[comp.unix.sysv386] Switching VTs on Interactive UNIX

feng@wimsey.bc.ca (Feng Chen) (06/12/91)

On SCO UNIX, switching VTs is done with Alt-F1, Alt-F2, etc., instead
of with Alt-SysReq F1, etc.  Is it possible to duplicate the SCO
behaviour on Interactive UNIX 3.2, version 2.2? I've had a look at
keyboard(7) and <sys/kd.h>, but have only been able to shuffle the
VT-switching keys around; I haven't been able to reduce their number.

Can anyone help?  I'll summarize any responses.
-- 
Feng Chen
Voice: (604) 873-2000                feng@mtnsys.wimsey.bc.ca
Fax:   (604) 877-1121                ubc-cs!van-bc!mtnsys!feng

feng@mtnsys.wimsey.bc.ca (Feng Chen) (06/15/91)

In a previous article, I asked if Interactive UNIX could be made to
switch VTs using Alt-F1, Alt-F2, etc.

By far, the most popular solution (thanks, everyone!) was a program by
Larry Campbell.  It's quite short, so I enclose it below.  A respondent
indicated that it runs on ISC 2.0.2 as well, and I can confirm that it
runs on ISC 2.2.

I also received a program called fixkey, by Robert Lin, which remaps
Alt-F1, etc., + some other keys, for use with Crisp.  Send me email if
you'd like a copy.

-----8<----- cut here -----8<----- cut here -----8<----- cut here -----8<-----
/*
 * Article 749 of comp.unix.i386:
 * Path: aloha1!uhccux!humu!nosc!helios.ee.lbl.gov!pasteur!ucbvax!tut.cis.ohio-state.edu!ukma!nrl-cmf!think!redsox!campbell
 * From: campbell@redsox.bsw.com (Larry Campbell)
 * Newsgroups: comp.sys.att,comp.unix.i386,alt.sources
 * Subject: Re: 6386 V.3.2 virtual terminal switch remapping?
 * Summary: Here's a program to do it
 * Message-ID: <781@redsox.bsw.com>
 * Date: 18 Jun 89 04:15:02 GMT
 * References: <484@oglvee.UUCP>
 * Reply-To: campbell@redsox.UUCP (Larry Campbell)
 * Organization: The Boston Software Works, Inc.
 * Lines: 52
 * 
 * The manual entry is incomplete;  you have to scrutinize kd.h carefully.
 * I'm glad Jim's posting (Hi, Jim!) prompted me to look this up and write
 * the following program (which I call kset, but you can call Nancy if you
 * like).
 * 
 * This program lets you switch consoles with Alt-F1 through Alt-F8 (instead
 * of the irritating Alt-Sysreq F1 through Alt-Sysreq F8);  modify to taste.
 * I wrote and tested it on Interactive 386/ix v2.0.1, but I assume it will
 * also work on the AT&T SVR3.2 release.
 */

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

extern void exit();
extern void perror();

struct kbentry
    kbetab[] =
	{
	    { K_ALTTAB,	59, SPECIALKEY | (K_VTF + 1) },
	    { K_ALTTAB,	60, SPECIALKEY | (K_VTF + 2) },
	    { K_ALTTAB,	61, SPECIALKEY | (K_VTF + 3) },
	    { K_ALTTAB,	62, SPECIALKEY | (K_VTF + 4) },
	    { K_ALTTAB,	63, SPECIALKEY | (K_VTF + 5) },
	    { K_ALTTAB,	64, SPECIALKEY | (K_VTF + 6) },
	    { K_ALTTAB,	65, SPECIALKEY | (K_VTF + 7) },
	    { K_ALTTAB,	66, SPECIALKEY | (K_VTF + 0) },
	    { 0,         0,                        0 }
	};

main()
{
int i;

for (i = 0; kbetab[i].kb_index; i++)
    {
    if (ioctl(0, KDSKBENT, &kbetab[i]) == -1)
	{
	perror("kset: KDGKBENT ioctl failed");
	exit(1);
	}
    }
return 0;
}

/*
 * Larry Campbell                          The Boston Software Works, Inc.
 * campbell@bsw.com                        120 Fulton Street
 * wjh12!redsox!campbell                   Boston, MA 02146
 */
-----8<----- cut here -----8<----- cut here -----8<----- cut here -----8<-----

-- 
Feng Chen
van-bc!mtnsys!feng		 feng@mtnsys.wimsey.bc.ca

tan@bronson.uucp (Tan Bronson) (06/19/91)

In article <1991Jun12.052103.16367@wimsey.bc.ca> feng@wimsey.bc.ca (Feng Chen) writes:
>On SCO UNIX, switching VTs is done with Alt-F1, Alt-F2, etc., instead
>of with Alt-SysReq F1, etc.  Is it possible to duplicate the SCO
>behaviour on Interactive UNIX 3.2, version 2.2? I've had a look at
>keyboard(7) and <sys/kd.h>, but have only been able to shuffle the
>VT-switching keys around; I haven't been able to reduce their number.
	There is good news and bad news. The good new is that the attached
    program was provided by someone at Interactive and it seems to work.
	The bad news is that after this program is run, switching to/from
    a VT running X can wedge the keyboard, rendering it useless for X.
    Sometimes switching back and forth can fix the X server, but
    when I reported this bug to Interactive, they recommended that I
    stop using this tool and I have not had the problem since.
	I've stopped using VT's now that I run X, so this is not too much
    of a problem for me.

====== xenix_ix.c =====
#include <sys/types.h>
#include <sys/at_ansi.h>
#include <sys/kd.h>

struct kbentry table[] = {
{ K_ALTTAB, 59, SPECIALKEY | (K_VTF +1) },
{ K_ALTTAB, 60, SPECIALKEY | (K_VTF +2) },
{ K_ALTTAB, 61, SPECIALKEY | (K_VTF +3) },
{ K_ALTTAB, 62, SPECIALKEY | (K_VTF +4) },
{ K_ALTTAB, 63, SPECIALKEY | (K_VTF +5) },
{ K_ALTTAB, 64, SPECIALKEY | (K_VTF +6) },
{ K_ALTTAB, 65, SPECIALKEY | (K_VTF +7) },
{ K_ALTTAB, 66, SPECIALKEY | (K_VTF +8) },
{ K_ALTTAB, 67, SPECIALKEY | (K_VTF +9) },
{ K_ALTTAB, 68, SPECIALKEY | (K_VTF +0) },
};

main ()
{
    int i;

    for (i = 0; i < sizeof(table)/sizeof(struct kbentry); ++i)
	if (ioctl(0, KDSKBENT, &table[i]) == -1) {
	    perror("xenix_in: KDSKBENT failed");
	    exit(1);
	}
}
-- 
Tan Bronson		tan@Microvation.COM (or tan@bronson.UUCP)
Microvation Consultants 20 Sperry Road 		Madison, CT 06443
			Voice: (203)-421-5061	Fax: (203)-421-5292

martin@mwtech.UUCP (Martin Weitzel) (06/21/91)

In article <1991Jun18.221620.6574@bronson.uucp> tan@bronson.uucp (Tan Bronson) writes:
[about a program that enables VT-switching with a single keystroke]
>	The bad news is that after this program is run, switching to/from
>    a VT running X can wedge the keyboard, rendering it useless for X.
>    Sometimes switching back and forth can fix the X server, ...

I've always been able to fix the X server when this occured by switching
back and forth when the mouse-cursor is *within* an xterm-window.

Further it seems the wedged keyboard is more likely to occur when
you use the ALT-F-VT-switching and the mouse-cursor is *outside* an
xterm-window (though I've not been able to reproduce it 100%, there
seems something more to be involved).
-- 
Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83