author | jeremy <jeremy> | 2002-02-15 21:10:04 (UTC) |
---|---|---|
committer | jeremy <jeremy> | 2002-02-15 21:10:04 (UTC) |
commit | b15950bcf97b5590d37373ec2beedab80e40ded6 (patch) (unidiff) | |
tree | 85f44cdb278d0b0825868892db8d3bc2d2a5fba5 | |
parent | 756a71b71837bd6771bec8fc510e072a5f4233f8 (diff) | |
download | opie-b15950bcf97b5590d37373ec2beedab80e40ded6.zip opie-b15950bcf97b5590d37373ec2beedab80e40ded6.tar.gz opie-b15950bcf97b5590d37373ec2beedab80e40ded6.tar.bz2 |
Added support for the rec button on iPAQ's. This addition will only work if
you have opie-taskbar-1.5.0_beta7.1 ...
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 97 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.h | 1 |
2 files changed, 33 insertions, 65 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 5ce6fa9..006e0ba 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -140,3 +140,3 @@ VMemo::VMemo( QWidget *parent, const char *name ) | |||
140 | setFixedWidth( 14 ); | 140 | setFixedWidth( 14 ); |
141 | 141 | ||
142 | recording = FALSE; | 142 | recording = FALSE; |
@@ -144,6 +144,5 @@ VMemo::VMemo( QWidget *parent, const char *name ) | |||
144 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 144 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
145 | connect( myChannel, SIGNAL(sayHi()), this, SLOT(sayHi()) ); | ||
146 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 145 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
147 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 146 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
148 | 147 | ||
149 | struct utsname name; /* check for embedix kernel running on the zaurus, if | 148 | struct utsname name; /* check for embedix kernel running on the zaurus, if |
@@ -159,47 +158,9 @@ VMemo::VMemo( QWidget *parent, const char *name ) | |||
159 | { | 158 | { |
160 | int fr; | ||
161 | systemZaurus=FALSE; | 159 | systemZaurus=FALSE; |
162 | 160 | ||
163 | if ((fr = fork()) == -1) | 161 | // Register the REC key press. |
164 | { | 162 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); |
165 | qWarning("Fork failed"); | 163 | e << 4096; |
166 | } | 164 | e << QString("QPE/VMemo"); |
167 | else if (fr == 0) | 165 | e << QString("toggleRecord()"); |
168 | { | ||
169 | int key, max; | ||
170 | fd_set fdr; | ||
171 | char buffer[10]; | ||
172 | |||
173 | key = open("/dev/touchscreen/key", O_RDONLY); | ||
174 | if (key == -1) | ||
175 | { | ||
176 | qWarning("Could not open key"); | ||
177 | exit(1); | ||
178 | } | ||
179 | |||
180 | while(1) | ||
181 | { | ||
182 | FD_ZERO(&fdr); | ||
183 | FD_SET(key, &fdr); | ||
184 | max = key; | ||
185 | |||
186 | qWarning("while"); | ||
187 | |||
188 | read(key, buffer, 10); | ||
189 | if(*buffer == (char)129) | ||
190 | { | ||
191 | qWarning("REC = stop"); | ||
192 | QCopEnvelope( "QPE/VMemo", "toggleRecord()"); | ||
193 | QCopEnvelope( "QPE/VMemo", "sayHi()"); | ||
194 | } | ||
195 | else if(*buffer == (char)1) | ||
196 | { | ||
197 | qWarning("REC = start"); | ||
198 | QCopEnvelope( "QPE/VMemo", "toggleRecord()"); | ||
199 | QCopEnvelope( "QPE/VMemo", "sayHi()"); | ||
200 | } | ||
201 | } | ||
202 | } | ||
203 | else if(fr) | ||
204 | qWarning("parent: Fork = good"); | ||
205 | } | 166 | } |
@@ -213,7 +174,2 @@ VMemo::~VMemo() | |||
213 | 174 | ||
214 | void VMemo::sayHi() | ||
215 | { | ||
216 | qWarning("Hi"); | ||
217 | } | ||
218 | |||
219 | void VMemo::receive( const QCString &msg, const QByteArray &data ) | 175 | void VMemo::receive( const QCString &msg, const QByteArray &data ) |
@@ -221,6 +177,10 @@ void VMemo::receive( const QCString &msg, const QByteArray &data ) | |||
221 | QDataStream stream( data, IO_ReadOnly ); | 177 | QDataStream stream( data, IO_ReadOnly ); |
222 | qWarning(msg); | 178 | qWarning("VMemo::receive: %s", (const char *)msg); |
223 | if ( msg == "toggleRecord()" ) { | 179 | if (msg == "toggleRecord()") |
224 | qWarning("Hello"); | 180 | { |
225 | } | 181 | if (recording) |
182 | mouseReleaseEvent(NULL); | ||
183 | else | ||
184 | mousePressEvent(NULL); | ||
185 | } | ||
226 | } | 186 | } |
@@ -235,4 +195,2 @@ void VMemo::mousePressEvent( QMouseEvent * ) | |||
235 | { | 195 | { |
236 | QCopEnvelope( "QPE/VMemo", "sayHi()"); | ||
237 | |||
238 | // just to be safe | 196 | // just to be safe |
@@ -397,4 +355,4 @@ void VMemo::record(void) | |||
397 | { | 355 | { |
398 | int length=0, result, value; | 356 | int length=0, result, value; //, i; |
399 | char sound[8192]; | 357 | char sound[512]; //, leftBuffer[256], rightBuffer[256]; |
400 | 358 | ||
@@ -406,8 +364,20 @@ void VMemo::record(void) | |||
406 | qApp->processEvents(); | 364 | qApp->processEvents(); |
407 | write(wav, sound, result); | 365 | |
366 | /* attempt to write only one channel...didnt work. | ||
367 | for (i = 0; i < result; i++) { | ||
368 | leftBuffer[i] = sound[2*i]; | ||
369 | rightBuffer[i] = sound[2*i+1]; | ||
370 | } | ||
371 | */ | ||
408 | qApp->processEvents(); | 372 | qApp->processEvents(); |
373 | |||
374 | /* needed to only write one channel. comment out above "write/length" code. | ||
375 | write(wav, leftBuffer, result / 2); | ||
376 | length += result/2; | ||
377 | */ | ||
378 | |||
379 | write(wav, sound, result); | ||
409 | length += result; | 380 | length += result; |
381 | |||
410 | qApp->processEvents(); | 382 | qApp->processEvents(); |
411 | // printf("%d\r",length); | ||
412 | // fflush(stdout); | ||
413 | } | 383 | } |
@@ -422,3 +392,2 @@ void VMemo::record(void) | |||
422 | write(wav, &length, 4); | 392 | write(wav, &length, 4); |
423 | // qDebug("File length %d, samplecount %d", value, length); | ||
424 | track.close(); | 393 | track.close(); |
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h index 824309e..d96cd94 100644 --- a/core/applets/vmemo/vmemo.h +++ b/core/applets/vmemo/vmemo.h | |||
@@ -38,3 +38,2 @@ public slots: | |||
38 | void receive( const QCString &msg, const QByteArray &data ); | 38 | void receive( const QCString &msg, const QByteArray &data ); |
39 | void sayHi(); | ||
40 | 39 | ||