Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!cmcl2!yale!husc6!panda!genrad!decvax!decwrl!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.windows.x Subject: Re: Audible Bell Message-ID: <15330@sun.uucp> Date: Thu, 19-Mar-87 15:14:18 EST Article-I.D.: sun.15330 Posted: Thu Mar 19 15:14:18 1987 Date-Received: Sat, 21-Mar-87 07:41:31 EST References: <12287439268.16.HODGES@SRI-STRIPE.ARPA> <4800@slate.Diamond.BBN.COM> Sender: news@sun.uucp Reply-To: guy@sun.UUCP (Guy Harris) Distribution: world Organization: Sun Microsystems, Mountain View Lines: 186 >You first have to create /dev/bell, which is the device XFeep() wants >to talk to. Or, alternatively, apply the following script to the X.V10R4 "libsun/util.c", which causes it to use the "ioctl"s that are documented in the manual page KB(4S), at least in 3.2: *** util.c Mon Mar 16 08:40:44 1987 --- /tmp/util.c Thu Mar 19 11:52:26 1987 *************** *** 59,118 **** #include "Xsun.h" #include extern int vsdev; - /* - * Ring the bell on a sun 120, volume between 0 (quiet) and 7 (loud). - * Need to make the /dev/bell device with - * the same major device number as tty[ab] but with a new minor number. - * - * # /etc/mknod /dev/bell c 12 2 - * - * crw-rw-rw- 1 root 12, 0 Jan 6 18:18 /dev/ttya - * crw-rw-rw- 1 root 12, 1 Feb 26 1985 /dev/ttyb - * crw-rw-rw- 1 root 12, 2 Jan 14 08:45 /dev/bell - * - */ - - - #define RING_ON 0x02 /* Control-B */ - #define RING_OFF 0x03 /* Control-C */ #define RING_WAIT 25000 /* microseconds, for volume 1 */ #ifndef NULL #define NULL 0 #endif SoundBell (volume) int volume; { - static int bell = -1; - int status; - char outbuf[1]; struct timeval ring_time; if (volume == 0) { return(0); } ! if (bell < 0) { ! bell = open("/dev/bell",2); ! if (bell < 0) { return(1); } } ring_time.tv_sec = 0; ring_time.tv_usec = RING_WAIT * volume; ! outbuf[0] = RING_ON; ! status = write(bell,outbuf,1); ! if (status < 0) { return(1); } select(0, NULL, NULL, NULL, &ring_time); ! outbuf[0] = RING_OFF; ! status = write(bell,outbuf,1); ! if (status < 0) { return(1); } return (0); --- 59,102 ---- #include "Xsun.h" #include + #include + #include + #include extern int vsdev; #define RING_WAIT 25000 /* microseconds, for volume 1 */ #ifndef NULL #define NULL 0 #endif + static int kbdfd = -1; + SoundBell (volume) int volume; { struct timeval ring_time; + static int bell = KBD_CMD_BELL; + static int nobell = KBD_CMD_NOBELL; if (volume == 0) { return(0); } ! if (kbdfd < 0) { ! kbdfd = open("/dev/kbd",2); ! if (kbdfd < 0) { return(1); } } ring_time.tv_sec = 0; ring_time.tv_usec = RING_WAIT * volume; ! if (ioctl(kbdfd, KIOCCMD, &bell) < 0) { return(1); } select(0, NULL, NULL, NULL, &ring_time); ! if (ioctl(kbdfd, KIOCCMD, &nobell) < 0) { return(1); } return (0); *************** *** 123,129 **** SetKeyClick (volume) int volume; { ! return (0); } /* Set autorepeat */ --- 107,125 ---- SetKeyClick (volume) int volume; { ! int cmd; ! ! if (kbdfd < 0) { ! kbdfd = open("/dev/kbd",2); ! if (kbdfd < 0) { ! return(1); ! } ! } ! cmd = (volume == 0) ? KBD_CMD_NOCLICK : KBD_CMD_CLICK; ! if (ioctl(kbdfd, KIOCCMD, &cmd) < 0) { ! return(1); ! } ! return (0); } /* Set autorepeat */ This also gives you the ability to change the key click. CAVEAT: I haven't tried this to see what it does on a Sun-2 keyboard. I also don't guarantee that it won't get confused. SunView doesn't change the key click; I have no idea if this is because they haven't bothered or because the keyboard can get confused. There are some comments in the keyboard driver code that imply the latter is a possibility.... FURTHER CAVEAT: I haven't dropped this into X to try it out. I just tested the "ioctl"s under SunView in stand-alone programs (although the bell "ioctl"s are what SunView uses to ring the audible bell). If it doesn't compile, the changes should be obvious. Also note that all the other caveats we stuck into "util.c" apply here as well: * The Sun X drivers are a product of Sun Microsystems, Inc. and are provided * for unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify these drivers without charge, but are not authorized * to license or distribute them to anyone else except as part of a product or * program developed by the user. * * THE SUN X DRIVERS ARE PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND * INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A * PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE * PRACTICE. * * The Sun X Drivers are provided with no support and without any obligation * on the part of Sun Microsystems, Inc. to assist in their use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THE SUN X * DRIVERS OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. The changes to other versions of "util.c" should be similar (the version from the 4.3BSD tape doesn't have SoundBell, so you just drop the new one in).