ISC Keyboard fix post

Robert Lin rlin at cs.ubc.ca
Tue Sep 18 07:12:43 AEST 1990


Recently I posted a message about how I wrote a program to change the
keystroke to go to virtual screens, from Alt-SysRq Fn to Alt-Fn.
I've since been flooded with requests, so it seems to be a better
idea to post.

The program is called fixkey.c, which I use to reassign the keyboard so
I can use CRISP 1.9 the way it is meant to be used under ISC. I haven't
tried this code with any other AT&T SysV386, but I think they are all
compatible at this level, and all of them should respond the same; i.e.
all should reassign the virtual terminal keys. 

Note the standard screen switch sequence is still valid. You can still
use Alt-SysRq to hop around. I sometimes forget I had the fix in place
and still use the same old long key strokes.

To use this program, run fixkey from your login script. Every new user
who logs in gets the default system key assignment. I think that's why
this program won't work for system initialization. 

NOTE: People who use VPIX may want to be careful. If their DOS application
uses Alt-Fn keys, the application will *PROBABLY MOST LIKELY (untested)*
never see the keys. One possible solution is to wire VPIX into a script
file, which runs a program to temporarily put the old values back into
the Alt-Fn key assignment, then on exit restore the keyboard back to this
way. Of course, I don't use VPIX, I don't ever plan on using VPIX, and 
the gentleman who uses VPIX that flamed me for this program, please 
redirect to /dev/null.


#include <fcntl.h>
#include <sys/types.h>
#include <sys/at_ansi.h>
#include <sys/kd.h>

keymap_t MyKeys;
char IntMap [12] = { '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3' };

main ()
{
	int i, n;
	char *cp, StrTable [512];
	
	ioctl (0, GIO_KEYMAP, &MyKeys);
	for (i = 0; i < 12; i++) { /* 2 is CTRL */
		MyKeys.key [i + 71].map [2] = i + 0x58;
	}

	/* Program Alt-F1 to /dev/console, Alt-F2 ... F8 to vt01 ... vt07 */
	/* Then program Alt-Right to NEXT and Alt-Left to PREV screen */

	for (i = 0; i < 8; i++) {
		MyKeys.key [i + 59].map [4] = i + 134;
	}

	/* If you don't use CRISP and don't need to remap these keys */
	/* the below can be safely deleted, up to PIO_KEYMAP. However */
	/* these statements are harmless. Who knows, one day you may */
	/* decide CRISP is really for you! */

	MyKeys.key [16].map [4] = 0x7D; /* Alt-Q => esc N q */
	MyKeys.key [17].map [4] = 0x7D; /* Alt-W => esc N w */
	MyKeys.key [30].map [4] = 0x7D; /* Alt-A => esc N a */
	MyKeys.key [44].map [4] = 0x7D; /* Alt-Z => esc N z */
	MyKeys.key [50].map [4] = 0x7D; /* Alt-M => esc N m */
	MyKeys.key [11].map [4] = 0x7D; /* Alt-0 => esc N 0 */

	for (i = 2; i <= 10; i++) {
		MyKeys.key [i].map [4] = 0x7D; /* Alt-1 to 9, => esc N 1-9 */
	}

	ioctl (0, PIO_KEYMAP, &MyKeys);

	/* everything after this is irrelevent for people who only want */
	/* the virtual screen keys remapped. */

	ioctl (0, GIO_STRMAP, StrTable);
	cp = StrTable + 244;	
	for (i = 0; i < 12; i++) {
		*cp++ = 0x1B;
		*cp++ = '?';
		*cp++ = IntMap [i];
		*cp++ = '\0';
	}
	*cp = '\0';	
	ioctl (0, PIO_STRMAP, StrTable);
}



More information about the Comp.unix.sysv386 mailing list