author | schurig <schurig> | 2004-09-10 12:18:17 (UTC) |
---|---|---|
committer | schurig <schurig> | 2004-09-10 12:18:17 (UTC) |
commit | 9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521 (patch) (unidiff) | |
tree | 53927c6a19c69d54bb3d0e092ac57180bcb60222 | |
parent | ed70ec4945c7816ec6e899207ec8b99e20e10da5 (diff) | |
download | opie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.zip opie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.tar.gz opie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.tar.bz2 |
added support for DEVFS
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 10 | ||||
-rw-r--r-- | core/applets/vtapplet/vt.cpp | 8 | ||||
-rw-r--r-- | libopie/odevice.cpp | 4 | ||||
-rw-r--r-- | libopie2/opiemm/osoundsystem.cpp | 5 | ||||
-rw-r--r-- | library/qpeapplication.cpp | 16 |
5 files changed, 40 insertions, 3 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index e747a19..07ef15c 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -366,108 +366,112 @@ bool VMemo::startRecording() { | |||
366 | DocLnk l; | 366 | DocLnk l; |
367 | l.setFile(fileName); | 367 | l.setFile(fileName); |
368 | l.setName(dlName); | 368 | l.setName(dlName); |
369 | l.setType("audio/x-wav"); | 369 | l.setType("audio/x-wav"); |
370 | l.setCategories(cats); | 370 | l.setCategories(cats); |
371 | l.writeLink(); | 371 | l.writeLink(); |
372 | return TRUE; | 372 | return TRUE; |
373 | } else | 373 | } else |
374 | return FALSE; | 374 | return FALSE; |
375 | 375 | ||
376 | } | 376 | } |
377 | 377 | ||
378 | void VMemo::stopRecording() { | 378 | void VMemo::stopRecording() { |
379 | // show(); | 379 | // show(); |
380 | odebug << "Stopped recording" << oendl; | 380 | odebug << "Stopped recording" << oendl; |
381 | recording = FALSE; | 381 | recording = FALSE; |
382 | if(useAlerts) { | 382 | if(useAlerts) { |
383 | msgLabel->close(); | 383 | msgLabel->close(); |
384 | msgLabel=0; | 384 | msgLabel=0; |
385 | delete msgLabel; | 385 | delete msgLabel; |
386 | } | 386 | } |
387 | t_timer->stop(); | 387 | t_timer->stop(); |
388 | Config cfg("Vmemo"); | 388 | Config cfg("Vmemo"); |
389 | cfg.setGroup("Defaults"); | 389 | cfg.setGroup("Defaults"); |
390 | // if( cfg.readNumEntry("hideIcon",0) == 1 ) | 390 | // if( cfg.readNumEntry("hideIcon",0) == 1 ) |
391 | // hide(); | 391 | // hide(); |
392 | } | 392 | } |
393 | 393 | ||
394 | int VMemo::openDSP() { | 394 | int VMemo::openDSP() { |
395 | Config cfg("Vmemo"); | 395 | Config cfg("Vmemo"); |
396 | cfg.setGroup("Record"); | 396 | cfg.setGroup("Record"); |
397 | 397 | ||
398 | speed = cfg.readNumEntry("SampleRate", 22050); | 398 | speed = cfg.readNumEntry("SampleRate", 22050); |
399 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 399 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
400 | if (cfg.readNumEntry("SixteenBit", 1)==1) { | 400 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
401 | format = AFMT_S16_LE; | 401 | format = AFMT_S16_LE; |
402 | resolution = 16; | 402 | resolution = 16; |
403 | } else { | 403 | } else { |
404 | format = AFMT_U8; | 404 | format = AFMT_U8; |
405 | resolution = 8; | 405 | resolution = 8; |
406 | } | 406 | } |
407 | 407 | ||
408 | odebug << "samplerate: " << speed << ", channels " << channels << ", resolution " << resolution << "" << oendl; | 408 | odebug << "samplerate: " << speed << ", channels " << channels << ", resolution " << resolution << "" << oendl; |
409 | 409 | ||
410 | if(systemZaurus) { | 410 | if(systemZaurus) { |
411 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 | 411 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 |
412 | channels=1; //zaurus has one input channel | 412 | channels=1; //zaurus has one input channel |
413 | } else { | 413 | } else { |
414 | #ifdef QT_QWS_DEVFS | ||
415 | dsp = open("/dev/sound/dsp", O_RDONLY); | ||
416 | #else | ||
414 | dsp = open("/dev/dsp", O_RDONLY); | 417 | dsp = open("/dev/dsp", O_RDONLY); |
418 | #endif | ||
415 | } | 419 | } |
416 | 420 | ||
417 | if(dsp == -1) { | 421 | if (dsp == -1) { |
418 | msgLabel->close(); | 422 | msgLabel->close(); |
419 | msgLabel=0; | 423 | msgLabel=0; |
420 | delete msgLabel; | 424 | delete msgLabel; |
421 | 425 | ||
422 | perror("open(\"/dev/dsp\")"); | 426 | perror("open(\"/dev/dsp\")"); |
423 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); | 427 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); |
424 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); | 428 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); |
425 | return -1; | 429 | return -1; |
426 | } | 430 | } |
427 | 431 | ||
428 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 432 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
429 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 433 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
430 | return -1; | 434 | return -1; |
431 | } | 435 | } |
432 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { | 436 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { |
433 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 437 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
434 | return -1; | 438 | return -1; |
435 | } | 439 | } |
436 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { | 440 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { |
437 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 441 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
438 | return -1; | 442 | return -1; |
439 | } | 443 | } |
440 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { | 444 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { |
441 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); | 445 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); |
442 | return -1; | 446 | return -1; |
443 | } | 447 | } |
444 | 448 | ||
445 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute | 449 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute |
446 | 450 | ||
447 | return 1; | 451 | return 1; |
448 | } | 452 | } |
449 | 453 | ||
450 | int VMemo::openWAV(const char *filename) { | 454 | int VMemo::openWAV(const char *filename) { |
451 | track.setName(filename); | 455 | track.setName(filename); |
452 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { | 456 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { |
453 | errorMsg=filename; | 457 | errorMsg=filename; |
454 | return -1; | 458 | return -1; |
455 | } | 459 | } |
456 | 460 | ||
457 | wav=track.handle(); | 461 | wav=track.handle(); |
458 | Config vmCfg("Vmemo"); | 462 | Config vmCfg("Vmemo"); |
459 | vmCfg.setGroup("Defaults"); | 463 | vmCfg.setGroup("Defaults"); |
460 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 464 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
461 | 465 | ||
462 | WaveHeader wh; | 466 | WaveHeader wh; |
463 | 467 | ||
464 | wh.main_chunk = RIFF; | 468 | wh.main_chunk = RIFF; |
465 | wh.length=0; | 469 | wh.length=0; |
466 | wh.chunk_type = WAVE; | 470 | wh.chunk_type = WAVE; |
467 | wh.sub_chunk = FMT; | 471 | wh.sub_chunk = FMT; |
468 | wh.sc_len = 16; | 472 | wh.sc_len = 16; |
469 | if(useADPCM) | 473 | if(useADPCM) |
470 | wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; | 474 | wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; |
471 | else | 475 | else |
472 | wh.format = PCM_CODE; | 476 | wh.format = PCM_CODE; |
473 | wh.modus = channels; | 477 | wh.modus = channels; |
diff --git a/core/applets/vtapplet/vt.cpp b/core/applets/vtapplet/vt.cpp index aec63c3..7832ee0 100644 --- a/core/applets/vtapplet/vt.cpp +++ b/core/applets/vtapplet/vt.cpp | |||
@@ -35,121 +35,129 @@ VTApplet::VTApplet ( ) | |||
35 | } | 35 | } |
36 | 36 | ||
37 | VTApplet::~VTApplet ( ) | 37 | VTApplet::~VTApplet ( ) |
38 | { | 38 | { |
39 | } | 39 | } |
40 | 40 | ||
41 | int VTApplet::position ( ) const | 41 | int VTApplet::position ( ) const |
42 | { | 42 | { |
43 | return 2; | 43 | return 2; |
44 | } | 44 | } |
45 | 45 | ||
46 | QString VTApplet::name ( ) const | 46 | QString VTApplet::name ( ) const |
47 | { | 47 | { |
48 | return tr( "VT shortcut" ); | 48 | return tr( "VT shortcut" ); |
49 | } | 49 | } |
50 | 50 | ||
51 | QString VTApplet::text ( ) const | 51 | QString VTApplet::text ( ) const |
52 | { | 52 | { |
53 | return tr( "Terminal" ); | 53 | return tr( "Terminal" ); |
54 | } | 54 | } |
55 | 55 | ||
56 | /* | 56 | /* |
57 | QString VTApplet::tr( const char* s ) const | 57 | QString VTApplet::tr( const char* s ) const |
58 | { | 58 | { |
59 | return qApp->translate( "VTApplet", s, 0 ); | 59 | return qApp->translate( "VTApplet", s, 0 ); |
60 | } | 60 | } |
61 | 61 | ||
62 | QString VTApplet::tr( const char* s, const char* p ) const | 62 | QString VTApplet::tr( const char* s, const char* p ) const |
63 | { | 63 | { |
64 | return qApp->translate( "VTApplet", s, p ); | 64 | return qApp->translate( "VTApplet", s, p ); |
65 | } | 65 | } |
66 | */ | 66 | */ |
67 | 67 | ||
68 | QIconSet VTApplet::icon ( ) const | 68 | QIconSet VTApplet::icon ( ) const |
69 | { | 69 | { |
70 | QPixmap pix; | 70 | QPixmap pix; |
71 | QImage img = Resource::loadImage ( "terminal" ); | 71 | QImage img = Resource::loadImage ( "terminal" ); |
72 | 72 | ||
73 | if ( !img. isNull ( )) | 73 | if ( !img. isNull ( )) |
74 | pix. convertFromImage ( img. smoothScale ( 14, 14 )); | 74 | pix. convertFromImage ( img. smoothScale ( 14, 14 )); |
75 | return pix; | 75 | return pix; |
76 | } | 76 | } |
77 | 77 | ||
78 | QPopupMenu *VTApplet::popup ( QWidget* parent ) const | 78 | QPopupMenu *VTApplet::popup ( QWidget* parent ) const |
79 | { | 79 | { |
80 | odebug << "VTApplet::popup" << oendl; | 80 | odebug << "VTApplet::popup" << oendl; |
81 | 81 | ||
82 | struct vt_stat vtstat; | 82 | struct vt_stat vtstat; |
83 | #ifdef QT_QWS_DEVFS | ||
84 | int fd = ::open( "/dev/vc/0", O_RDWR ); | ||
85 | #else | ||
83 | int fd = ::open( "/dev/tty0", O_RDWR ); | 86 | int fd = ::open( "/dev/tty0", O_RDWR ); |
87 | #endif | ||
84 | if ( fd == -1 ) return 0; | 88 | if ( fd == -1 ) return 0; |
85 | if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0; | 89 | if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0; |
86 | 90 | ||
87 | m_subMenu = new QPopupMenu( parent ); | 91 | m_subMenu = new QPopupMenu( parent ); |
88 | m_subMenu->setCheckable( true ); | 92 | m_subMenu->setCheckable( true ); |
89 | for ( int i = 1; i < 10; ++i ) | 93 | for ( int i = 1; i < 10; ++i ) |
90 | { | 94 | { |
91 | int id = m_subMenu->insertItem( QString::number( i ), 500+i ); | 95 | int id = m_subMenu->insertItem( QString::number( i ), 500+i ); |
92 | m_subMenu->setItemChecked( id, id-500 == vtstat.v_active ); | 96 | m_subMenu->setItemChecked( id, id-500 == vtstat.v_active ); |
93 | } | 97 | } |
94 | ::close( fd ); | 98 | ::close( fd ); |
95 | 99 | ||
96 | connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) ); | 100 | connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) ); |
97 | connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) ); | 101 | connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) ); |
98 | 102 | ||
99 | return m_subMenu; | 103 | return m_subMenu; |
100 | } | 104 | } |
101 | 105 | ||
102 | 106 | ||
103 | void VTApplet::changeVT( int index ) | 107 | void VTApplet::changeVT( int index ) |
104 | { | 108 | { |
105 | //odebug << "VTApplet::changeVT( " << index-500 << " )" << oendl; | 109 | //odebug << "VTApplet::changeVT( " << index-500 << " )" << oendl; |
106 | 110 | ||
111 | #ifdef QT_QWS_DEVFS | ||
112 | int fd = ::open("/dev/vc/0", O_RDWR); | ||
113 | #else | ||
107 | int fd = ::open("/dev/tty0", O_RDWR); | 114 | int fd = ::open("/dev/tty0", O_RDWR); |
115 | #endif | ||
108 | if ( fd == -1 ) return; | 116 | if ( fd == -1 ) return; |
109 | ioctl( fd, VT_ACTIVATE, index-500 ); | 117 | ioctl( fd, VT_ACTIVATE, index-500 ); |
110 | } | 118 | } |
111 | 119 | ||
112 | 120 | ||
113 | void VTApplet::updateMenu() | 121 | void VTApplet::updateMenu() |
114 | { | 122 | { |
115 | //odebug << "VTApplet::updateMenu()" << oendl; | 123 | //odebug << "VTApplet::updateMenu()" << oendl; |
116 | 124 | ||
117 | int fd = ::open( "/dev/console", O_RDONLY ); | 125 | int fd = ::open( "/dev/console", O_RDONLY ); |
118 | if ( fd == -1 ) return; | 126 | if ( fd == -1 ) return; |
119 | 127 | ||
120 | for ( int i = 1; i < 10; ++i ) | 128 | for ( int i = 1; i < 10; ++i ) |
121 | { | 129 | { |
122 | int result = ioctl( fd, VT_DISALLOCATE, i ); | 130 | int result = ioctl( fd, VT_DISALLOCATE, i ); |
123 | 131 | ||
124 | /* | 132 | /* |
125 | if ( result == -1 ) | 133 | if ( result == -1 ) |
126 | odebug << "VT " << i << " disallocated == free" << oendl; | 134 | odebug << "VT " << i << " disallocated == free" << oendl; |
127 | else | 135 | else |
128 | odebug << "VT " << i << " _not_ disallocated == busy" << oendl; | 136 | odebug << "VT " << i << " _not_ disallocated == busy" << oendl; |
129 | */ | 137 | */ |
130 | 138 | ||
131 | m_subMenu->setItemEnabled( 500+i, result == -1 ); | 139 | m_subMenu->setItemEnabled( 500+i, result == -1 ); |
132 | } | 140 | } |
133 | 141 | ||
134 | ::close( fd ); | 142 | ::close( fd ); |
135 | } | 143 | } |
136 | 144 | ||
137 | 145 | ||
138 | void VTApplet::activated() | 146 | void VTApplet::activated() |
139 | { | 147 | { |
140 | odebug << "VTApplet::activated()" << oendl; | 148 | odebug << "VTApplet::activated()" << oendl; |
141 | } | 149 | } |
142 | 150 | ||
143 | 151 | ||
144 | QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | 152 | QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) |
145 | { | 153 | { |
146 | *iface = 0; | 154 | *iface = 0; |
147 | if ( uuid == IID_QUnknown ) | 155 | if ( uuid == IID_QUnknown ) |
148 | *iface = this; | 156 | *iface = this; |
149 | else if ( uuid == IID_MenuApplet ) | 157 | else if ( uuid == IID_MenuApplet ) |
150 | *iface = this; | 158 | *iface = this; |
151 | else | 159 | else |
152 | return QS_FALSE; | 160 | return QS_FALSE; |
153 | 161 | ||
154 | if ( *iface ) | 162 | if ( *iface ) |
155 | (*iface)-> addRef ( ); | 163 | (*iface)-> addRef ( ); |
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 21070bf..9d0bbbf 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -550,97 +550,101 @@ bool ODevice::suspend ( ) | |||
550 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 550 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
551 | return false; | 551 | return false; |
552 | 552 | ||
553 | bool res = false; | 553 | bool res = false; |
554 | 554 | ||
555 | struct timeval tvs, tvn; | 555 | struct timeval tvs, tvn; |
556 | ::gettimeofday ( &tvs, 0 ); | 556 | ::gettimeofday ( &tvs, 0 ); |
557 | 557 | ||
558 | ::sync ( ); // flush fs caches | 558 | ::sync ( ); // flush fs caches |
559 | res = ( ::system ( "apm --suspend" ) == 0 ); | 559 | res = ( ::system ( "apm --suspend" ) == 0 ); |
560 | 560 | ||
561 | // This is needed because the iPAQ apm implementation is asynchronous and we | 561 | // This is needed because the iPAQ apm implementation is asynchronous and we |
562 | // can not be sure when exactly the device is really suspended | 562 | // can not be sure when exactly the device is really suspended |
563 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 563 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
564 | 564 | ||
565 | if ( res ) { | 565 | if ( res ) { |
566 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 566 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
567 | ::usleep ( 200 * 1000 ); | 567 | ::usleep ( 200 * 1000 ); |
568 | ::gettimeofday ( &tvn, 0 ); | 568 | ::gettimeofday ( &tvn, 0 ); |
569 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 569 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
570 | } | 570 | } |
571 | 571 | ||
572 | return res; | 572 | return res; |
573 | } | 573 | } |
574 | 574 | ||
575 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 575 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
576 | 576 | ||
577 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 577 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
578 | 578 | ||
579 | /* VESA Blanking Levels */ | 579 | /* VESA Blanking Levels */ |
580 | #define VESA_NO_BLANKING 0 | 580 | #define VESA_NO_BLANKING 0 |
581 | #define VESA_VSYNC_SUSPEND 1 | 581 | #define VESA_VSYNC_SUSPEND 1 |
582 | #define VESA_HSYNC_SUSPEND 2 | 582 | #define VESA_HSYNC_SUSPEND 2 |
583 | #define VESA_POWERDOWN 3 | 583 | #define VESA_POWERDOWN 3 |
584 | 584 | ||
585 | /** | 585 | /** |
586 | * This sets the display on or off | 586 | * This sets the display on or off |
587 | */ | 587 | */ |
588 | bool ODevice::setDisplayStatus ( bool on ) | 588 | bool ODevice::setDisplayStatus ( bool on ) |
589 | { | 589 | { |
590 | qDebug("ODevice::setDisplayStatus(%d)", on); | 590 | qDebug("ODevice::setDisplayStatus(%d)", on); |
591 | 591 | ||
592 | if ( d-> m_model == Model_Unknown ) | 592 | if ( d-> m_model == Model_Unknown ) |
593 | return false; | 593 | return false; |
594 | 594 | ||
595 | bool res = false; | 595 | bool res = false; |
596 | int fd; | 596 | int fd; |
597 | 597 | ||
598 | #ifdef QT_QWS_DEVFS | ||
599 | if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { | ||
600 | #else | ||
598 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 601 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
602 | #endif | ||
599 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 603 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
600 | ::close ( fd ); | 604 | ::close ( fd ); |
601 | } | 605 | } |
602 | return res; | 606 | return res; |
603 | } | 607 | } |
604 | 608 | ||
605 | /** | 609 | /** |
606 | * This sets the display brightness | 610 | * This sets the display brightness |
607 | * | 611 | * |
608 | * @param p The brightness to be set on a scale from 0 to 255 | 612 | * @param p The brightness to be set on a scale from 0 to 255 |
609 | * @return success or failure | 613 | * @return success or failure |
610 | */ | 614 | */ |
611 | bool ODevice::setDisplayBrightness ( int p) | 615 | bool ODevice::setDisplayBrightness ( int p) |
612 | { | 616 | { |
613 | Q_UNUSED( p ) | 617 | Q_UNUSED( p ) |
614 | return false; | 618 | return false; |
615 | } | 619 | } |
616 | 620 | ||
617 | /** | 621 | /** |
618 | * @return returns the number of steppings on the brightness slider | 622 | * @return returns the number of steppings on the brightness slider |
619 | * in the Light-'n-Power settings. | 623 | * in the Light-'n-Power settings. |
620 | */ | 624 | */ |
621 | int ODevice::displayBrightnessResolution ( ) const | 625 | int ODevice::displayBrightnessResolution ( ) const |
622 | { | 626 | { |
623 | return 16; | 627 | return 16; |
624 | } | 628 | } |
625 | 629 | ||
626 | /** | 630 | /** |
627 | * This sets the display contrast | 631 | * This sets the display contrast |
628 | * @param p The contrast to be set on a scale from 0 to 255 | 632 | * @param p The contrast to be set on a scale from 0 to 255 |
629 | * @return success or failure | 633 | * @return success or failure |
630 | */ | 634 | */ |
631 | bool ODevice::setDisplayContrast ( int p) | 635 | bool ODevice::setDisplayContrast ( int p) |
632 | { | 636 | { |
633 | Q_UNUSED( p ) | 637 | Q_UNUSED( p ) |
634 | return false; | 638 | return false; |
635 | } | 639 | } |
636 | 640 | ||
637 | /** | 641 | /** |
638 | * @return return the max value for the brightness settings slider | 642 | * @return return the max value for the brightness settings slider |
639 | * or 0 if the device doesn't support setting of a contrast | 643 | * or 0 if the device doesn't support setting of a contrast |
640 | */ | 644 | */ |
641 | int ODevice::displayContrastResolution ( ) const | 645 | int ODevice::displayContrastResolution ( ) const |
642 | { | 646 | { |
643 | return 0; | 647 | return 0; |
644 | } | 648 | } |
645 | 649 | ||
646 | /** | 650 | /** |
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp index 763ff65..17e5cb0 100644 --- a/libopie2/opiemm/osoundsystem.cpp +++ b/libopie2/opiemm/osoundsystem.cpp | |||
@@ -92,98 +92,103 @@ void OSoundSystem::synchronize() | |||
92 | */ | 92 | */ |
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | int OSoundSystem::count() const | 96 | int OSoundSystem::count() const |
97 | { | 97 | { |
98 | return _interfaces.count(); | 98 | return _interfaces.count(); |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | OSoundCard* OSoundSystem::card( const QString& iface ) const | 102 | OSoundCard* OSoundSystem::card( const QString& iface ) const |
103 | { | 103 | { |
104 | return _interfaces[iface]; | 104 | return _interfaces[iface]; |
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | OSoundSystem* OSoundSystem::instance() | 108 | OSoundSystem* OSoundSystem::instance() |
109 | { | 109 | { |
110 | if ( !_instance ) _instance = new OSoundSystem(); | 110 | if ( !_instance ) _instance = new OSoundSystem(); |
111 | return _instance; | 111 | return _instance; |
112 | } | 112 | } |
113 | 113 | ||
114 | 114 | ||
115 | OSoundSystem::CardIterator OSoundSystem::iterator() const | 115 | OSoundSystem::CardIterator OSoundSystem::iterator() const |
116 | { | 116 | { |
117 | return OSoundSystem::CardIterator( _interfaces ); | 117 | return OSoundSystem::CardIterator( _interfaces ); |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | /*====================================================================================== | 121 | /*====================================================================================== |
122 | * OSoundCard | 122 | * OSoundCard |
123 | *======================================================================================*/ | 123 | *======================================================================================*/ |
124 | 124 | ||
125 | OSoundCard::OSoundCard( QObject* parent, const char* name ) | 125 | OSoundCard::OSoundCard( QObject* parent, const char* name ) |
126 | :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) | 126 | :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) |
127 | { | 127 | { |
128 | odebug << "OSoundCard::OSoundCard()" << oendl; | 128 | odebug << "OSoundCard::OSoundCard()" << oendl; |
129 | init(); | 129 | init(); |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | OSoundCard::~OSoundCard() | 133 | OSoundCard::~OSoundCard() |
134 | { | 134 | { |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | void OSoundCard::init() | 138 | void OSoundCard::init() |
139 | { | 139 | { |
140 | #ifdef QT_QWS_DEVFS | ||
141 | _audio = new OAudioInterface( this, "/dev/sound/dsp" ); | ||
142 | _mixer = new OMixerInterface( this, "/dev/sound/mixer" ); | ||
143 | #else | ||
140 | _audio = new OAudioInterface( this, "/dev/dsp" ); | 144 | _audio = new OAudioInterface( this, "/dev/dsp" ); |
141 | _mixer = new OMixerInterface( this, "/dev/mixer" ); | 145 | _mixer = new OMixerInterface( this, "/dev/mixer" ); |
146 | #endif | ||
142 | } | 147 | } |
143 | 148 | ||
144 | 149 | ||
145 | /*====================================================================================== | 150 | /*====================================================================================== |
146 | * OAudioInterface | 151 | * OAudioInterface |
147 | *======================================================================================*/ | 152 | *======================================================================================*/ |
148 | 153 | ||
149 | OAudioInterface::OAudioInterface( QObject* parent, const char* name ) | 154 | OAudioInterface::OAudioInterface( QObject* parent, const char* name ) |
150 | :QObject( parent, name ), _sfd(0) | 155 | :QObject( parent, name ), _sfd(0) |
151 | { | 156 | { |
152 | odebug << "OAudioInterface::OAudioInterface()" << oendl; | 157 | odebug << "OAudioInterface::OAudioInterface()" << oendl; |
153 | init(); | 158 | init(); |
154 | } | 159 | } |
155 | 160 | ||
156 | 161 | ||
157 | OAudioInterface::~OAudioInterface() | 162 | OAudioInterface::~OAudioInterface() |
158 | { | 163 | { |
159 | } | 164 | } |
160 | 165 | ||
161 | 166 | ||
162 | void OAudioInterface::init() | 167 | void OAudioInterface::init() |
163 | { | 168 | { |
164 | 169 | ||
165 | 170 | ||
166 | } | 171 | } |
167 | 172 | ||
168 | 173 | ||
169 | /*====================================================================================== | 174 | /*====================================================================================== |
170 | * OMixerInterface | 175 | * OMixerInterface |
171 | *======================================================================================*/ | 176 | *======================================================================================*/ |
172 | 177 | ||
173 | OMixerInterface::OMixerInterface( QObject* parent, const char* name ) | 178 | OMixerInterface::OMixerInterface( QObject* parent, const char* name ) |
174 | :QObject( parent, name ) | 179 | :QObject( parent, name ) |
175 | { | 180 | { |
176 | odebug << "OMixerInterface::OMixerInterface()" << oendl; | 181 | odebug << "OMixerInterface::OMixerInterface()" << oendl; |
177 | init(); | 182 | init(); |
178 | } | 183 | } |
179 | 184 | ||
180 | 185 | ||
181 | OMixerInterface::~OMixerInterface() | 186 | OMixerInterface::~OMixerInterface() |
182 | { | 187 | { |
183 | } | 188 | } |
184 | 189 | ||
185 | 190 | ||
186 | void OMixerInterface::init() | 191 | void OMixerInterface::init() |
187 | { | 192 | { |
188 | // open the device | 193 | // open the device |
189 | _fd = ::open( name(), O_RDWR ); | 194 | _fd = ::open( name(), O_RDWR ); |
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index c6d9cfd..ca90427 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -520,168 +520,184 @@ public: | |||
520 | { | 520 | { |
521 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 521 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
522 | if ( !r ) { | 522 | if ( !r ) { |
523 | int sl = abs_name.length(); | 523 | int sl = abs_name.length(); |
524 | do { | 524 | do { |
525 | sl = abs_name.findRev( '/', sl - 1 ); | 525 | sl = abs_name.findRev( '/', sl - 1 ); |
526 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 526 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
527 | int dot = name.findRev( '.' ); | 527 | int dot = name.findRev( '.' ); |
528 | if ( dot >= 0 ) | 528 | if ( dot >= 0 ) |
529 | name = name.left( dot ); | 529 | name = name.left( dot ); |
530 | QImage img = Resource::loadImage( name ); | 530 | QImage img = Resource::loadImage( name ); |
531 | if ( !img.isNull() ) { | 531 | if ( !img.isNull() ) { |
532 | delete resImage; | 532 | delete resImage; |
533 | resImage = new QImageDrag( img ); | 533 | resImage = new QImageDrag( img ); |
534 | r = resImage; | 534 | r = resImage; |
535 | } | 535 | } |
536 | } | 536 | } |
537 | while ( !r && sl > 0 ); | 537 | while ( !r && sl > 0 ); |
538 | } | 538 | } |
539 | return r; | 539 | return r; |
540 | } | 540 | } |
541 | private: | 541 | private: |
542 | mutable QImageDrag *resImage; | 542 | mutable QImageDrag *resImage; |
543 | }; | 543 | }; |
544 | 544 | ||
545 | static int& hack(int& i) | 545 | static int& hack(int& i) |
546 | { | 546 | { |
547 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 547 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
548 | // These should be created, but aren't in Qt 2.3.0 | 548 | // These should be created, but aren't in Qt 2.3.0 |
549 | (void)new QUtf8Codec; | 549 | (void)new QUtf8Codec; |
550 | (void)new QUtf16Codec; | 550 | (void)new QUtf16Codec; |
551 | #endif | 551 | #endif |
552 | return i; | 552 | return i; |
553 | } | 553 | } |
554 | 554 | ||
555 | static int muted = 0; | 555 | static int muted = 0; |
556 | static int micMuted = 0; | 556 | static int micMuted = 0; |
557 | 557 | ||
558 | static void setVolume( int t = 0, int percent = -1 ) | 558 | static void setVolume( int t = 0, int percent = -1 ) |
559 | { | 559 | { |
560 | switch ( t ) { | 560 | switch ( t ) { |
561 | case 0: { | 561 | case 0: { |
562 | Config cfg( "qpe" ); | 562 | Config cfg( "qpe" ); |
563 | cfg.setGroup( "Volume" ); | 563 | cfg.setGroup( "Volume" ); |
564 | if ( percent < 0 ) | 564 | if ( percent < 0 ) |
565 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 565 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
566 | #ifndef QT_NO_SOUND | 566 | #ifndef QT_NO_SOUND |
567 | int fd = 0; | 567 | int fd = 0; |
568 | #ifdef QT_QWS_DEVFS | ||
569 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
570 | #else | ||
568 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 571 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
572 | #endif | ||
569 | int vol = muted ? 0 : percent; | 573 | int vol = muted ? 0 : percent; |
570 | // set both channels to same volume | 574 | // set both channels to same volume |
571 | vol |= vol << 8; | 575 | vol |= vol << 8; |
572 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); | 576 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); |
573 | ::close( fd ); | 577 | ::close( fd ); |
574 | } | 578 | } |
575 | #endif | 579 | #endif |
576 | } | 580 | } |
577 | break; | 581 | break; |
578 | } | 582 | } |
579 | } | 583 | } |
580 | 584 | ||
581 | static void setMic( int t = 0, int percent = -1 ) | 585 | static void setMic( int t = 0, int percent = -1 ) |
582 | { | 586 | { |
583 | switch ( t ) { | 587 | switch ( t ) { |
584 | case 0: { | 588 | case 0: { |
585 | Config cfg( "qpe" ); | 589 | Config cfg( "qpe" ); |
586 | cfg.setGroup( "Volume" ); | 590 | cfg.setGroup( "Volume" ); |
587 | if ( percent < 0 ) | 591 | if ( percent < 0 ) |
588 | percent = cfg.readNumEntry( "Mic", 50 ); | 592 | percent = cfg.readNumEntry( "Mic", 50 ); |
589 | 593 | ||
590 | #ifndef QT_NO_SOUND | 594 | #ifndef QT_NO_SOUND |
591 | int fd = 0; | 595 | int fd = 0; |
592 | int mic = micMuted ? 0 : percent; | 596 | int mic = micMuted ? 0 : percent; |
597 | #ifdef QT_QWS_DEVFS | ||
598 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
599 | #else | ||
593 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 600 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
601 | #endif | ||
594 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 602 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
595 | ::close( fd ); | 603 | ::close( fd ); |
596 | } | 604 | } |
597 | #endif | 605 | #endif |
598 | } | 606 | } |
599 | break; | 607 | break; |
600 | } | 608 | } |
601 | } | 609 | } |
602 | 610 | ||
603 | 611 | ||
604 | static void setBass( int t = 0, int percent = -1 ) | 612 | static void setBass( int t = 0, int percent = -1 ) |
605 | { | 613 | { |
606 | switch ( t ) { | 614 | switch ( t ) { |
607 | case 0: { | 615 | case 0: { |
608 | Config cfg( "qpe" ); | 616 | Config cfg( "qpe" ); |
609 | cfg.setGroup( "Volume" ); | 617 | cfg.setGroup( "Volume" ); |
610 | if ( percent < 0 ) | 618 | if ( percent < 0 ) |
611 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 619 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
612 | 620 | ||
613 | #ifndef QT_NO_SOUND | 621 | #ifndef QT_NO_SOUND |
614 | int fd = 0; | 622 | int fd = 0; |
615 | int bass = percent; | 623 | int bass = percent; |
624 | #ifdef QT_QWS_DEVFS | ||
625 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
626 | #else | ||
616 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 627 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
628 | #endif | ||
617 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 629 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
618 | ::close( fd ); | 630 | ::close( fd ); |
619 | } | 631 | } |
620 | #endif | 632 | #endif |
621 | } | 633 | } |
622 | break; | 634 | break; |
623 | } | 635 | } |
624 | } | 636 | } |
625 | 637 | ||
626 | 638 | ||
627 | static void setTreble( int t = 0, int percent = -1 ) | 639 | static void setTreble( int t = 0, int percent = -1 ) |
628 | { | 640 | { |
629 | switch ( t ) { | 641 | switch ( t ) { |
630 | case 0: { | 642 | case 0: { |
631 | Config cfg( "qpe" ); | 643 | Config cfg( "qpe" ); |
632 | cfg.setGroup( "Volume" ); | 644 | cfg.setGroup( "Volume" ); |
633 | if ( percent < 0 ) | 645 | if ( percent < 0 ) |
634 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 646 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
635 | 647 | ||
636 | #ifndef QT_NO_SOUND | 648 | #ifndef QT_NO_SOUND |
637 | int fd = 0; | 649 | int fd = 0; |
638 | int treble = percent; | 650 | int treble = percent; |
651 | #ifdef QT_QWS_DEVFS | ||
652 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
653 | #else | ||
639 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 654 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
655 | #endif | ||
640 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 656 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
641 | ::close( fd ); | 657 | ::close( fd ); |
642 | } | 658 | } |
643 | #endif | 659 | #endif |
644 | } | 660 | } |
645 | break; | 661 | break; |
646 | } | 662 | } |
647 | } | 663 | } |
648 | 664 | ||
649 | 665 | ||
650 | /** | 666 | /** |
651 | \class QPEApplication | 667 | \class QPEApplication |
652 | \brief The QPEApplication class implements various system services | 668 | \brief The QPEApplication class implements various system services |
653 | that are available to all Qtopia applications. | 669 | that are available to all Qtopia applications. |
654 | 670 | ||
655 | Simply by using QPEApplication instead of QApplication, a standard Qt | 671 | Simply by using QPEApplication instead of QApplication, a standard Qt |
656 | application becomes a Qtopia application. It automatically follows | 672 | application becomes a Qtopia application. It automatically follows |
657 | style changes, quits and raises, and in the | 673 | style changes, quits and raises, and in the |
658 | case of \link docwidget.html document-oriented\endlink applications, | 674 | case of \link docwidget.html document-oriented\endlink applications, |
659 | changes the currently displayed document in response to the environment. | 675 | changes the currently displayed document in response to the environment. |
660 | 676 | ||
661 | To create a \link docwidget.html document-oriented\endlink | 677 | To create a \link docwidget.html document-oriented\endlink |
662 | application use showMainDocumentWidget(); to create a | 678 | application use showMainDocumentWidget(); to create a |
663 | non-document-oriented application use showMainWidget(). The | 679 | non-document-oriented application use showMainWidget(). The |
664 | keepRunning() function indicates whether the application will | 680 | keepRunning() function indicates whether the application will |
665 | continue running after it's processed the last \link qcop.html | 681 | continue running after it's processed the last \link qcop.html |
666 | QCop\endlink message. This can be changed using setKeepRunning(). | 682 | QCop\endlink message. This can be changed using setKeepRunning(). |
667 | 683 | ||
668 | A variety of signals are emitted when certain events occur, for | 684 | A variety of signals are emitted when certain events occur, for |
669 | example, timeChanged(), clockChanged(), weekChanged(), | 685 | example, timeChanged(), clockChanged(), weekChanged(), |
670 | dateFormatChanged() and volumeChanged(). If the application receives | 686 | dateFormatChanged() and volumeChanged(). If the application receives |
671 | a \link qcop.html QCop\endlink message on the application's | 687 | a \link qcop.html QCop\endlink message on the application's |
672 | QPE/Application/\e{appname} channel, the appMessage() signal is | 688 | QPE/Application/\e{appname} channel, the appMessage() signal is |
673 | emitted. There are also flush() and reload() signals, which | 689 | emitted. There are also flush() and reload() signals, which |
674 | are emitted when synching begins and ends respectively - upon these | 690 | are emitted when synching begins and ends respectively - upon these |
675 | signals, the application should save and reload any data | 691 | signals, the application should save and reload any data |
676 | files that are involved in synching. Most of these signals will initially | 692 | files that are involved in synching. Most of these signals will initially |
677 | be received and unfiltered through the appMessage() signal. | 693 | be received and unfiltered through the appMessage() signal. |
678 | 694 | ||
679 | This class also provides a set of useful static functions. The | 695 | This class also provides a set of useful static functions. The |
680 | qpeDir() and documentDir() functions return the respective paths. | 696 | qpeDir() and documentDir() functions return the respective paths. |
681 | The grabKeyboard() and ungrabKeyboard() functions are used to | 697 | The grabKeyboard() and ungrabKeyboard() functions are used to |
682 | control whether the application takes control of the device's | 698 | control whether the application takes control of the device's |
683 | physical buttons (e.g. application launch keys). The stylus' mode of | 699 | physical buttons (e.g. application launch keys). The stylus' mode of |
684 | operation is set with setStylusOperation() and retrieved with | 700 | operation is set with setStylusOperation() and retrieved with |
685 | stylusOperation(). There are also setInputMethodHint() and | 701 | stylusOperation(). There are also setInputMethodHint() and |
686 | inputMethodHint() functions. | 702 | inputMethodHint() functions. |
687 | 703 | ||