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 /core/applets | |
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 | 4 | ||||
-rw-r--r-- | core/applets/vtapplet/vt.cpp | 8 |
2 files changed, 12 insertions, 0 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 | |||
@@ -390,49 +390,53 @@ void VMemo::stopRecording() { | |||
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; |
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 | |||
@@ -59,73 +59,81 @@ QString VTApplet::tr( const char* s ) const | |||
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 ); |