home *** CD-ROM | disk | FTP | other *** search
- From: hm@hcshh.hcs.de (Hellmuth Michaelis)
- Newsgroups: comp.sources.misc
- Subject: v41i141: pcvt - Video Driver for 386BSD/NetBSD/FreeBSD, v3.00, Part02/13
- Date: 1 Mar 1994 16:58:55 -0600
- Organization: Sterling Software
- Sender: root@news.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <2l0hbf$4v0@sparky.sterling.com>
- X-Md4-Signature: 27373af1352100af2bee350ed2456bf3
-
- Submitted-by: hm@hcshh.hcs.de (Hellmuth Michaelis)
- Posting-number: Volume 41, Issue 141
- Archive-name: pcvt/part02
- Environment: 386BSD, NETBSD, FREEBSD
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: pcvt/pcvt_kbd.c
- # Wrapped by kent@sparky on Tue Mar 1 16:46:17 1994
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 2 (of 13)."'
- if test -f 'pcvt/pcvt_kbd.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'pcvt/pcvt_kbd.c'\"
- else
- echo shar: Extracting \"'pcvt/pcvt_kbd.c'\" \(85774 characters\)
- sed "s/^X//" >'pcvt/pcvt_kbd.c' <<'END_OF_FILE'
- X/*
- X * Copyright (c) 1992,1993,1994 Hellmuth Michaelis, Brian Dunford-Shore,
- X * Joerg Wunsch and Holger Veit.
- X *
- X * All rights reserved.
- X *
- X * This code is derived from software contributed to Berkeley by
- X * William Jolitz and Don Ahn.
- X *
- X * This code is derived from software contributed to 386BSD by
- X * Holger Veit.
- X *
- X * Redistribution and use in source and binary forms, with or without
- X * modification, are permitted provided that the following conditions
- X * are met:
- X * 1. Redistributions of source code must retain the above copyright
- X * notice, this list of conditions and the following disclaimer.
- X * 2. Redistributions in binary form must reproduce the above copyright
- X * notice, this list of conditions and the following disclaimer in the
- X * documentation and/or other materials provided with the distribution.
- X * 3. All advertising materials mentioning features or use of this software
- X * must display the following acknowledgement:
- X * This product includes software developed by Hellmuth Michaelis,
- X * Brian Dunford-Shore and Joerg Wunsch.
- X * 4. The name authors may not be used to endorse or promote products
- X * derived from this software without specific prior written permission.
- X *
- X * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
- X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- X * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- X *
- X *
- X * @(#)pcvt_kbd.c, 3.00, Last Edit-Date: [Sun Feb 27 17:04:53 1994]
- X *
- X */
- X
- X/*---------------------------------------------------------------------------*
- X *
- X * pcvt_kbd.c VT220 Driver Keyboard Interface Code
- X * ----------------------------------------------------
- X * -jw include rather primitive X stuff
- X * -hm patch from Gordon L. Burditt to fix repeat of CAPS LOCK etc.
- X * -hm netbsd: no file ddb.h available
- X * -hm new keyboard routines from netbsd-current
- X * -hm re-introduced keyboard id detection
- X * -hm keyboard id debugging, hp sends special id ...
- X * -jw keyboard overlay table now malloc'ed, SCROLL_SLEEP
- X * -hm keyboard initialization for ddb activists ...
- X * -hm keyboard security no longer ignored
- X * -hm reset cursor when soft reset fkey
- X * -jw USL VT compatibility
- X * -hm CTRL-ALT-Fx switches to virtual terminal x
- X * -hm added totalscreen checking, removed bug in vt220-like kbd part
- X * -hm SCROLL_SLEEPing works
- X * -hm kbd scancode sets 1 and 2 (patch from Onno van der Linden)
- X * -hm printscreen key fix
- X * -jw mouse emulation mode
- X * -jw/hm all ifdef's converted to if's
- X * -jw cleaned up the key prefix recognition
- X * -jw included PCVT_META_ESC
- X * -hm removed typo in cfkey11() (pillhuhns have good eyes ..)
- X * -hm Debugger("kbd") patch from Joerg for FreeBSD
- X * -hm bugfix, ALT-F12 steps over screen 0
- X * -hm vgapage() -> do_vgapage(), checks if in scrolling
- X * -hm ------------ Release 3.00 --------------
- X *
- X *---------------------------------------------------------------------------*/
- X
- X#include "vt.h"
- X#if NVT > 0
- X
- X#include "pcvt_hdr.h" /* global include */
- X
- Xstatic void fkey1(void), fkey2(void), fkey3(void), fkey4(void);
- Xstatic void fkey5(void), fkey6(void), fkey7(void), fkey8(void);
- Xstatic void fkey9(void), fkey10(void), fkey11(void), fkey12(void);
- X
- Xstatic void sfkey1(void), sfkey2(void), sfkey3(void), sfkey4(void);
- Xstatic void sfkey5(void), sfkey6(void), sfkey7(void), sfkey8(void);
- Xstatic void sfkey9(void), sfkey10(void), sfkey11(void), sfkey12(void);
- X
- Xstatic void cfkey1(void), cfkey2(void), cfkey3(void), cfkey4(void);
- Xstatic void cfkey5(void), cfkey6(void), cfkey7(void), cfkey8(void);
- Xstatic void cfkey9(void), cfkey10(void), cfkey11(void), cfkey12(void);
- X
- Xstatic void doreset ( void );
- Xstatic void ovlinit ( int force );
- Xstatic void settpmrate ( int rate );
- Xstatic void setlockkeys ( int snc );
- Xstatic int kbc_8042cmd ( int val );
- Xstatic int getokeydef ( unsigned key, struct kbd_ovlkey *thisdef );
- Xstatic int getckeydef ( unsigned key, struct kbd_ovlkey *thisdef );
- Xstatic int rmkeydef ( int key );
- Xstatic int setkeydef ( struct kbd_ovlkey *data );
- Xstatic u_char * xlatkey2ascii( U_short key );
- X
- Xstatic int ledstate = 0; /* keyboard led's */
- Xstatic int tpmrate = KBD_TPD500|KBD_TPM100;
- Xstatic u_char altkpflag = 0;
- Xstatic u_short altkpval = 0;
- X
- X#if PCVT_SHOWKEYS
- Xu_char rawkeybuf[80];
- X#endif /* PCVT_SHOWKEYS */
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 12
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xdo_vgapage(int page)
- X{
- X if(critical_scroll)
- X switch_page = page;
- X else
- X vgapage(page);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * this is one sub-entry for the table. the type can be either
- X * "pointer to a string" or "pointer to a function"
- X *---------------------------------------------------------------------------*/
- Xtypedef struct
- X{
- X u_char subtype; /* subtype, string or function */
- X union what
- X {
- X u_char *string; /* ptr to string, null terminated */
- X void (*func)(); /* ptr to function */
- X } what;
- X} entry;
- X
- X/*---------------------------------------------------------------------------*
- X * this is the "outer" table
- X *---------------------------------------------------------------------------*/
- Xtypedef struct
- X{
- X u_short type; /* type of key */
- X u_short ovlindex; /* -hv- index into overload table */
- X entry unshift; /* normal default codes/funcs */
- X entry shift; /* shifted default codes/funcs */
- X entry ctrl; /* control default codes/funcs */
- X} Keycap_def;
- X
- X#define IDX0 0 /* default indexvalue into ovl table */
- X
- X#define STR KBD_SUBT_STR /* subtype = ptr to string */
- X#define FNC KBD_SUBT_FNC /* subtype = ptr to function */
- X
- X#define CODE_SIZE 5
- X
- X/*---------------------------------------------------------------------------*
- X * the overlaytable table is a static fixed size scratchpad where all the
- X * overloaded definitions are stored.
- X * an entry consists of a short (holding the new type attribute) and
- X * four entries for a new keydefinition.
- X *---------------------------------------------------------------------------*/
- X
- X#define OVLTBL_SIZE 64 /* 64 keys can be overloaded */
- X
- X#define Ovl_tbl struct kbd_ovlkey
- X
- Xstatic Ovl_tbl *ovltbl; /* the table itself */
- X
- Xstatic ovlinitflag = 0; /* the init flag for the table */
- X
- X/*
- X * key codes >= 128 denote "virtual" shift/control
- X * They are resolved before any keymapping is handled
- X */
- X
- X#if PCVT_SCANSET == 2
- Xstatic u_char scantokey[] = {
- X/* -0- -1- -2- -3- -4- -5- -6- -7- This layout is valid for US only */
- X/*00*/ 0,120, 0,116,114,112,113,123, /* ?? F9 ?? F5 F3 F1 F2 F12 */
- X/*08*/ 0,121,119,117,115, 16, 1, 0, /* ?? F10 F8 F6 F4 TAB ` ?? */
- X/*10*/ 0, 60, 44, 0, 58, 17, 2, 0, /* ?? ALl SHl ?? CTl Q 1 ?? */
- X/*18*/ 0, 0, 46, 32, 31, 18, 3, 0, /* ?? Z S A W 2 ?? ?? */
- X/*20*/ 0, 48, 47, 33, 19, 5, 4, 0, /* ?? C X D E 4 3 ?? */
- X/*28*/ 0, 61, 49, 34, 21, 20, 6, 0, /* ?? SP V F T R 5 ?? */
- X/*30*/ 0, 51, 50, 36, 35, 22, 7, 0, /* ?? N B H G Y 6 ?? */
- X/*38*/ 0, 0, 52, 37, 23, 8, 9, 0, /* ?? ?? M J U 7 8 ?? */
- X/*40*/ 0, 53, 38, 24, 25, 11, 10, 0, /* ?? , K I O 0 9 ?? */
- X/*48*/ 0, 54, 55, 39, 40, 26, 12, 0, /* ?? . / L ; P - ?? */
- X/*50*/ 0, 0, 41, 0, 27, 13, 0, 0, /* ?? ?? " ?? [ = ?? ?? */
- X/*58*/ 30, 57, 43, 28, 0, 29, 0, 0, /* CAP SHr ENT ] ?? \ ?? ?? */
- X/*60*/ 0, 45, 0, 0, 0, 0, 15, 0, /* ?? NL1 ?? ?? ?? ?? BS ?? */
- X/*68*/ 0, 93, 0, 92, 91, 0, 0, 0, /* ?? KP1 ?? KP4 KP7 ?? ?? ?? */
- X/*70*/ 99,104, 98, 97,102, 96,110, 90, /* KP0 KP. KP2 KP5 KP6 KP8 ESC NUM */
- X/*78*/ 122,106,103,105,100,101,125, 0, /* F11 KP+ KP3 KP- KP* KP9 LOC ?? */
- X/*80*/ 0, 0, 0,118,127 /* ?? ?? ?? F7 SyRQ */
- X};
- X
- Xstatic u_char extscantokey[] = {
- X/* -0- -1- -2- -3- -4- -5- -6- -7- This layout is valid for US only */
- X/*00*/ 0,120, 0,116,114,112,113,123, /* ?? F9 ?? F5 F3 F1 F2 F12 */
- X/*08*/ 0,121,119,117,115, 16, 1, 0, /* ?? F10 F8 F6 F4 TAB ` ?? */
- X/*10*/ 0, 62,128, 0, 58, 17, 2, 0, /* ?? ALr vSh ?? CTr Q 1 ?? */
- X/*18*/ 0, 0, 46, 32, 31, 18, 3, 0, /* ?? Z S A W 2 ?? ?? */
- X/*20*/ 0, 48, 47, 33, 19, 5, 4, 0, /* ?? C X D E 4 3 ?? */
- X/*28*/ 0, 61, 49, 34, 21, 20, 6, 0, /* ?? SP V F T R 5 ?? */
- X/*30*/ 0, 51, 50, 36, 35, 22, 7, 0, /* ?? N B H G Y 6 ?? */
- X/*38*/ 0, 0, 52, 37, 23, 8, 9, 0, /* ?? ?? M J U 7 8 ?? */
- X/*40*/ 0, 53, 38, 24, 25, 11, 10, 0, /* ?? , K I O 0 9 ?? */
- X/*48*/ 0, 54, 95, 39, 40, 26, 12, 0, /* ?? . KP/ L ; P - ?? */
- X/*50*/ 0, 0, 41, 0, 27, 13, 0, 0, /* ?? ?? " ?? [ = ?? ?? */
- X/*58*/ 30, 57,108, 28, 0, 29, 0, 0, /* CAP SHr KPE ] ?? \ ?? ?? */
- X/*60*/ 0, 45, 0, 0, 0, 0, 15, 0, /* ?? NL1 ?? ?? ?? ?? BS ?? */
- X/*68*/ 0, 81, 0, 79, 80, 0, 0, 0, /* ?? END ?? LA HOM ?? ?? ?? */
- X/*70*/ 75, 76, 84, 97, 89, 83,110, 90, /* INS DEL DA KP5 RA UA ESC NUM */
- X/*78*/ 122,106, 86,105,124, 85,126, 0, /* F11 KP+ PD KP- PSc PU Brk ?? */
- X/*80*/ 0, 0, 0,118,127 /* ?? ?? ?? F7 SysRq */
- X};
- X
- X#else /* PCVT_SCANSET != 2 */
- X
- Xstatic u_char scantokey[] = {
- X/* -0- -1- -2- -3- -4- -5- -6- -7- This layout is valid for US only */
- X/*00*/ 0,110, 2, 3, 4, 5, 6, 7, /* ?? ESC 1 2 3 4 5 6 */
- X/*08*/ 8, 9, 10, 11, 12, 13, 15, 16, /* 7 8 9 0 - = BS TAB */
- X/*10*/ 17, 18, 19, 20, 21, 22, 23, 24, /* Q W E R T Y U I */
- X/*18*/ 25, 26, 27, 28, 43, 58, 31, 32, /* O P [ ] ENT CTl A S */
- X/*20*/ 33, 34, 35, 36, 37, 38, 39, 40, /* D F G H J K L ; */
- X/*28*/ 41, 1, 44, 29, 46, 47, 48, 49, /* ' ` SHl \ Z X C V */
- X/*30*/ 50, 51, 52, 53, 54, 55, 57,100, /* B N M , . / SHr KP* */
- X/*38*/ 60, 61, 30,112,113,114,115,116, /* ALl SP CAP F1 F2 F3 F4 F5 */
- X/*40*/ 117,118,119,120,121, 90,125, 91, /* F6 F7 F8 F9 F10 NUM LOC KP7 */
- X/*48*/ 96,101,105, 92, 97,102,106, 93, /* KP8 KP9 KP- KP4 KP5 KP6 KP+ KP1 */
- X/*50*/ 98,103, 99,104,127, 0, 45,122, /* KP2 KP3 KP0 KP. SyRq?? NL1 F11 */
- X/*58*/ 123 /* F12 */
- X};
- X
- Xstatic u_char extscantokey[] = {
- X/* -0- -1- -2- -3- -4- -5- -6- -7- This layout is valid for US only */
- X/*00*/ 0,110, 2, 3, 4, 5, 6, 7, /* ?? ESC 1 2 3 4 5 6 */
- X/*08*/ 8, 9, 10, 11, 12, 13, 15, 16, /* 7 8 9 0 - = BS TAB */
- X/*10*/ 17, 18, 19, 20, 21, 22, 23, 24, /* Q W E R T Y U I */
- X/*18*/ 25, 26, 27, 28,108, 58, 31, 32, /* O P [ ] KPE CTr A S */
- X/*20*/ 33, 34, 35, 36, 37, 38, 39, 40, /* D F G H J K L ; */
- X/*28*/ 41, 1,128, 29, 46, 47, 48, 49, /* ' ` vSh \ Z X C V */
- X/*30*/ 50, 51, 52, 53, 54, 95, 57,124, /* B N M , . KP/ SHr KP* */
- X/*38*/ 62, 61, 30,112,113,114,115,116, /* ALr SP CAP F1 F2 F3 F4 F5 */
- X/*40*/ 117,118,119,120,121, 90,126, 80, /* F6 F7 F8 F9 F10 NUM Brk HOM */
- X/*48*/ 83, 85,105, 79, 97, 89,106, 81, /* UA PU KP- LA KP5 RA KP+ END */
- X/*50*/ 84, 86, 75, 76, 0, 0, 45,122, /* DA PD INS DEL ?? ?? NL1 F11 */
- X/*58*/ 123, /* F12 */
- X};
- X#endif /* PCVT_SCANSET == 2 */
- X
- Xstatic Keycap_def key2ascii[] =
- X{
- X
- X/* define some shorthands to make the table (almost) fit into 80 columns */
- X#define C (u_char *)
- X#define V (void *)
- X#define S STR
- X#define F FNC
- X#define I IDX0
- X
- X/* DONT EVER OVERLOAD KEY 0, THIS IS A KEY THAT MUSTN'T EXIST */
- X
- X/* type index unshift shift ctrl */
- X/* ---------------------------------------------------------- */
- X/* 0*/ KBD_NONE, I, {S,C "df"}, {S,C ""}, {S,C ""},
- X/* 1*/ KBD_ASCII, I, {S,C "`"}, {S,C "~"}, {S,C "`"},
- X/* 2*/ KBD_ASCII, I, {S,C "1"}, {S,C "!"}, {S,C "1"},
- X/* 3*/ KBD_ASCII, I, {S,C "2"}, {S,C "@"}, {S,C "\000"},
- X/* 4*/ KBD_ASCII, I, {S,C "3"}, {S,C "#"}, {S,C "3"},
- X/* 5*/ KBD_ASCII, I, {S,C "4"}, {S,C "$"}, {S,C "4"},
- X/* 6*/ KBD_ASCII, I, {S,C "5"}, {S,C "%"}, {S,C "5"},
- X/* 7*/ KBD_ASCII, I, {S,C "6"}, {S,C "^"}, {S,C "\036"},
- X/* 8*/ KBD_ASCII, I, {S,C "7"}, {S,C "&"}, {S,C "7"},
- X/* 9*/ KBD_ASCII, I, {S,C "8"}, {S,C "*"}, {S,C "9"},
- X/* 10*/ KBD_ASCII, I, {S,C "9"}, {S,C "("}, {S,C "9"},
- X/* 11*/ KBD_ASCII, I, {S,C "0"}, {S,C ")"}, {S,C "0"},
- X/* 12*/ KBD_ASCII, I, {S,C "-"}, {S,C "_"}, {S,C "\037"},
- X/* 13*/ KBD_ASCII, I, {S,C "="}, {S,C "+"}, {S,C "="},
- X/* 14*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 15*/ KBD_ASCII, I, {S,C "\177"}, {S,C "\010"}, {S,C "\177"}, /* BS */
- X/* 16*/ KBD_ASCII, I, {S,C "\t"}, {S,C "\t"}, {S,C "\t"}, /* TAB */
- X/* 17*/ KBD_ASCII, I, {S,C "q"}, {S,C "Q"}, {S,C "\021"},
- X/* 18*/ KBD_ASCII, I, {S,C "w"}, {S,C "W"}, {S,C "\027"},
- X/* 19*/ KBD_ASCII, I, {S,C "e"}, {S,C "E"}, {S,C "\005"},
- X/* 20*/ KBD_ASCII, I, {S,C "r"}, {S,C "R"}, {S,C "\022"},
- X/* 21*/ KBD_ASCII, I, {S,C "t"}, {S,C "T"}, {S,C "\024"},
- X/* 22*/ KBD_ASCII, I, {S,C "y"}, {S,C "Y"}, {S,C "\031"},
- X/* 23*/ KBD_ASCII, I, {S,C "u"}, {S,C "U"}, {S,C "\025"},
- X/* 24*/ KBD_ASCII, I, {S,C "i"}, {S,C "I"}, {S,C "\011"},
- X/* 25*/ KBD_ASCII, I, {S,C "o"}, {S,C "O"}, {S,C "\017"},
- X/* 26*/ KBD_ASCII, I, {S,C "p"}, {S,C "P"}, {S,C "\020"},
- X/* 27*/ KBD_ASCII, I, {S,C "["}, {S,C "{"}, {S,C "\033"},
- X/* 28*/ KBD_ASCII, I, {S,C "]"}, {S,C "}"}, {S,C "\035"},
- X/* 29*/ KBD_ASCII, I, {S,C "\\"}, {S,C "|"}, {S,C "\034"},
- X/* 30*/ KBD_CAPS, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 31*/ KBD_ASCII, I, {S,C "a"}, {S,C "A"}, {S,C "\001"},
- X/* 32*/ KBD_ASCII, I, {S,C "s"}, {S,C "S"}, {S,C "\023"},
- X/* 33*/ KBD_ASCII, I, {S,C "d"}, {S,C "D"}, {S,C "\004"},
- X/* 34*/ KBD_ASCII, I, {S,C "f"}, {S,C "F"}, {S,C "\006"},
- X/* 35*/ KBD_ASCII, I, {S,C "g"}, {S,C "G"}, {S,C "\007"},
- X/* 36*/ KBD_ASCII, I, {S,C "h"}, {S,C "H"}, {S,C "\010"},
- X/* 37*/ KBD_ASCII, I, {S,C "j"}, {S,C "J"}, {S,C "\n"},
- X/* 38*/ KBD_ASCII, I, {S,C "k"}, {S,C "K"}, {S,C "\013"},
- X/* 39*/ KBD_ASCII, I, {S,C "l"}, {S,C "L"}, {S,C "\014"},
- X/* 40*/ KBD_ASCII, I, {S,C ";"}, {S,C ":"}, {S,C ";"},
- X/* 41*/ KBD_ASCII, I, {S,C "'"}, {S,C "\""}, {S,C "'"},
- X/* 42*/ KBD_ASCII, I, {S,C "\\"}, {S,C "|"}, {S,C "\034"}, /* special */
- X/* 43*/ KBD_RETURN,I, {S,C "\r"}, {S,C "\r"}, {S,C "\r"}, /* RETURN */
- X/* 44*/ KBD_SHIFT, I, {S,C ""}, {S,C ""}, {S,C ""}, /* SHIFT left */
- X/* 45*/ KBD_ASCII, I, {S,C "<"}, {S,C ">"}, {S,C ""},
- X/* 46*/ KBD_ASCII, I, {S,C "z"}, {S,C "Z"}, {S,C "\032"},
- X/* 47*/ KBD_ASCII, I, {S,C "x"}, {S,C "X"}, {S,C "\030"},
- X/* 48*/ KBD_ASCII, I, {S,C "c"}, {S,C "C"}, {S,C "\003"},
- X/* 49*/ KBD_ASCII, I, {S,C "v"}, {S,C "V"}, {S,C "\026"},
- X/* 50*/ KBD_ASCII, I, {S,C "b"}, {S,C "B"}, {S,C "\002"},
- X/* 51*/ KBD_ASCII, I, {S,C "n"}, {S,C "N"}, {S,C "\016"},
- X/* 52*/ KBD_ASCII, I, {S,C "m"}, {S,C "M"}, {S,C "\r"},
- X/* 53*/ KBD_ASCII, I, {S,C ","}, {S,C "<"}, {S,C ","},
- X/* 54*/ KBD_ASCII, I, {S,C "."}, {S,C ">"}, {S,C "."},
- X/* 55*/ KBD_ASCII, I, {S,C "/"}, {S,C "?"}, {S,C "/"},
- X/* 56*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 57*/ KBD_SHIFT, I, {S,C ""}, {S,C ""}, {S,C ""}, /* SHIFT right */
- X/* 58*/ KBD_CTL, I, {S,C ""}, {S,C ""}, {S,C ""}, /* CTL left */
- X/* 59*/ KBD_ASCII, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 60*/ KBD_META, I, {S,C ""}, {S,C ""}, {S,C ""}, /* ALT left */
- X#if !PCVT_NULLCHARS
- X/* 61*/ KBD_ASCII, I, {S,C " "}, {S,C " "}, {S,C " "}, /* SPACE */
- X#else
- X/* 61*/ KBD_ASCII, I, {S,C " "}, {S,C " "}, {S,C "\000"}, /* SPACE */
- X#endif /* PCVT_NULLCHARS */
- X/* 62*/ KBD_META, I, {S,C ""}, {S,C ""}, {S,C ""}, /* ALT right */
- X/* 63*/ KBD_ASCII, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 64*/ KBD_CTL, I, {S,C ""}, {S,C ""}, {S,C ""}, /* CTL right */
- X/* 65*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 66*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 67*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 68*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 69*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 70*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 71*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 72*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 73*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 74*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 75*/ KBD_FUNC, I, {S,C "\033[2~"},{S,C "\033[2~"},{S,C "\033[2~"},/* INS */
- X/* 76*/ KBD_FUNC, I, {S,C "\033[3~"},{S,C "\033[3~"},{S,C "\033[3~"},/* DEL */
- X/* 77*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 78*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 79*/ KBD_CURSOR,I, {S,C "\033[D"},{S,C "\033OD"},{S,C "\033[D"}, /* CU <- */
- X/* 80*/ KBD_FUNC, I, {S,C "\033[1~"},{S,C "\033[1~"},{S,C "\033[1~"},/* HOME = FIND*/
- X/* 81*/ KBD_FUNC, I, {S,C "\033[4~"},{S,C "\033[4~"},{S,C "\033[4~"},/* END = SELECT */
- X/* 82*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 83*/ KBD_CURSOR,I, {S,C "\033[A"},{S,C "\033OA"},{S,C "\033[A"}, /* CU ^ */
- X/* 84*/ KBD_CURSOR,I, {S,C "\033[B"},{S,C "\033OB"},{S,C "\033[B"}, /* CU v */
- X/* 85*/ KBD_FUNC, I, {S,C "\033[5~"},{S,C "\033[5~"},{S,C "\033[5~"},/*PG UP*/
- X/* 86*/ KBD_FUNC, I, {S,C "\033[6~"},{S,C "\033[6~"},{S,C "\033[6~"},/*PG DN*/
- X/* 87*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 88*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 89*/ KBD_CURSOR,I, {S,C "\033[C"},{S,C "\033OC"},{S,C "\033[C"}, /* CU -> */
- X/* 90*/ KBD_NUM, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 91*/ KBD_KP, I, {S,C "7"}, {S,C "\033Ow"},{S,C "7"},
- X/* 92*/ KBD_KP, I, {S,C "4"}, {S,C "\033Ot"},{S,C "4"},
- X/* 93*/ KBD_KP, I, {S,C "1"}, {S,C "\033Oq"},{S,C "1"},
- X/* 94*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/* 95*/ KBD_KP, I, {S,C "/"}, {S,C "/"}, {S,C "/"},
- X/* 96*/ KBD_KP, I, {S,C "8"}, {S,C "\033Ox"},{S,C "8"},
- X/* 97*/ KBD_KP, I, {S,C "5"}, {S,C "\033Ou"},{S,C "5"},
- X/* 98*/ KBD_KP, I, {S,C "2"}, {S,C "\033Or"},{S,C "2"},
- X/* 99*/ KBD_KP, I, {S,C "0"}, {S,C "\033Op"},{S,C "0"},
- X/*100*/ KBD_KP, I, {S,C "*"}, {S,C "*"}, {S,C "*"},
- X/*101*/ KBD_KP, I, {S,C "9"}, {S,C "\033Oy"},{S,C "9"},
- X/*102*/ KBD_KP, I, {S,C "6"}, {S,C "\033Ov"},{S,C "6"},
- X/*103*/ KBD_KP, I, {S,C "3"}, {S,C "\033Os"},{S,C "3"},
- X/*104*/ KBD_KP, I, {S,C "."}, {S,C "\033On"},{S,C "."},
- X/*105*/ KBD_KP, I, {S,C "-"}, {S,C "\033Om"},{S,C "-"},
- X/*106*/ KBD_KP, I, {S,C "+"}, {S,C "+"}, {S,C "+"},
- X/*107*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/*108*/ KBD_RETURN,I, {S,C "\r"}, {S,C "\033OM"},{S,C "\r"}, /* KP ENTER */
- X/*109*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/*110*/ KBD_ASCII, I, {S,C "\033"}, {S,C "\033"}, {S,C "\033"},
- X/*111*/ KBD_NONE, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/*112*/ KBD_FUNC, I, {F,V fkey1}, {F,V sfkey1}, {F,V cfkey1}, /* F1 */
- X/*113*/ KBD_FUNC, I, {F,V fkey2}, {F,V sfkey2}, {F,V cfkey2}, /* F2 */
- X/*114*/ KBD_FUNC, I, {F,V fkey3}, {F,V sfkey3}, {F,V cfkey3}, /* F3 */
- X/*115*/ KBD_FUNC, I, {F,V fkey4}, {F,V sfkey4}, {F,V cfkey4}, /* F4 */
- X/*116*/ KBD_FUNC, I, {F,V fkey5}, {F,V sfkey5}, {F,V cfkey5}, /* F5 */
- X/*117*/ KBD_FUNC, I, {F,V fkey6}, {F,V sfkey6}, {F,V cfkey6}, /* F6 */
- X/*118*/ KBD_FUNC, I, {F,V fkey7}, {F,V sfkey7}, {F,V cfkey7}, /* F7 */
- X/*119*/ KBD_FUNC, I, {F,V fkey8}, {F,V sfkey8}, {F,V cfkey8}, /* F8 */
- X/*120*/ KBD_FUNC, I, {F,V fkey9}, {F,V sfkey9}, {F,V cfkey9}, /* F9 */
- X/*121*/ KBD_FUNC, I, {F,V fkey10}, {F,V sfkey10}, {F,V cfkey10}, /* F10 */
- X/*122*/ KBD_FUNC, I, {F,V fkey11}, {F,V sfkey11}, {F,V cfkey11}, /* F11 */
- X/*123*/ KBD_FUNC, I, {F,V fkey12}, {F,V sfkey12}, {F,V cfkey12}, /* F12 */
- X/*124*/ KBD_KP, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/*125*/ KBD_SCROLL,I, {S,C ""}, {S,C ""}, {S,C ""},
- X/*126*/ KBD_BREAK, I, {S,C ""}, {S,C ""}, {S,C ""},
- X/*127*/ KBD_FUNC, I, {S,C ""}, {S,C ""}, {S,C ""}, /* SysRq */
- X
- X#undef C
- X#undef V
- X#undef S
- X#undef F
- X#undef I
- X};
- Xstatic short keypad2num[] = {
- X 7, 4, 1, -1, -1, 8, 5, 2, 0, -1, 9, 6, 3, -1, -1, -1, -1
- X};
- X
- X#if PCVT_USL_VT_COMPAT
- X
- X#define N_KEYNUMS 128
- X
- X/*
- X * this is the reverse mapping from keynumbers to scanset 1 codes
- X * it is used to emulate the SysV-style GIO_KEYMAP ioctl cmd
- X */
- X
- Xstatic u_char key2scan1[N_KEYNUMS] = {
- X 0,0x29,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09, /* 0 */
- X 0x0a,0x0b,0x0c,0x0d, 0,0x0e,0x0f,0x10,0x11,0x12, /* 10 */
- X 0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x2b, /* 20 */
- X 0x3a,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26, /* 30 */
- X 0x27,0x28, 0,0x1c,0x2a,0x56,0x2c,0x2d,0x2e,0x2f, /* 40 */
- X 0x30,0x31,0x32,0x33,0x34,0x35,0x56,0x36,0x1d, 0, /* 50 */
- X 0x38,0x39, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 */
- X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 70 */
- X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80 */
- X 0x45,0x47,0x4b,0x4f, 0, 0,0x48,0x4c,0x50,0x52, /* 90 */
- X 0x37,0x49,0x4d,0x51,0x53,0x4a,0x4e, 0, 0, 0, /* 100 */
- X 0x01, 0,0x3b,0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42, /* 110 */
- X 0x43,0x44,0x57,0x58, 0,0x46, 0,0x54 /* 120 */
- X};
- X
- X/*
- X * SysV is brain-dead enough to stick on the IBM code page 437. So we
- X * have to translate our keymapping into IBM 437 (possibly losing keys),
- X * in order to have the X server convert it back into ISO8859.1
- X */
- X
- X/* NB: this table only contains the mapping for codes >= 128 */
- X
- Xstatic u_char iso2ibm437[] =
- X{
- X 0, 0, 0, 0, 0, 0, 0, 0,
- X 0, 0, 0, 0, 0, 0, 0, 0,
- X 0, 0, 0, 0, 0, 0, 0, 0,
- X 0, 0, 0, 0, 0, 0, 0, 0,
- X 0xff, 0xad, 0x9b, 0x9c, 0, 0x9d, 0, 0x40,
- X 0x6f, 0x63, 0x61, 0xae, 0, 0, 0, 0,
- X 0xf8, 0xf1, 0xfd, 0x33, 0, 0xe6, 0, 0xfa,
- X 0, 0x31, 0x6f, 0xaf, 0xac, 0xab, 0, 0xa8,
- X 0x41, 0x41, 0x41, 0x41, 0x8e, 0x8f, 0x92, 0x80,
- X 0x45, 0x90, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49,
- X 0x81, 0xa5, 0x4f, 0x4f, 0x4f, 0x4f, 0x99, 0x4f,
- X 0x4f, 0x55, 0x55, 0x55, 0x9a, 0x59, 0, 0xe1,
- X 0x85, 0xa0, 0x83, 0x61, 0x84, 0x86, 0x91, 0x87,
- X 0x8a, 0x82, 0x88, 0x89, 0x8d, 0xa1, 0x8c, 0x8b,
- X 0, 0xa4, 0x95, 0xa2, 0x93, 0x6f, 0x94, 0x6f,
- X 0x6f, 0x97, 0xa3, 0x96, 0x81, 0x98, 0, 0
- X};
- X
- X#endif /* PCVT_USL_VT_COMPAT */
- X
- X
- X/*---------------------------------------------------------------------------*
- X * update keyboard led's
- X *---------------------------------------------------------------------------*/
- Xvoid
- Xupdate_led(void)
- X{
- X ledstate = ((vsp->scroll_lock) |
- X (vsp->num_lock * 2) |
- X (vsp->caps_lock * 4));
- X
- X if(kbd_cmd(KEYB_C_LEDS) != 0)
- X printf("Keyboard LED command timeout\n");
- X else if(kbd_cmd(ledstate) != 0)
- X printf("Keyboard LED data timeout\n");
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * set typamatic rate
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsettpmrate(int rate)
- X{
- X tpmrate = rate & 0x7f;
- X if(kbd_cmd(KEYB_C_TYPEM) != 0)
- X printf("Keyboard TYPEMATIC command timeout\n");
- X else if(kbd_cmd(tpmrate) != 0)
- X printf("Keyboard TYPEMATIC data timeout\n");
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * Pass command to keyboard controller (8042)
- X *---------------------------------------------------------------------------*/
- Xstatic int
- Xkbc_8042cmd(int val)
- X{
- X unsigned timeo;
- X
- X timeo = 100000; /* > 100 msec */
- X while (inb(CONTROLLER_CTRL) & STATUS_INPBF)
- X if (--timeo == 0)
- X return (-1);
- X outb(CONTROLLER_CTRL, val);
- X return (0);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * Pass command to keyboard itself
- X *---------------------------------------------------------------------------*/
- Xint
- Xkbd_cmd(int val)
- X{
- X unsigned timeo;
- X
- X timeo = 100000; /* > 100 msec */
- X while (inb(CONTROLLER_CTRL) & STATUS_INPBF)
- X if (--timeo == 0)
- X return (-1);
- X outb(CONTROLLER_DATA, val);
- X return (0);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * Read response from keyboard
- X *---------------------------------------------------------------------------*/
- Xint
- Xkbd_response(void)
- X{
- X unsigned timeo;
- X
- X timeo = 500000; /* > 500 msec (KEYB_R_SELFOK requires 87) */
- X while (!(inb(CONTROLLER_CTRL) & STATUS_OUTPBF))
- X if (--timeo == 0)
- X return (-1);
- X return ((u_char) inb(CONTROLLER_DATA));
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * try to force keyboard into a known state ..
- X *---------------------------------------------------------------------------*/
- Xstatic
- Xvoid doreset(void)
- X{
- X int again = 0;
- X int response;
- X
- X /* Enable interrupts and keyboard, etc. */
- X if (kbc_8042cmd(CONTR_WRITE) != 0)
- X printf("Timeout specifying load of keyboard command byte\n");
- X
- X#if PCVT_USEKBDSEC /* security enabled */
- X
- X# if PCVT_SCANSET == 2
- X# define KBDINITCMD COMMAND_SYSFLG|COMMAND_IRQEN
- X# else /* PCVT_SCANSET != 2 */
- X# define KBDINITCMD COMMAND_PCSCAN|COMMAND_SYSFLG|COMMAND_IRQEN
- X# endif /* PCVT_SCANSET == 2 */
- X
- X#else /* ! PCVT_USEKBDSEC */ /* security disabled */
- X
- X# if PCVT_SCANSET == 2
- X# define KBDINITCMD COMMAND_INHOVR|COMMAND_SYSFLG|COMMAND_IRQEN
- X# else /* PCVT_SCANSET != 2 */
- X# define KBDINITCMD COMMAND_PCSCAN|COMMAND_INHOVR|COMMAND_SYSFLG\
- X |COMMAND_IRQEN
- X# endif /* PCVT_SCANSET == 2 */
- X
- X#endif /* PCVT_USEKBDSEC */
- X
- X if (kbd_cmd(KBDINITCMD) != 0)
- X printf("Timeout writing keyboard command byte\n");
- X
- X /*
- X * Discard any stale keyboard activity. The 0.1 boot code isn't
- X * very careful and sometimes leaves a KEYB_R_RESEND.
- X */
- X while (inb(CONTROLLER_CTRL) & STATUS_OUTPBF)
- X kbd_response();
- X
- X /* Start keyboard reset */
- X if (kbd_cmd(KEYB_C_RESET) != 0)
- X printf("Timeout for keyboard reset command\n");
- X
- X /* Wait for the first response to reset and handle retries */
- X while ((response = kbd_response()) != KEYB_R_ACK) {
- X if (response < 0) {
- X printf("Timeout for keyboard reset ack byte #1\n");
- X response = KEYB_R_RESEND;
- X }
- X if (response == KEYB_R_RESEND) {
- X if (!again) {
- X printf("KEYBOARD disconnected: RECONNECT\n");
- X again = 1;
- X }
- X if (kbd_cmd(KEYB_C_RESET) != 0)
- X printf("Timeout for keyboard reset command\n");
- X }
- X /*
- X * Other responses are harmless. They may occur for new
- X * keystrokes.
- X */
- X }
- X
- X /* Wait for the second response to reset */
- X while ((response = kbd_response()) != KEYB_R_SELFOK) {
- X if (response < 0) {
- X printf("Timeout for keyboard reset ack byte #2\n");
- X /*
- X * If KEYB_R_SELFOK never arrives, the loop will
- X * finish here unless the keyboard babbles or
- X * STATUS_OUTPBF gets stuck.
- X */
- X break;
- X }
- X }
- X
- X#if PCVT_KEYBDID
- X
- X if(kbd_cmd(KEYB_C_ID) != 0)
- X {
- X printf("Timeout for keyboard ID command\n");
- X keyboard_type = KB_UNKNOWN;
- X }
- X else
- X {
- X
- Xr_entry:
- X
- X if((response = kbd_response()) == KEYB_R_MF2ID1)
- X {
- X if((response = kbd_response()) == KEYB_R_MF2ID2)
- X {
- X keyboard_type = KB_MFII;
- X }
- X else if(response == KEYB_R_MF2ID2HP)
- X {
- X keyboard_type = KB_MFII;
- X }
- X else
- X {
- X printf("\nkbdid, response 2 = [%d]\n",
- X response);
- X keyboard_type = KB_UNKNOWN;
- X }
- X }
- X else if (response == KEYB_R_ACK)
- X {
- X goto r_entry;
- X }
- X else if (response == -1)
- X {
- X keyboard_type = KB_AT;
- X }
- X else
- X {
- X printf("\nkbdid, response 1 = [%d]\n", response);
- X }
- X }
- X
- X#else /* PCVT_KEYBDID */
- X
- X keyboard_type = KB_MFII; /* force it .. */
- X
- X#endif /* PCVT_KEYBDID */
- X
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * init keyboard code
- X *---------------------------------------------------------------------------*/
- Xvoid
- Xkbd_code_init(void)
- X{
- X doreset();
- X ovlinit(0);
- X keyboard_is_initialized = 1;
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * init keyboard code, this initializes the keyboard subsystem
- X * just "a bit" so the very very first ddb session is able to
- X * get proper keystrokes, in other words, it's a hack ....
- X *---------------------------------------------------------------------------*/
- Xvoid
- Xkbd_code_init1(void)
- X{
- X doreset();
- X keyboard_is_initialized = 1;
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * init keyboard overlay table
- X *---------------------------------------------------------------------------*/
- Xstatic
- Xvoid ovlinit(int force)
- X{
- X register i;
- X
- X if(force || ovlinitflag==0)
- X {
- X if(ovlinitflag == 0 &&
- X (ovltbl = (Ovl_tbl *)malloc(sizeof(Ovl_tbl) * OVLTBL_SIZE,
- X M_DEVBUF, M_WAITOK)) == NULL)
- X panic("pcvt_kbd: malloc of Ovl_tbl failed");
- X
- X for(i=0; i<OVLTBL_SIZE; i++)
- X {
- X ovltbl[i].keynum =
- X ovltbl[i].type = 0;
- X ovltbl[i].unshift[0] =
- X ovltbl[i].shift[0] =
- X ovltbl[i].ctrl[0] =
- X ovltbl[i].altgr[0] = 0;
- X ovltbl[i].subu =
- X ovltbl[i].subs =
- X ovltbl[i].subc =
- X ovltbl[i].suba = KBD_SUBT_STR; /* just strings .. */
- X }
- X for(i=0; i<=MAXKEYNUM; i++)
- X key2ascii[i].type &= KBD_MASK;
- X ovlinitflag = 1;
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * get original key definition
- X *---------------------------------------------------------------------------*/
- Xstatic int
- Xgetokeydef(unsigned key, Ovl_tbl *thisdef)
- X{
- X if(key == 0 || key > MAXKEYNUM)
- X return EINVAL;
- X
- X thisdef->keynum = key;
- X thisdef->type = key2ascii[key].type;
- X
- X if(key2ascii[key].unshift.subtype == STR)
- X {
- X bcopyb((u_char *)(key2ascii[key].unshift.what.string),
- X thisdef->unshift, CODE_SIZE);
- X thisdef->subu = KBD_SUBT_STR;
- X }
- X else
- X {
- X bcopyb("", thisdef->unshift, CODE_SIZE);
- X thisdef->subu = KBD_SUBT_FNC;
- X }
- X
- X if(key2ascii[key].shift.subtype == STR)
- X {
- X bcopyb((u_char *)(key2ascii[key].shift.what.string),
- X thisdef->shift, CODE_SIZE);
- X thisdef->subs = KBD_SUBT_STR;
- X }
- X else
- X {
- X bcopyb("",thisdef->shift,CODE_SIZE);
- X thisdef->subs = KBD_SUBT_FNC;
- X }
- X
- X if(key2ascii[key].ctrl.subtype == STR)
- X {
- X bcopyb((u_char *)(key2ascii[key].ctrl.what.string),
- X thisdef->ctrl, CODE_SIZE);
- X thisdef->subc = KBD_SUBT_STR;
- X }
- X else
- X {
- X bcopyb("",thisdef->ctrl,CODE_SIZE);
- X thisdef->subc = KBD_SUBT_FNC;
- X }
- X
- X /* deliver at least anything for ALTGR settings ... */
- X
- X if(key2ascii[key].unshift.subtype == STR)
- X {
- X bcopyb((u_char *)(key2ascii[key].unshift.what.string),
- X thisdef->altgr, CODE_SIZE);
- X thisdef->suba = KBD_SUBT_STR;
- X }
- X else
- X {
- X bcopyb("",thisdef->altgr, CODE_SIZE);
- X thisdef->suba = KBD_SUBT_FNC;
- X }
- X return 0;
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * get current key definition
- X *---------------------------------------------------------------------------*/
- Xstatic int
- Xgetckeydef(unsigned key, Ovl_tbl *thisdef)
- X{
- X u_short type = key2ascii[key].type;
- X
- X if(key>MAXKEYNUM)
- X return EINVAL;
- X
- X if(type & KBD_OVERLOAD)
- X *thisdef = ovltbl[key2ascii[key].ovlindex];
- X else
- X getokeydef(key,thisdef);
- X
- X return 0;
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * translate keynumber and returns ptr to associated ascii string
- X * if key is bound to a function, executes it, and ret empty ptr
- X *---------------------------------------------------------------------------*/
- Xstatic u_char *
- Xxlatkey2ascii(U_short key)
- X{
- X static u_char capchar[2] = {0, 0};
- X#if PCVT_META_ESC
- X static u_char metachar[3] = {0x1b, 0, 0};
- X#else
- X static u_char metachar[2] = {0, 0};
- X#endif
- X static Ovl_tbl thisdef;
- X int n;
- X void (*fnc)();
- X
- X if(key==0) /* ignore the NON-KEY */
- X return 0;
- X
- X getckeydef(key&0x7F, &thisdef); /* get the current ASCII value */
- X
- X thisdef.type &= KBD_MASK;
- X
- X if(key&0x80) /* special handling of ALT-KEYPAD */
- X {
- X /* is the ALT Key released? */
- X if(thisdef.type==KBD_META || thisdef.type==KBD_ALTGR)
- X {
- X if(altkpflag) /* have we been in altkp mode? */
- X {
- X capchar[0] = altkpval;
- X altkpflag = 0;
- X altkpval = 0;
- X return capchar;
- X }
- X }
- X return 0;
- X }
- X
- X switch(thisdef.type) /* convert the keys */
- X {
- X case KBD_BREAK:
- X case KBD_ASCII:
- X case KBD_FUNC:
- X fnc = NULL;
- X more_chars = NULL;
- X
- X if(altgr_down)
- X more_chars = (u_char *)thisdef.altgr;
- X
- X else if(shift_down || vsp->shift_lock)
- X {
- X if(key2ascii[key].shift.subtype == STR)
- X more_chars = (u_char *)thisdef.shift;
- X else
- X fnc = key2ascii[key].shift.what.func;
- X }
- X
- X else if(ctrl_down)
- X {
- X if(key2ascii[key].ctrl.subtype == STR)
- X more_chars = (u_char *)thisdef.ctrl;
- X else
- X fnc = key2ascii[key].ctrl.what.func;
- X }
- X
- X else
- X {
- X if(key2ascii[key].unshift.subtype == STR)
- X more_chars = (u_char *)thisdef.unshift;
- X else
- X fnc = key2ascii[key].unshift.what.func;
- X }
- X
- X if(fnc)
- X (*fnc)(); /* execute function */
- X
- X if((more_chars != NULL) && (more_chars[1] == 0))
- X {
- X if(vsp->caps_lock && more_chars[0] >= 'a'
- X && more_chars[0] <= 'z')
- X {
- X capchar[0] = *more_chars - ('a'-'A');
- X more_chars = capchar;
- X }
- X if(meta_down)
- X {
- X#if PCVT_META_ESC
- X metachar[1] = *more_chars;
- X#else
- X metachar[0] = *more_chars | 0x80;
- X#endif
- X more_chars = metachar;
- X }
- X }
- X return(more_chars);
- X
- X case KBD_KP:
- X fnc = NULL;
- X more_chars = NULL;
- X
- X if(meta_down)
- X {
- X switch(key)
- X {
- X case 95: /* / */
- X altkpflag = 0;
- X more_chars =
- X (u_char *)"\033OQ";
- X return(more_chars);
- X
- X case 100: /* * */
- X altkpflag = 0;
- X more_chars =
- X (u_char *)"\033OR";
- X return(more_chars);
- X
- X case 105: /* - */
- X altkpflag = 0;
- X more_chars =
- X (u_char *)"\033OS";
- X return(more_chars);
- X }
- X }
- X
- X if(meta_down || altgr_down)
- X {
- X if((n = keypad2num[key-91]) >= 0)
- X {
- X if(!altkpflag)
- X {
- X /* start ALT-KP mode */
- X altkpflag = 1;
- X altkpval = 0;
- X }
- X altkpval *= 10;
- X altkpval += n;
- X }
- X else
- X altkpflag = 0;
- X return 0;
- X }
- X
- X if(!(vsp->num_lock))
- X {
- X if(key2ascii[key].shift.subtype == STR)
- X more_chars = (u_char *)thisdef.shift;
- X else
- X fnc = key2ascii[key].shift.what.func;
- X }
- X else
- X {
- X if(key2ascii[key].unshift.subtype == STR)
- X more_chars = (u_char *)thisdef.unshift;
- X else
- X fnc = key2ascii[key].unshift.what.func;
- X }
- X
- X if(fnc)
- X (*fnc)(); /* execute function */
- X return(more_chars);
- X
- X case KBD_CURSOR:
- X fnc = NULL;
- X more_chars = NULL;
- X
- X if(vsp->ckm)
- X {
- X if(key2ascii[key].shift.subtype == STR)
- X more_chars = (u_char *)thisdef.shift;
- X else
- X fnc = key2ascii[key].shift.what.func;
- X }
- X else
- X {
- X if(key2ascii[key].unshift.subtype == STR)
- X more_chars = (u_char *)thisdef.unshift;
- X else
- X fnc = key2ascii[key].unshift.what.func;
- X }
- X
- X if(fnc)
- X (*fnc)(); /* execute function */
- X return(more_chars);
- X
- X case KBD_NUM: /* special kp-num handling */
- X more_chars = NULL;
- X
- X if(meta_down)
- X {
- X more_chars = (u_char *)"\033OP"; /* PF1 */
- X }
- X else
- X {
- X vsp->num_lock ^= 1;
- X update_led();
- X }
- X return(more_chars);
- X
- X case KBD_RETURN:
- X more_chars = NULL;
- X
- X if(!(vsp->num_lock))
- X {
- X more_chars = (u_char *)thisdef.shift;
- X }
- X else
- X {
- X more_chars = (u_char *)thisdef.unshift;
- X }
- X if(vsp->lnm && (*more_chars == '\r'))
- X {
- X more_chars = (u_char *)"\r\n"; /* CR LF */
- X }
- X return(more_chars);
- X
- X case KBD_META: /* these keys are */
- X case KBD_ALTGR: /* handled directly */
- X case KBD_SCROLL: /* by the keyboard */
- X case KBD_CAPS: /* handler - they are */
- X case KBD_SHFTLOCK: /* ignored here */
- X case KBD_CTL:
- X case KBD_NONE:
- X default:
- X return 0;
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * get keystrokes from the keyboard.
- X * if noblock = 0, wait until a key is pressed.
- X * else return NULL if no characters present.
- X *---------------------------------------------------------------------------*/
- Xu_char *
- Xsgetc(int noblock)
- X{
- X u_char *cp;
- X u_char dt;
- X u_char key;
- X u_short type;
- X
- X static u_char kbd_lastkey = 0; /* last keystroke */
- X static struct
- X {
- X u_char extended: 1; /* extended prefix seen */
- X u_char ext1: 1; /* extended prefix 1 seen */
- X u_char breakseen: 1; /* break code seen */
- X u_char vshift: 1; /* virtual shift pending */
- X u_char vcontrol: 1; /* virtual control pending */
- X u_char sysrq: 1; /* sysrq pressed */
- X } kbd_status = {0};
- X
- X#ifdef XSERVER
- X static char keybuf[2] = {0}; /* the second 0 is a delimiter! */
- X#endif /* XSERVER */
- X
- Xloop:
- X /* see if there is something from the keyboard in the input buffer */
- X
- X#ifdef XSERVER
- X if (inb(CONTROLLER_CTRL) & STATUS_OUTPBF)
- X {
- X dt = inb(CONTROLLER_DATA); /* yes, get it ! */
- X
- X /*
- X * If x mode is active, only care for locking keys, then
- X * return the scan code instead of any key translation.
- X * Additionally, this prevents us from any attempts to
- X * execute pcvt internal functions caused by keys (such
- X * as screen flipping).
- X * XXX For now, only the default locking key definitions
- X * are recognized (i.e. if you have overloaded you "A" key
- X * as NUMLOCK, that wont effect X mode:-)
- X * Changing this would be nice, but would require modifi-
- X * cations to the X server. After having this, X will
- X * deal with the LEDs itself, so we are committed.
- X */
- X /*
- X * Iff PCVT_USL_VT_COMPAT is defined, the behaviour has
- X * been fixed. We need not care about any keys here, since
- X * there are ioctls that deal with the lock key / LED stuff.
- X */
- X if (pcvt_kbd_raw)
- X {
- X keybuf[0] = dt;
- X#if !PCVT_USL_VT_COMPAT
- X if ((dt & 0x80) == 0)
- X /* key make */
- X switch(dt)
- X {
- X case 0x45:
- X /* XXX on which virt screen? */ vsp->num_lock ^= 1;
- X update_led();
- X break;
- X
- X case 0x3a:
- X vsp->caps_lock ^= 1;
- X update_led();
- X break;
- X
- X case 0x46:
- X vsp->scroll_lock ^= 1;
- X update_led();
- X break;
- X }
- X#endif /* !PCVT_USL_VT_COMPAT */
- X
- X#if PCVT_EMU_MOUSE
- X /*
- X * The (mouse systems) mouse emulator. The mouse
- X * device allocates the first device node that is
- X * not used by a virtual terminal. (E.g., you have
- X * eight vtys, /dev/ttyv0 thru /dev/ttyv7, so the
- X * mouse emulator were /dev/ttyv8.)
- X * Currently the emulator only works if the keyboard
- X * is in raw (PC scan code) mode. This is the typic-
- X * al case when running the X server.
- X * It is activated if the num locks LED is active
- X * for the current vty, and if the mouse device
- X * has been opened by at least one process. It
- X * grabs the numerical keypad events (but only
- X * the "non-extended", so the separate arrow keys
- X * continue to work), and three keys for the "mouse
- X * buttons", preferrably F1 thru F3. Any of the
- X * eight directions (N, NE, E, SE, S, SW, W, NW)
- X * is supported, and frequent key presses (less
- X * than e.g. half a second between key presses)
- X * cause the emulator to accelerate the pointer
- X * movement by 6, while single presses result in
- X * single moves, so each point can be reached.
- X */
- X /*
- X * NB: the following code is spagghetti.
- X * Only eat it with lotta tomato ketchup and
- X * Parmesan cheese:-)
- X */
- X /*
- X * look whether we will have to steal the keys
- X * and cook them into mouse events
- X */
- X if(vsp->num_lock && mouse.opened)
- X {
- X int button, accel, i;
- X enum mouse_dir
- X {
- X MOUSE_NW, MOUSE_N, MOUSE_NE,
- X MOUSE_W, MOUSE_0, MOUSE_E,
- X MOUSE_SW, MOUSE_S, MOUSE_SE
- X }
- X move;
- X struct timeval now;
- X /* from sys/kern/kern_time.c */
- X extern void timevalsub
- X (struct timeval *, struct timeval *);
- X dev_t dummy = makedev(0, mouse.minor);
- X struct tty *mousetty = get_pccons(dummy);
- X /*
- X * strings to send for each mouse event,
- X * indexed by the movement direction and
- X * the "accelerator" value (TRUE for frequent
- X * key presses); note that the first byte
- X * of each string is actually overwritten
- X * by the current button value before sending
- X * the string
- X */
- X static u_char mousestrings[2][MOUSE_SE+1][5] =
- X {
- X {
- X /* first, the non-accelerated strings*/
- X {0x87, -1, 1, 0, 0}, /* NW */
- X {0x87, 0, 1, 0, 0}, /* N */
- X {0x87, 1, 1, 0, 0}, /* NE */
- X {0x87, -1, 0, 0, 0}, /* W */
- X {0x87, 0, 0, 0, 0}, /* 0 */
- X {0x87, 1, 0, 0, 0}, /* E */
- X {0x87, -1, -1, 0, 0}, /* SW */
- X {0x87, 0, -1, 0, 0}, /* S */
- X {0x87, 1, -1, 0, 0} /* SE */
- X },
- X {
- X /* now, 6 steps at once */
- X {0x87, -4, 4, 0, 0}, /* NW */
- X {0x87, 0, 6, 0, 0}, /* N */
- X {0x87, 4, 4, 0, 0}, /* NE */
- X {0x87, -6, 0, 0, 0}, /* W */
- X {0x87, 0, 0, 0, 0}, /* 0 */
- X {0x87, 6, 0, 0, 0}, /* E */
- X {0x87, -4, -4, 0, 0}, /* SW */
- X {0x87, 0, -6, 0, 0}, /* S */
- X {0x87, 4, -4, 0, 0} /* SE */
- X }
- X };
- X
- X if(dt == 0xe0)
- X {
- X /* ignore extended scan codes */
- X mouse.extendedseen = 1;
- X goto no_mouse_event;
- X }
- X if(mouse.extendedseen)
- X {
- X mouse.extendedseen = 0;
- X goto no_mouse_event;
- X }
- X mouse.extendedseen = 0;
- X
- X /*
- X * Note that we cannot use a switch here
- X * since we want to have the keycodes in
- X * a variable
- X */
- X if((dt & 0x7f) == mousedef.leftbutton) {
- X button = 4;
- X goto do_button;
- X }
- X else if((dt & 0x7f) == mousedef.middlebutton) {
- X button = 2;
- X goto do_button;
- X }
- X else if((dt & 0x7f) == mousedef.rightbutton) {
- X button = 1;
- X do_button:
- X
- X /*
- X * i would really like to give
- X * some acustical support
- X * (pling/plong); i am not sure
- X * whether it is safe to call
- X * sysbeep from within an intr
- X * service, since it calls
- X * timeout in turn which mani-
- X * pulates the spl mask - jw
- X */
- X
- X# define PLING sysbeep(PCVT_SYSBEEPF / 1500, 2)
- X# define PLONG sysbeep(PCVT_SYSBEEPF / 1200, 2)
- X
- X if(mousedef.stickybuttons)
- X {
- X if(dt & 0x80) {
- X mouse.breakseen = 1;
- X return (u_char *)0;
- X }
- X else if(mouse.buttons == button
- X && !mouse.breakseen) {
- X /* ignore repeats */
- X return (u_char *)0;
- X }
- X else
- X mouse.breakseen = 0;
- X if(mouse.buttons == button) {
- X /* release it */
- X mouse.buttons = 0;
- X PLONG;
- X } else {
- X /*
- X * eventually, release
- X * any other button,
- X * and stick this one
- X */
- X mouse.buttons = button;
- X PLING;
- X }
- X }
- X else
- X {
- X if(dt & 0x80) {
- X mouse.buttons &=
- X ~button;
- X PLONG;
- X }
- X else if((mouse.buttons
- X & button) == 0) {
- X mouse.buttons |=
- X button;
- X PLING;
- X }
- X /*else: ignore same btn press*/
- X }
- X move = MOUSE_0;
- X accel = 0;
- X }
- X# undef PLING
- X# undef PLONG
- X else switch(dt & 0x7f)
- X {
- X /* the arrow keys - KP 1 thru KP 9 */
- X case 0x47: move = MOUSE_NW; goto do_move;
- X case 0x48: move = MOUSE_N; goto do_move;
- X case 0x49: move = MOUSE_NE; goto do_move;
- X case 0x4b: move = MOUSE_W; goto do_move;
- X case 0x4c: move = MOUSE_0; goto do_move;
- X case 0x4d: move = MOUSE_E; goto do_move;
- X case 0x4f: move = MOUSE_SW; goto do_move;
- X case 0x50: move = MOUSE_S; goto do_move;
- X case 0x51: move = MOUSE_SE;
- X do_move:
- X if(dt & 0x80)
- X /*
- X * arrow key break events are
- X * of no importance for us
- X */
- X return (u_char *)0;
- X /*
- X * see whether the last move did
- X * happen "recently", i.e. before
- X * less than half a second
- X */
- X now = time;
- X timevalsub(&now, &mouse.lastmove);
- X mouse.lastmove = time;
- X accel = (now.tv_sec == 0
- X && now.tv_usec
- X < mousedef.acceltime);
- X break;
- X
- X default: /* not a mouse-emulating key */
- X goto no_mouse_event;
- X }
- X mousestrings[accel][move][0] =
- X 0x80 + (~mouse.buttons & 7);
- X /* finally, send the string */
- X for(i = 0; i < 5; i++)
- X (*linesw[mousetty->t_line].l_rint)
- X (mousestrings[accel][move][i],
- X mousetty);
- X return (u_char *)0; /* not a kbd event */
- X }
- Xno_mouse_event:
- X
- X#endif /* PCVT_EMU_MOUSE */
- X
- X return ((u_char *)keybuf);
- X }
- X }
- X
- X#else /* !XSERVER */
- X
- X if(inb(CONTROLLER_CTRL) & STATUS_OUTPBF)
- X dt = inb(CONTROLLER_DATA); /* yes, get it ! */
- X
- X#endif /* !XSERVER */
- X
- X else
- X {
- X if(noblock)
- X return NULL;
- X else
- X goto loop;
- X }
- X
- X#if PCVT_SHOWKEYS
- X {
- X int rki;
- X
- X
- X for(rki = 3; rki < 80; rki++) /* shift left buffer */
- X rawkeybuf[rki-3] = rawkeybuf[rki];
- X
- X rawkeybuf[77] = ' '; /* delimiter */
- X
- X rki = (dt & 0xf0) >> 4; /* ms nibble */
- X
- X if(rki <= 9)
- X rki = rki + '0';
- X else
- X rki = rki - 10 + 'A';
- X
- X rawkeybuf[78] = rki;
- X
- X rki = dt & 0x0f; /* ls nibble */
- X
- X if(rki <= 9)
- X rki = rki + '0';
- X else
- X rki = rki - 10 + 'A';
- X
- X rawkeybuf[79] = rki;
- X }
- X#endif /* PCVT_SHOWKEYS */
- X
- X /* lets look what we got */
- X switch(dt)
- X {
- X case KEYB_R_OVERRUN0: /* keyboard buffer overflow */
- X
- X#if PCVT_SCANSET == 2
- X case KEYB_R_SELFOK: /* keyboard selftest ok */
- X#endif /* PCVT_SCANSET == 2 */
- X
- X case KEYB_R_ECHO: /* keyboard response to KEYB_C_ECHO */
- X case KEYB_R_ACK: /* acknowledge after command has rx'd*/
- X case KEYB_R_SELFBAD: /* keyboard selftest FAILED */
- X case KEYB_R_DIAGBAD: /* keyboard self diagnostic failure */
- X case KEYB_R_RESEND: /* keyboard wants us to resend cmnd */
- X case KEYB_R_OVERRUN1: /* keyboard buffer overflow */
- X break;
- X
- X case KEYB_R_EXT1: /* keyboard extended scancode pfx 2 */
- X kbd_status.ext1 = 1;
- X /* FALLTHROUGH */
- X case KEYB_R_EXT0: /* keyboard extended scancode pfx 1 */
- X kbd_status.extended = 1;
- X break;
- X
- X#if PCVT_SCANSET == 2
- X case KEYB_R_BREAKPFX: /* break code prefix for set 2 and 3 */
- X kbd_status.breakseen = 1;
- X break;
- X#endif /* PCVT_SCANSET == 2 */
- X
- X default:
- X goto regular; /* regular key */
- X }
- X
- X if(noblock)
- X return NULL;
- X else
- X goto loop;
- X
- X /* got a normal scan key */
- Xregular:
- X
- X#if PCVT_SCANSET == 1
- X kbd_status.breakseen = dt & 0x80 ? 1 : 0;
- X dt &= 0x7f;
- X#endif /* PCVT_SCANSET == 1 */
- X
- X /* make a keycode from scan code */
- X if(dt >= sizeof scantokey / sizeof(u_char))
- X key = 0;
- X else
- X key = kbd_status.extended ? extscantokey[dt] : scantokey[dt];
- X if(kbd_status.ext1 && key == 58)
- X /* virtual control key */
- X key = 129;
- X kbd_status.extended = kbd_status.ext1 = 0;
- X
- X#if PCVT_CTRL_ALT_DEL /* Check for cntl-alt-del */
- X if((key == 76) && ctrl_down && (meta_down||altgr_down))
- X cpu_reset();
- X#endif /* PCVT_CTRL_ALT_DEL */
- X
- X#if !PCVT_NETBSD
- X#include "ddb.h"
- X#endif /* !PCVT_NETBSD */
- X
- X#if NDDB > 0 || defined(DDB) /* Check for cntl-alt-esc */
- X
- X if((key == 110) && ctrl_down && (meta_down || altgr_down))
- X {
- X static u_char in_Debugger;
- X
- X if(!in_Debugger)
- X {
- X in_Debugger = 1;
- X#if PCVT_FREEBSD
- X /* the string is actually not used... */
- X Debugger("kbd");
- X#else
- X Debugger();
- X#endif
- X in_Debugger = 0;
- X if(noblock)
- X return NULL;
- X else
- X goto loop;
- X }
- X }
- X#endif /* NDDB > 0 || defined(DDB) */
- X
- X /* look for keys with special handling */
- X if(key == 128)
- X {
- X /*
- X * virtual shift; sent around PrtScr, and around the arrow
- X * keys if the NumLck LED is on
- X */
- X kbd_status.vshift = !kbd_status.breakseen;
- X key = 0; /* no key */
- X }
- X else if(key == 129)
- X {
- X /*
- X * virtual control - the most ugly thingie at all
- X * the Pause key sends:
- X * <virtual control make> <numlock make> <virtual control
- X * break> <numlock break>
- X */
- X if(!kbd_status.breakseen)
- X kbd_status.vcontrol = 1;
- X /* else: let the numlock hook clear this */
- X key = 0; /* no key */
- X }
- X else if(key == 90)
- X {
- X /* NumLock, look whether this is rather a Pause */
- X if(kbd_status.vcontrol)
- X key = 126;
- X /*
- X * if this is the final break code of a Pause key,
- X * clear the virtual control status, too
- X */
- X if(kbd_status.vcontrol && kbd_status.breakseen)
- X kbd_status.vcontrol = 0;
- X }
- X else if(key == 127)
- X {
- X /*
- X * a SysRq; some keyboards are brain-dead enough to
- X * repeat the SysRq key make code by sending PrtScr
- X * make codes; other keyboards do not repeat SysRq
- X * at all. We keep track of the SysRq state here.
- X */
- X kbd_status.sysrq = !kbd_status.breakseen;
- X }
- X else if(key == 124)
- X {
- X /*
- X * PrtScr; look whether this is really PrtScr or rather
- X * a silly repeat of a SysRq key
- X */
- X if(kbd_status.sysrq)
- X /* ignore the garbage */
- X key = 0;
- X }
- X
- X /* in NOREPEAT MODE ignore the key if it was the same as before */
- X
- X if(!kbrepflag && key == kbd_lastkey && !kbd_status.breakseen)
- X {
- X if(noblock)
- X return NULL;
- X else
- X goto loop;
- X }
- X
- X type = key2ascii[key].type;
- X
- X if(type & KBD_OVERLOAD)
- X type = ovltbl[key2ascii[key].ovlindex].type;
- X
- X type &= KBD_MASK;
- X
- X switch(type)
- X {
- X case KBD_SHFTLOCK:
- X if(!kbd_status.breakseen && key != kbd_lastkey)
- X {
- X vsp->shift_lock ^= 1;
- X }
- X break;
- X
- X case KBD_CAPS:
- X if(!kbd_status.breakseen && key != kbd_lastkey)
- X {
- X vsp->caps_lock ^= 1;
- X update_led();
- X }
- X break;
- X
- X case KBD_SCROLL:
- X if(!kbd_status.breakseen && key != kbd_lastkey)
- X {
- X vsp->scroll_lock ^= 1;
- X update_led();
- X
- X if(!(vsp->scroll_lock))
- X {
- X /* someone may be sleeping */
- X wakeup((caddr_t)&(vsp->scroll_lock));
- X }
- X }
- X break;
- X
- X case KBD_SHIFT:
- X shift_down = kbd_status.breakseen ? 0 : 1;
- X break;
- X
- X case KBD_META:
- X meta_down = kbd_status.breakseen ? 0 : 0x80;
- X break;
- X
- X case KBD_ALTGR:
- X altgr_down = kbd_status.breakseen ? 0 : 1;
- X break;
- X
- X case KBD_CTL:
- X ctrl_down = kbd_status.breakseen ? 0 : 1;
- X break;
- X
- X case KBD_NONE:
- X default:
- X break; /* deliver a key */
- X }
- X
- X if(kbd_status.breakseen)
- X {
- X key |= 0x80;
- X kbd_status.breakseen = 0;
- X kbd_lastkey = 0; /* -hv- I know this is a bug with */
- X } /* N-Key-Rollover, but I ignore that */
- X else /* because avoidance is too complicated */
- X kbd_lastkey = key;
- X
- X cp = xlatkey2ascii(key); /* have a key */
- X if(cp == NULL && !noblock)
- X goto loop;
- X return cp;
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * reflect status of locking keys & set led's
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsetlockkeys(int snc)
- X{
- X vsp->scroll_lock = snc & 1;
- X vsp->num_lock = (snc & 2) ? 1 : 0;
- X vsp->caps_lock = (snc & 4) ? 1 : 0;
- X update_led();
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * remove a key definition
- X *---------------------------------------------------------------------------*/
- Xstatic int
- Xrmkeydef(int key)
- X{
- X register Ovl_tbl *ref;
- X
- X if(key==0 || key > MAXKEYNUM)
- X return EINVAL;
- X
- X if(key2ascii[key].type & KBD_OVERLOAD)
- X {
- X ref = &ovltbl[key2ascii[key].ovlindex];
- X ref->keynum = 0;
- X ref->type = 0;
- X ref->unshift[0] =
- X ref->shift[0] =
- X ref->ctrl[0] =
- X ref->altgr[0] = 0;
- X key2ascii[key].type &= KBD_MASK;
- X }
- X return 0;
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * overlay a key
- X *---------------------------------------------------------------------------*/
- Xstatic int
- Xsetkeydef(Ovl_tbl *data)
- X{
- X register i;
- X
- X if( data->keynum > MAXKEYNUM ||
- X (data->type & KBD_MASK) == KBD_BREAK ||
- X (data->type & KBD_MASK) > KBD_SHFTLOCK)
- X return EINVAL;
- X
- X data->unshift[KBDMAXOVLKEYSIZE] =
- X data->shift[KBDMAXOVLKEYSIZE] =
- X data->ctrl[KBDMAXOVLKEYSIZE] =
- X data->altgr[KBDMAXOVLKEYSIZE] = 0;
- X
- X data->subu =
- X data->subs =
- X data->subc =
- X data->suba = KBD_SUBT_STR; /* just strings .. */
- X
- X data->type |= KBD_OVERLOAD; /* mark overloaded */
- X
- X /* if key already overloaded, use that slot else find free slot */
- X
- X if(key2ascii[data->keynum].type & KBD_OVERLOAD)
- X {
- X i = key2ascii[data->keynum].ovlindex;
- X }
- X else
- X {
- X for(i=0; i<OVLTBL_SIZE; i++)
- X if(ovltbl[i].keynum==0)
- X break;
- X
- X if(i==OVLTBL_SIZE)
- X return ENOSPC; /* no space, abuse of ENOSPC(!) */
- X }
- X
- X ovltbl[i] = *data; /* copy new data string */
- X
- X key2ascii[data->keynum].type |= KBD_OVERLOAD; /* mark key */
- X key2ascii[data->keynum].ovlindex = i;
- X
- X return 0;
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * keyboard ioctl's entry
- X *---------------------------------------------------------------------------*/
- Xint
- Xkbdioctl(Dev_t dev, int cmd, caddr_t data, int flag)
- X{
- X int key;
- X
- X switch(cmd)
- X {
- X case KBDRESET:
- X doreset();
- X ovlinit(1);
- X settpmrate(KBD_TPD500|KBD_TPM100);
- X setlockkeys(0);
- X break;
- X
- X case KBDGTPMAT:
- X *(int *)data = tpmrate;
- X break;
- X
- X case KBDSTPMAT:
- X settpmrate(*(int *)data);
- X break;
- X
- X case KBDGREPSW:
- X *(int *)data = kbrepflag;
- X break;
- X
- X case KBDSREPSW:
- X kbrepflag = (*(int *)data) & 1;
- X break;
- X
- X case KBDGLEDS:
- X *(int *)data = ledstate;
- X break;
- X
- X case KBDSLEDS:
- X update_led(); /* ??? */
- X break;
- X
- X case KBDGLOCK:
- X *(int *)data = ( (vsp->scroll_lock) |
- X (vsp->num_lock * 2) |
- X (vsp->caps_lock * 4));
- X break;
- X
- X case KBDSLOCK:
- X setlockkeys(*(int *)data);
- X break;
- X
- X case KBDGCKEY:
- X key = ((Ovl_tbl *)data)->keynum;
- X return getckeydef(key,(Ovl_tbl *)data);
- X
- X case KBDSCKEY:
- X key = ((Ovl_tbl *)data)->keynum;
- X return setkeydef((Ovl_tbl *)data);
- X
- X case KBDGOKEY:
- X key = ((Ovl_tbl *)data)->keynum;
- X return getokeydef(key,(Ovl_tbl *)data);
- X
- X case KBDRMKEY:
- X key = *(int *)data;
- X return rmkeydef(key);
- X
- X case KBDDEFAULT:
- X ovlinit(1);
- X break;
- X
- X default:
- X /* proceed with vga ioctls */
- X return -1;
- X }
- X return 0;
- X}
- X
- X#if PCVT_EMU_MOUSE
- X/*--------------------------------------------------------------------------*
- X * mouse emulator ioctl
- X *--------------------------------------------------------------------------*/
- Xint
- Xmouse_ioctl(Dev_t dev, int cmd, caddr_t data)
- X{
- X struct mousedefs *def = (struct mousedefs *)data;
- X
- X switch(cmd)
- X {
- X case KBDMOUSEGET:
- X *def = mousedef;
- X break;
- X
- X case KBDMOUSESET:
- X mousedef = *def;
- X break;
- X
- X default:
- X return -1;
- X }
- X return 0;
- X}
- X#endif /* PCVT_EMU_MOUSE */
- X
- X#if PCVT_USL_VT_COMPAT
- X/*---------------------------------------------------------------------------*
- X * convert ISO-8859 style keycode into IBM 437
- X *---------------------------------------------------------------------------*/
- Xstatic inline u_char
- Xiso2ibm(u_char c)
- X{
- X if(c < 0x80)
- X return c;
- X return iso2ibm437[c - 0x80];
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * build up a USL style keyboard map
- X *---------------------------------------------------------------------------*/
- Xvoid
- Xget_usl_keymap(keymap_t *map)
- X{
- X int i;
- X
- X bzero((caddr_t)map, sizeof(keymap_t));
- X
- X map->n_keys = 0x59; /* that many keys we know about */
- X
- X for(i = 1; i < N_KEYNUMS; i++)
- X {
- X Ovl_tbl kdef;
- X u_char c;
- X int j;
- X int idx = key2scan1[i];
- X
- X if(idx == 0 || idx >= map->n_keys)
- X continue;
- X
- X getckeydef(i, &kdef);
- X kdef.type &= KBD_MASK;
- X switch(kdef.type)
- X {
- X case KBD_ASCII:
- X case KBD_RETURN:
- X map->key[idx].map[0] = iso2ibm(kdef.unshift[0]);
- X map->key[idx].map[1] = iso2ibm(kdef.shift[0]);
- X map->key[idx].map[2] = map->key[idx].map[3] =
- X iso2ibm(kdef.ctrl[0]);
- X map->key[idx].map[4] = map->key[idx].map[5] =
- X iso2ibm(c = kdef.altgr[0]);
- X /*
- X * XXX this is a hack
- X * since we currently do not map strings to AltGr +
- X * shift, we attempt to use the unshifted AltGr
- X * definition here and try to toggle the case
- X * this should at least work for ISO8859 letters,
- X * but also for (e.g.) russian KOI-8 style
- X */
- X if((c & 0x7f) >= 0x40)
- X map->key[idx].map[5] = iso2ibm(c ^ 0x20);
- X break;
- X
- X case KBD_FUNC:
- X /* we are only interested in F1 thru F12 here */
- X if(i >= 112 && i <= 123) {
- X map->key[idx].map[0] = i - 112 + 27;
- X map->key[idx].spcl = 0x80;
- X }
- X break;
- X
- X case KBD_SHIFT:
- X c = i == 44? 2 /* lSh */: 3 /* rSh */; goto special;
- X
- X case KBD_CAPS:
- X c = 4; goto special;
- X
- X case KBD_NUM:
- X c = 5; goto special;
- X
- X case KBD_SCROLL:
- X c = 6; goto special;
- X
- X case KBD_META:
- X c = 7; goto special;
- X
- X case KBD_CTL:
- X c = 9; goto special;
- X special:
- X for(j = 0; j < NUM_STATES; j++)
- X map->key[idx].map[j] = c;
- X map->key[idx].spcl = 0xff;
- X break;
- X
- X default:
- X break;
- X }
- X }
- X}
- X
- X#endif /* PCVT_USL_VT_COMPAT */
- X
- X/*---------------------------------------------------------------------------*
- X * switch keypad to numeric mode
- X *---------------------------------------------------------------------------*/
- Xvoid
- Xvt_keynum(struct video_state *svsp)
- X{
- X svsp->num_lock = 1;
- X update_led();
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * switch keypad to application mode
- X *---------------------------------------------------------------------------*/
- Xvoid
- Xvt_keyappl(struct video_state *svsp)
- X{
- X svsp->num_lock = 0;
- X update_led();
- X}
- X
- X#if PCVT_VT220KEYB
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 1
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey1(void)
- X{
- X if(meta_down)
- X more_chars = (u_char *)"\033[23~"; /* F11 */
- X else
- X do_vgapage(0);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 2
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey2(void)
- X{
- X if(meta_down)
- X more_chars = (u_char *)"\033[24~"; /* F12 */
- X else
- X do_vgapage(1);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 3
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey3(void)
- X{
- X if(meta_down)
- X more_chars = (u_char *)"\033[25~"; /* F13 */
- X else
- X do_vgapage(2);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 4
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey4(void)
- X{
- X if(meta_down)
- X more_chars = (u_char *)"\033[26~"; /* F14 */
- X else
- X do_vgapage(3);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 5
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey5(void)
- X{
- X if(meta_down)
- X more_chars = (u_char *)"\033[28~"; /* Help */
- X else
- X {
- X if((current_video_screen + 1) > totalscreens-1)
- X do_vgapage(0);
- X else
- X do_vgapage(current_video_screen + 1);
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 6
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey6(void)
- X{
- X if(meta_down)
- X more_chars = (u_char *)"\033[29~"; /* DO */
- X else
- X more_chars = (u_char *)"\033[17~"; /* F6 */
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 7
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey7(void)
- X{
- X if(meta_down)
- X more_chars = (u_char *)"\033[31~"; /* F17 */
- X else
- X more_chars = (u_char *)"\033[18~"; /* F7 */
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 8
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey8(void)
- X{
- X if(meta_down)
- X more_chars = (u_char *)"\033[32~"; /* F18 */
- X else
- X more_chars = (u_char *)"\033[19~"; /* F8 */
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 9
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey9(void)
- X{
- X if(meta_down)
- X more_chars = (u_char *)"\033[33~"; /* F19 */
- X else
- X more_chars = (u_char *)"\033[20~"; /* F9 */
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 10
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey10(void)
- X{
- X if(meta_down)
- X more_chars = (u_char *)"\033[34~"; /* F20 */
- X else
- X more_chars = (u_char *)"\033[21~"; /* F10 */
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 11
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey11(void)
- X{
- X if(meta_down)
- X more_chars = (u_char *)"\0x8FP"; /* PF1 */
- X else
- X more_chars = (u_char *)"\033[23~"; /* F11 */
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 12
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey12(void)
- X{
- X if(meta_down)
- X more_chars = (u_char *)"\0x8FQ"; /* PF2 */
- X else
- X more_chars = (u_char *)"\033[24~"; /* F12 */
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 1
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey1(void)
- X{
- X if(meta_down)
- X {
- X if(vsp->ukt.length[6]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[6]]);
- X else
- X more_chars = (u_char *)"\033[23~"; /* F11 */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 2
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey2(void)
- X{
- X if(meta_down)
- X {
- X if(vsp->ukt.length[7]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[7]]);
- X else
- X more_chars = (u_char *)"\033[24~"; /* F12 */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 3
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey3(void)
- X{
- X if(meta_down)
- X {
- X if(vsp->ukt.length[8]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[8]]);
- X else
- X more_chars = (u_char *)"\033[25~"; /* F13 */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 4
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey4(void)
- X{
- X if(meta_down)
- X {
- X if(vsp->ukt.length[9]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[9]]);
- X else
- X more_chars = (u_char *)"\033[26~"; /* F14 */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 5
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey5(void)
- X{
- X if(meta_down)
- X {
- X if(vsp->ukt.length[11]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[11]]);
- X else
- X more_chars = (u_char *)"\033[28~"; /* Help */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 6
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey6(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[0]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[0]]);
- X else
- X more_chars = (u_char *)"\033[17~"; /* F6 */
- X }
- X else if(vsp->ukt.length[12]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[12]]);
- X else
- X more_chars = (u_char *)"\033[29~"; /* DO */
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 7
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey7(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[1]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[1]]);
- X else
- X more_chars = (u_char *)"\033[18~"; /* F7 */
- X }
- X else if(vsp->ukt.length[14]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[14]]);
- X else
- X more_chars = (u_char *)"\033[31~"; /* F17 */
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 8
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey8(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[2]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[2]]);
- X else
- X more_chars = (u_char *)"\033[19~"; /* F8 */
- X }
- X else if(vsp->ukt.length[14]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[15]]);
- X else
- X more_chars = (u_char *)"\033[32~"; /* F18 */
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 9
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey9(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[3]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[3]]);
- X else
- X more_chars = (u_char *)"\033[20~"; /* F9 */
- X }
- X else if(vsp->ukt.length[16]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[16]]);
- X else
- X more_chars = (u_char *)"\033[33~"; /* F19 */
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 10
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey10(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[4]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[4]]);
- X else
- X more_chars = (u_char *)"\033[21~"; /* F10 */
- X }
- X else if(vsp->ukt.length[17]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[17]]);
- X else
- X more_chars = (u_char *)"\033[34~"; /* F20 */
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 11
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey11(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[6]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[6]]);
- X else
- X more_chars = (u_char *)"\033[23~"; /* F11 */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 12
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey12(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[7]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[7]]);
- X else
- X more_chars = (u_char *)"\033[24~"; /* F12 */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 1
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey1(void)
- X{
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 2
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey2(void)
- X{
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 3
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey3(void)
- X{
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 4
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey4(void)
- X{
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 5
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey5(void)
- X{
- X if(vsp->which_fkl == SYS_FKL)
- X toggl_bell(vsp);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 6
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey6(void)
- X{
- X if(vsp->which_fkl == SYS_FKL)
- X toggl_sevenbit(vsp);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 7
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey7(void)
- X{
- X if(vsp->which_fkl == SYS_FKL)
- X toggl_dspf(vsp);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 8
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey8(void)
- X{
- X if(vsp->which_fkl == SYS_FKL)
- X toggl_awm(vsp);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 9
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey9(void)
- X{
- X if(vsp->labels_on) /* toggle label display on/off */
- X fkl_off(vsp);
- X else
- X fkl_on(vsp);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 10
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey10(void)
- X{
- X if(vsp->labels_on) /* toggle user/system fkey labels */
- X {
- X if(vsp->which_fkl == USR_FKL)
- X sw_sfkl(vsp);
- X else if(vsp->which_fkl == SYS_FKL)
- X sw_ufkl(vsp);
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 11
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey11(void)
- X{
- X if(vsp->vt_pure_mode == M_PUREVT)
- X set_emulation_mode(vsp, M_HPVT);
- X else if(vsp->vt_pure_mode == M_HPVT)
- X set_emulation_mode(vsp, M_PUREVT);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 12
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey12(void)
- X{
- X}
- X
- X#else /* !PCVT_VT220KEYB, HP-like Keyboard layout */
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 1
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey1(void)
- X{
- X if(!meta_down)
- X {
- X if((vsp->vt_pure_mode == M_HPVT)
- X && (vsp->which_fkl == SYS_FKL))
- X toggl_columns(vsp);
- X else
- X more_chars = (u_char *)"\033[17~"; /* F6 */
- X }
- X else
- X {
- X if(vsp->vt_pure_mode == M_PUREVT
- X || (vsp->which_fkl == USR_FKL))
- X more_chars = (u_char *)"\033[26~"; /* F14 */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 2
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey2(void)
- X{
- X if(!meta_down)
- X {
- X if((vsp->vt_pure_mode == M_HPVT)
- X && (vsp->which_fkl == SYS_FKL))
- X vt_ris(vsp);
- X else
- X more_chars = (u_char *)"\033[18~"; /* F7 */
- X }
- X else
- X {
- X if(vsp->vt_pure_mode == M_PUREVT
- X || (vsp->which_fkl == USR_FKL))
- X more_chars = (u_char *)"\033[28~"; /* HELP */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 3
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey3(void)
- X{
- X if(!meta_down)
- X {
- X if((vsp->vt_pure_mode == M_HPVT)
- X && (vsp->which_fkl == SYS_FKL))
- X toggl_24l(vsp);
- X else
- X more_chars = (u_char *)"\033[19~"; /* F8 */
- X }
- X else
- X {
- X if(vsp->vt_pure_mode == M_PUREVT
- X || (vsp->which_fkl == USR_FKL))
- X more_chars = (u_char *)"\033[29~"; /* DO */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 4
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey4(void)
- X{
- X if(!meta_down)
- X {
- X
- X#if PCVT_SHOWKEYS
- X if((vsp->vt_pure_mode == M_HPVT)
- X && (vsp->which_fkl == SYS_FKL))
- X toggl_kbddbg(vsp);
- X else
- X more_chars = (u_char *)"\033[20~"; /* F9 */
- X#else
- X if(vsp->vt_pure_mode == M_PUREVT
- X || (vsp->which_fkl == USR_FKL))
- X more_chars = (u_char *)"\033[20~"; /* F9 */
- X#endif /* PCVT_SHOWKEYS */
- X
- X }
- X else
- X {
- X if(vsp->vt_pure_mode == M_PUREVT
- X || (vsp->which_fkl == USR_FKL))
- X more_chars = (u_char *)"\033[31~"; /* F17 */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 5
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey5(void)
- X{
- X if(!meta_down)
- X {
- X if((vsp->vt_pure_mode == M_HPVT)
- X && (vsp->which_fkl == SYS_FKL))
- X toggl_bell(vsp);
- X else
- X more_chars = (u_char *)"\033[21~"; /* F10 */
- X }
- X else
- X {
- X if(vsp->vt_pure_mode == M_PUREVT
- X || (vsp->which_fkl == USR_FKL))
- X more_chars = (u_char *)"\033[32~"; /* F18 */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 6
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey6(void)
- X{
- X if(!meta_down)
- X {
- X if((vsp->vt_pure_mode == M_HPVT)
- X && (vsp->which_fkl == SYS_FKL))
- X toggl_sevenbit(vsp);
- X else
- X more_chars = (u_char *)"\033[23~"; /* F11 */
- X }
- X else
- X {
- X if(vsp->vt_pure_mode == M_PUREVT
- X || (vsp->which_fkl == USR_FKL))
- X more_chars = (u_char *)"\033[33~"; /* F19 */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 7
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey7(void)
- X{
- X if(!meta_down)
- X {
- X if((vsp->vt_pure_mode == M_HPVT)
- X && (vsp->which_fkl == SYS_FKL))
- X toggl_dspf(vsp);
- X else
- X more_chars = (u_char *)"\033[24~"; /* F12 */
- X }
- X else
- X {
- X if(vsp->vt_pure_mode == M_PUREVT
- X || (vsp->which_fkl == USR_FKL))
- X more_chars = (u_char *)"\033[34~"; /* F20 */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 8
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey8(void)
- X{
- X if(!meta_down)
- X {
- X if((vsp->vt_pure_mode == M_HPVT)
- X && (vsp->which_fkl == SYS_FKL))
- X toggl_awm(vsp);
- X else
- X more_chars = (u_char *)"\033[25~"; /* F13 */
- X }
- X else
- X {
- X if(vsp->vt_pure_mode == M_PUREVT
- X || (vsp->which_fkl == USR_FKL))
- X more_chars = (u_char *)"\033[35~"; /* F21 ??!! */
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 9
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey9(void)
- X{
- X if(meta_down)
- X {
- X if(vsp->vt_pure_mode == M_PUREVT)
- X return;
- X
- X if(vsp->labels_on) /* toggle label display on/off */
- X fkl_off(vsp);
- X else
- X fkl_on(vsp);
- X }
- X else
- X {
- X do_vgapage(0);
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 10
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey10(void)
- X{
- X if(meta_down)
- X {
- X if(vsp->vt_pure_mode != M_PUREVT && vsp->labels_on)
- X {
- X if(vsp->which_fkl == USR_FKL)
- X sw_sfkl(vsp);
- X else if(vsp->which_fkl == SYS_FKL)
- X sw_ufkl(vsp);
- X }
- X }
- X else
- X {
- X do_vgapage(1);
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 11
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey11(void)
- X{
- X if(meta_down)
- X {
- X if(vsp->vt_pure_mode == M_PUREVT)
- X set_emulation_mode(vsp, M_HPVT);
- X else if(vsp->vt_pure_mode == M_HPVT)
- X set_emulation_mode(vsp, M_PUREVT);
- X }
- X else
- X {
- X do_vgapage(2);
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to function key 12
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xfkey12(void)
- X{
- X if(meta_down)
- X {
- X if(current_video_screen + 1 > totalscreens-1)
- X do_vgapage(0);
- X else
- X do_vgapage(current_video_screen + 1);
- X }
- X else
- X {
- X do_vgapage(3);
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 1
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey1(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[0]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[0]]);
- X }
- X else
- X {
- X if(vsp->ukt.length[9]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[9]]);
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 2
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey2(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[1]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[1]]);
- X }
- X else
- X {
- X if(vsp->ukt.length[11]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[11]]);
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 3
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey3(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[2]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[2]]);
- X }
- X else
- X {
- X if(vsp->ukt.length[12]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[12]]);
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 4
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey4(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[3]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[3]]);
- X }
- X else
- X {
- X if(vsp->ukt.length[13]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[13]]);
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 5
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey5(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[4]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[4]]);
- X }
- X else
- X {
- X if(vsp->ukt.length[14]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[14]]);
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 6
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey6(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[6]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[6]]);
- X }
- X else
- X {
- X if(vsp->ukt.length[15]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[15]]);
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 7
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey7(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[7]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[7]]);
- X }
- X else
- X {
- X if(vsp->ukt.length[16]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[16]]);
- X }
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 8
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey8(void)
- X{
- X if(!meta_down)
- X {
- X if(vsp->ukt.length[8]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[8]]);
- X }
- X else
- X {
- X if(vsp->ukt.length[17]) /* entry available ? */
- X more_chars = (u_char *)
- X &(vsp->udkbuf[vsp->ukt.first[17]]);
- X }
- X}
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 9
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey9(void)
- X{
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 10
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey10(void)
- X{
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 11
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey11(void)
- X{
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to SHIFTED function key 12
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xsfkey12(void)
- X{
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 1
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey1(void)
- X{
- X if(meta_down)
- X do_vgapage(0);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 2
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey2(void)
- X{
- X if(meta_down)
- X do_vgapage(1);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 3
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey3(void)
- X{
- X if(meta_down)
- X do_vgapage(2);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 4
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey4(void)
- X{
- X if(meta_down)
- X do_vgapage(3);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 5
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey5(void)
- X{
- X if(meta_down)
- X do_vgapage(4);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 6
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey6(void)
- X{
- X if(meta_down)
- X do_vgapage(5);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 7
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey7(void)
- X{
- X if(meta_down)
- X do_vgapage(6);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 8
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey8(void)
- X{
- X if(meta_down)
- X do_vgapage(7);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 9
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey9(void)
- X{
- X if(meta_down)
- X do_vgapage(8);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 10
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey10(void)
- X{
- X if(meta_down)
- X do_vgapage(9);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 11
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey11(void)
- X{
- X if(meta_down)
- X do_vgapage(10);
- X}
- X
- X/*---------------------------------------------------------------------------*
- X * function bound to control function key 12
- X *---------------------------------------------------------------------------*/
- Xstatic void
- Xcfkey12(void)
- X{
- X if(meta_down)
- X do_vgapage(11);
- X}
- X
- X#endif /* PCVT_VT220KEYB */
- X
- X#endif /* NVT > 0 */
- X
- X/* ------------------------------- EOF -------------------------------------*/
- END_OF_FILE
- if test 85774 -ne `wc -c <'pcvt/pcvt_kbd.c'`; then
- echo shar: \"'pcvt/pcvt_kbd.c'\" unpacked with wrong size!
- fi
- # end of 'pcvt/pcvt_kbd.c'
- fi
- echo shar: End of archive 2 \(of 13\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 13 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-