Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!rice!sun-spots-request From: bcsaic!sundry!stant@beaver.cs.washington.edu (Stan Tazuma) Newsgroups: comp.sys.sun Subject: Re: defEATING CAPs-lock Keywords: Source Message-ID: <8385@brazos.Rice.edu> Date: 1 Jun 90 00:25:11 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 87 Approved: Sun-Spots@rice.edu X-Refs: Original: v9n178, Replies: v9n182 X-Sun-Spots-Digest: Volume 9, Issue 190, message 5 In article <8033@brazos.Rice.edu> zweig@ida.org (Johnny zweig) writes: >When I run X-windows on any machine I know of, I can change the keyboard >mappings and render the evil dreaded caps-lock key harmless (it is already >known to be useless, of course). That is, make it not do anything at all >no matter how often I accidentally hit it. > >Is there a way to do this in SunView, short of twiddling the kernel? What >I would really like would be a command in my .cshrc that just nukes the >damn thing for good (if I want to type all caps for awhile, I just have my >secretary come and hold her finger on the shift-key for me), but a command >that just fusses SunView's keyboard-processing would be the next best >thing. Here's a program that can disable the caps lock key, and just as importantly, can re-enable it (some people might actually like the key and you'll want to re-enable it after you've logged out). Works on SunOS 4.0.3, and also on back to 3.2 or so (when I originally wrote the program). /* * fixcapslock - manipulate CAPS LOCK key behavior on a Sun keyboard * * Stan Tazuma - 5/20/88 * * if no arguments, the CAPS LOCK key is disabled in the unshifted mode, * requiring the use of SHIFT/CAPS or CTRL/CAPS to enter/exit * CAPS LOCK mode. * if argv[1] is "reset" or "enable", the CAPS LOCK is fully * re-enabled ("setkeys reset" also works). * if argv[1] is "disable" (or anything besides "reset" and "enable"), the * CAPS LOCK key is completely disabled. */ #include #include #include #define streq(a,b) (strcmp(a,b) == 0) main(argc, argv) int argc; char **argv; { int fd; int value; fd = open("/dev/kbd", 1); if (fd < 0) { perror("/dev/kbd"); exit(1); } value = NOP; if (argc > 1) { if (streq(argv[1], "reset") || streq(argv[1], "enable")) value = SHIFTKEYS + CAPSLOCK; } /* change it in the Unshifted map */ set_capslock_key(fd, 0, value); /* change it in the Caps Locked map */ set_capslock_key(fd, CAPSMASK, value); if (argc > 1) { /* change it in the Shifted map and Ctrl map (results in * it being changed everywhere) */ set_capslock_key(fd, SHIFTMASK, value); set_capslock_key(fd, CTRLMASK, value); } exit(0); } set_capslock_key(fd, tablemask, value) int fd; int tablemask; int value; { struct kiockey key; key.kio_tablemask = tablemask; key.kio_station = 0x77; key.kio_entry = value; if (ioctl(fd, KIOCSETKEY, &key) < 0 ) { perror("KIOCSETKEY"); } }