dlls/kernel/console.c: Support PC speaker time/frequency on Linux

David Lee Lambert lamber45 at cse.msu.edu
Fri May 13 20:06:56 CDT 2005


Wine always beeps the same, if it beeps at all;  this patch starts to fix 
that.  The Linux console accepts codes so it can beep the PC speaker.  Now 
it might be easier to port programs that play little ditties...

Changelog:
  A better Beep() when Wine is run from the Linux console  

-- 
David Lee Lambert (also as4109 at wayne.edu)    cell ph# 586-873-8813
PGP key at http://www.cse.msu.edu/~lamber45/newmail.htm#GPGKey
-------------- next part --------------
--- dlls/kernel/console.c.v1_39	Fri May 13 15:38:16 2005
+++ dlls/kernel/console.c	Fri May 13 21:02:19 2005
@@ -193,9 +193,19 @@
  */
 BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDur )
 {
-    static const char beep = '\a';
-    /* dwFreq and dwDur are ignored by Win95 */
-    if (isatty(2)) write( 2, &beep, 1 );
+   if (strcmp(getenv("TERM"),"linux")==0 && isatty(2)) {
+      /* the Linux console supports setting frequency and duration */
+      char szBeep[50];
+      snprintf(szBeep,50,"\x1B[10;%d]\x1B[11;%d]\a",(int)dwFreq,(int)dwDur);
+      write( 2, szBeep, strlen(szBeep) );
+      usleep(dwDur*1000);
+   } else if (isatty(2)) {
+      /* dwFreq and dwDur are ignored by Win95 */
+      static const char beep = '\a';
+      write( 2, &beep, 1 );
+   } else {
+      /* TODO: we could play a .wav file instead... */
+   }
     return TRUE;
 }
 


More information about the wine-patches mailing list