author | jeremy <jeremy> | 2002-02-19 20:44:24 (UTC) |
---|---|---|
committer | jeremy <jeremy> | 2002-02-19 20:44:24 (UTC) |
commit | 4532d74ad882dc3c14cf1c42931e5cedf31cba05 (patch) (unidiff) | |
tree | 728e3e2c0924f9e11bc9e0f27eb974589ca37e2b | |
parent | 3ed313993ab9fa0f6a8c8ca2b2fe0f5c8cf39dc6 (diff) | |
download | opie-4532d74ad882dc3c14cf1c42931e5cedf31cba05.zip opie-4532d74ad882dc3c14cf1c42931e5cedf31cba05.tar.gz opie-4532d74ad882dc3c14cf1c42931e5cedf31cba05.tar.bz2 |
Temporarly disabled the mousePress and Release events on the iPAQ only due
to the sticky keyboard problem.
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 71 |
1 files changed, 25 insertions, 46 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index aa23ba7..48dd193 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -148,79 +148,81 @@ VMemo::VMemo( QWidget *parent, const char *name ) | |||
148 | 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 |
149 | lineo change string, this break | 149 | lineo change string, this break |
150 | */ | 150 | */ |
151 | if (uname(&name) != -1) | 151 | if (uname(&name) != -1) |
152 | { | 152 | { |
153 | QString release=name.release; | 153 | QString release=name.release; |
154 | qWarning("System release: %s\n", name.release); | ||
155 | if(release.find("embedix",0,TRUE) !=-1) | 154 | if(release.find("embedix",0,TRUE) !=-1) |
156 | systemZaurus=TRUE; | 155 | systemZaurus=TRUE; |
157 | else | 156 | else |
158 | { | 157 | { |
159 | systemZaurus=FALSE; | 158 | systemZaurus=FALSE; |
160 | 159 | ||
161 | // Register the REC key press. | 160 | // Register the REC key press. |
162 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); | 161 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); |
163 | e << 4096; | 162 | e << 4096; |
164 | e << QString("QPE/VMemo"); | 163 | e << QString("QPE/VMemo"); |
165 | e << QString("toggleRecord()"); | 164 | e << QString("toggleRecord()"); |
166 | } | 165 | } |
167 | } | 166 | } |
168 | qWarning("VMemo done init"); | ||
169 | } | 167 | } |
170 | 168 | ||
171 | VMemo::~VMemo() | 169 | VMemo::~VMemo() |
172 | { | 170 | { |
173 | } | 171 | } |
174 | 172 | ||
175 | void VMemo::receive( const QCString &msg, const QByteArray &data ) | 173 | void VMemo::receive( const QCString &msg, const QByteArray &data ) |
176 | { | 174 | { |
177 | QDataStream stream( data, IO_ReadOnly ); | 175 | QDataStream stream( data, IO_ReadOnly ); |
178 | qWarning("VMemo::receive: %s", (const char *)msg); | 176 | if (msg == "toggleRecord()") |
179 | if (msg == "toggleRecord()") | 177 | { |
180 | { | 178 | if (recording) |
181 | if (recording) | 179 | mouseReleaseEvent(NULL); |
182 | mouseReleaseEvent(NULL); | 180 | else |
183 | else | 181 | mousePressEvent(NULL); |
184 | mousePressEvent(NULL); | 182 | } |
185 | } | ||
186 | } | 183 | } |
187 | 184 | ||
188 | void VMemo::paintEvent( QPaintEvent* ) | 185 | void VMemo::paintEvent( QPaintEvent* ) |
189 | { | 186 | { |
190 | QPainter p(this); | 187 | QPainter p(this); |
191 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 188 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
192 | } | 189 | } |
193 | 190 | ||
194 | void VMemo::mousePressEvent( QMouseEvent * ) | 191 | void VMemo::mousePressEvent( QMouseEvent *me ) |
195 | { | 192 | { |
196 | // just to be safe | 193 | // just to be safe |
197 | if (recording) | 194 | if (recording) |
198 | { | 195 | { |
199 | recording = FALSE; | 196 | recording = FALSE; |
200 | return; | 197 | return; |
201 | } | 198 | } |
199 | |||
200 | /* | ||
201 | No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | ||
202 | mousePressEvent and mouseReleaseEvent with a NULL parameter. | ||
203 | */ | ||
204 | if (!systemZaurus && me != NULL) | ||
205 | return; | ||
202 | 206 | ||
203 | qWarning("VMemo::mousePress()"); | ||
204 | QSound::play(Resource::findSound("vmemob")); | 207 | QSound::play(Resource::findSound("vmemob")); |
205 | 208 | ||
206 | recording = TRUE; | 209 | recording = TRUE; |
207 | qWarning("VMemo::mousePress() -> Starting to record"); | ||
208 | if (openDSP() == -1) | 210 | if (openDSP() == -1) |
209 | { | 211 | { |
210 | // ### Display an error box | ||
211 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort"); | 212 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort"); |
212 | recording = FALSE; | 213 | recording = FALSE; |
213 | return; | 214 | return; |
214 | } | 215 | } |
215 | 216 | ||
216 | Config vmCfg("VMemo"); | 217 | Config vmCfg("VMemo"); |
217 | vmCfg.setGroup("Defaults"); | 218 | vmCfg.setGroup("Defaults"); |
218 | 219 | ||
219 | QDateTime dt = QDateTime::currentDateTime(); | 220 | QDateTime dt = QDateTime::currentDateTime(); |
220 | QString fileName; | 221 | QString fileName; |
222 | |||
221 | if(systemZaurus) | 223 | if(systemZaurus) |
222 | fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs | 224 | fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs |
223 | else | 225 | else |
224 | fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/"); | 226 | fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/"); |
225 | 227 | ||
226 | fileName += "vm_"; | 228 | fileName += "vm_"; |
@@ -232,14 +234,16 @@ void VMemo::mousePressEvent( QMouseEvent * ) | |||
232 | fileName.replace(QRegExp(" "),"_"); | 234 | fileName.replace(QRegExp(" "),"_"); |
233 | fileName.replace(QRegExp(":"),"."); | 235 | fileName.replace(QRegExp(":"),"."); |
234 | fileName.replace(QRegExp(","),""); | 236 | fileName.replace(QRegExp(","),""); |
235 | 237 | ||
236 | if(openWAV(fileName.latin1()) == -1) | 238 | if(openWAV(fileName.latin1()) == -1) |
237 | { | 239 | { |
238 | // ### Display an error box | 240 | QString err("Could not open the output file: "); |
239 | qWarning("VMemo::mousePress() -> WAV error"); | 241 | err += fileName; |
242 | |||
243 | QMessageBox::critical(0, "VMemo", err, "Abort"); | ||
240 | close(dsp); | 244 | close(dsp); |
241 | return; | 245 | return; |
242 | } | 246 | } |
243 | 247 | ||
244 | QArray<int> cats(1); | 248 | QArray<int> cats(1); |
245 | cats[0] = vmCfg.readNumEntry("Category", 0); | 249 | cats[0] = vmCfg.readNumEntry("Category", 0); |
@@ -255,13 +259,12 @@ void VMemo::mousePressEvent( QMouseEvent * ) | |||
255 | 259 | ||
256 | record(); | 260 | record(); |
257 | } | 261 | } |
258 | 262 | ||
259 | void VMemo::mouseReleaseEvent( QMouseEvent * ) | 263 | void VMemo::mouseReleaseEvent( QMouseEvent * ) |
260 | { | 264 | { |
261 | qWarning("VMemo::mouseRelese() -> Done recording"); | ||
262 | recording = FALSE; | 265 | recording = FALSE; |
263 | } | 266 | } |
264 | 267 | ||
265 | int VMemo::openDSP() | 268 | int VMemo::openDSP() |
266 | { | 269 | { |
267 | Config cfg("Sound"); | 270 | Config cfg("Sound"); |
@@ -317,19 +320,16 @@ int VMemo::openDSP() | |||
317 | 320 | ||
318 | return 1; | 321 | return 1; |
319 | } | 322 | } |
320 | 323 | ||
321 | int VMemo::openWAV(const char *filename) | 324 | int VMemo::openWAV(const char *filename) |
322 | { | 325 | { |
323 | qDebug("Creating %s ",filename); | ||
324 | track.setName(filename); | 326 | track.setName(filename); |
325 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) | 327 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) |
326 | { | ||
327 | qDebug("Could not open file"); | ||
328 | return -1; | 328 | return -1; |
329 | } | 329 | |
330 | wav=track.handle(); | 330 | wav=track.handle(); |
331 | 331 | ||
332 | WaveHeader wh; | 332 | WaveHeader wh; |
333 | 333 | ||
334 | wh.main_chunk = RIFF; | 334 | wh.main_chunk = RIFF; |
335 | wh.length=0; | 335 | wh.length=0; |
@@ -350,54 +350,33 @@ int VMemo::openWAV(const char *filename) | |||
350 | 350 | ||
351 | return 1; | 351 | return 1; |
352 | } | 352 | } |
353 | 353 | ||
354 | void VMemo::record(void) | 354 | void VMemo::record(void) |
355 | { | 355 | { |
356 | int length=0, result, value; //, i; | 356 | int length=0, result, value; |
357 | char sound[512]; //, leftBuffer[256], rightBuffer[256]; | 357 | char sound[512]; |
358 | |||
359 | qWarning("VMemo::record()"); | ||
360 | 358 | ||
361 | while(recording) | 359 | while(recording) |
362 | { | 360 | { |
363 | result = read(dsp, sound, 512); // 8192 | 361 | result = read(dsp, sound, 512); // 8192 |
364 | qApp->processEvents(); | 362 | qApp->processEvents(); |
365 | 363 | ||
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 | */ | ||
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); | 364 | write(wav, sound, result); |
380 | length += result; | 365 | length += result; |
381 | 366 | ||
382 | qApp->processEvents(); | 367 | qApp->processEvents(); |
383 | } | 368 | } |
384 | 369 | ||
385 | qWarning("VMemo::record() -> Done recording"); | ||
386 | qWarning("VMemo::record() -> Closing dsp"); | ||
387 | |||
388 | value = length+36; | 370 | value = length+36; |
389 | lseek(wav, 4, SEEK_SET); | 371 | lseek(wav, 4, SEEK_SET); |
390 | write(wav, &value, 4); | 372 | write(wav, &value, 4); |
391 | lseek(wav, 40, SEEK_SET); | 373 | lseek(wav, 40, SEEK_SET); |
392 | write(wav, &length, 4); | 374 | write(wav, &length, 4); |
393 | track.close(); | 375 | track.close(); |
394 | 376 | ||
395 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) | 377 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) |
396 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 378 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
397 | ::close(dsp); | 379 | ::close(dsp); |
398 | 380 | ||
399 | qWarning("VMemo::record() -> playing done recording sound"); | ||
400 | QSound::play(Resource::findSound("vmemoe")); | 381 | QSound::play(Resource::findSound("vmemoe")); |
401 | qWarning("VMemo::record() -> terminating"); | ||
402 | //QMessageBox::information(0, "VMemo", "Recording Done", 1); | ||
403 | } | 382 | } |