[comp.sys.sun] defEATING CAPs-lock

dknight@elm.sdd.trw.com (David B. Knight) (05/24/90)

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...

On a similar (actually, reverse) note:  Is there any way I can prevent
X-windows from disabling my capslock whenever I run it?  Thanks

Please email responses directly to me.

Dave Knight
dknight@elm.sdd.trw.com

boyter@uunet.uu.net (Maj Brian Boyter) (05/26/90)

In article <8033@brazos.Rice.edu>, zweig@ida.org (Johnny zweig) writes:
> 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

try:
   echo "mapi F1 ^[[224z" > ~/.ttyswrc
You have to exit and re-enter sunview for the change to take effect...

   Maj. Brian A Boyter
   boyter@fstc-chville.army.mil

stant@beaver.cs.washington.edu (Stan Tazuma) (06/01/90)

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 <sys/types.h>
#include <sundev/kbd.h>
#include <sundev/kbio.h>

#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");
    }
}