2 * Copyright (c) 1999 Hellmuth Michaelis
4 * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch.
6 * Copyright (c) 1992, 1993 Brian Dunford-Shore and Holger Veit.
10 * This code is derived from software contributed to Berkeley by
11 * William Jolitz and Don Ahn.
13 * This code is derived from software contributed to 386BSD by
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgement:
26 * This product includes software developed by Hellmuth Michaelis,
27 * Brian Dunford-Shore and Joerg Wunsch.
28 * 4. The name authors may not be used to endorse or promote products
29 * derived from this software without specific prior written permission.
31 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
32 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
33 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
34 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
35 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
36 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
40 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 /*---------------------------------------------------------------------------*
45 * pcvt_kbd.c VT220 Driver Keyboard Interface Code
46 * ----------------------------------------------------
48 * Last Edit-Date: [Mon Dec 27 14:01:50 1999]
50 * $FreeBSD: src/sys/i386/isa/pcvt/pcvt_kbd.c,v 1.32.2.1 2000/10/29 16:59:28 dwmalone Exp $
51 * $DragonFly: src/sys/dev/video/pcvt/i386/Attic/pcvt_kbd.c,v 1.4 2003/08/07 21:17:16 dillon Exp $
53 *---------------------------------------------------------------------------*/
60 #include "pcvt_hdr.h" /* global include */
62 #define LEDSTATE_UPDATE_PENDING (1 << 3)
64 static void fkey1(void), fkey2(void), fkey3(void), fkey4(void);
65 static void fkey5(void), fkey6(void), fkey7(void), fkey8(void);
66 static void fkey9(void), fkey10(void), fkey11(void), fkey12(void);
68 static void sfkey1(void), sfkey2(void), sfkey3(void), sfkey4(void);
69 static void sfkey5(void), sfkey6(void), sfkey7(void), sfkey8(void);
70 static void sfkey9(void), sfkey10(void), sfkey11(void), sfkey12(void);
72 static void cfkey1(void), cfkey2(void), cfkey3(void), cfkey4(void);
73 static void cfkey5(void), cfkey6(void), cfkey7(void), cfkey8(void);
74 static void cfkey9(void), cfkey10(void), cfkey11(void), cfkey12(void);
76 static void doreset ( void );
77 static void ovlinit ( int force );
78 static void settpmrate ( int rate );
79 static void setlockkeys ( int snc );
80 #ifndef _DEV_KBD_KBDREG_H_
81 static int kbc_8042cmd ( int val );
82 #endif /* !_DEV_KBD_KBDREG_H_ */
83 static int getokeydef ( unsigned key, struct kbd_ovlkey *thisdef );
84 static int getckeydef ( unsigned key, struct kbd_ovlkey *thisdef );
85 static int rmkeydef ( int key );
86 static int setkeydef ( struct kbd_ovlkey *data );
87 static u_char * xlatkey2ascii( U_short key );
89 static int ledstate = LEDSTATE_UPDATE_PENDING; /* keyboard led's */
90 static int tpmrate = KBD_TPD500|KBD_TPM100;
91 static u_char altkpflag = 0;
92 static u_short altkpval = 0;
94 static u_short *scrollback_savedscreen = (u_short *)0;
95 static size_t scrnsv_size = (size_t)-1;
96 static void scrollback_save_screen ( void );
97 static void scrollback_restore_screen ( void );
100 u_char rawkeybuf[80];
103 #include "pcvt_kbd.h" /* tables etc */
106 /*---------------------------------------------------------------------------*
107 * keyboard debugging: put kbd communication char into some buffer
108 *---------------------------------------------------------------------------*/
109 static void showkey (char delim, u_char val)
113 for(rki = 3; rki < 80; rki++) /* shift left buffer */
114 rawkeybuf[rki-3] = rawkeybuf[rki];
116 rawkeybuf[77] = delim; /* delimiter */
118 rki = (val & 0xf0) >> 4; /* ms nibble */
123 rki = rki - 10 + 'A';
127 rki = val & 0x0f; /* ls nibble */
132 rki = rki - 10 + 'A';
136 #endif /* PCVT_SHOWKEYS */
138 /*---------------------------------------------------------------------------*
139 * function to switch to another virtual screen
140 *---------------------------------------------------------------------------*/
144 if(critical_scroll) /* executing critical region ? */
145 switch_page = page; /* yes, auto switch later */
147 vgapage(page); /* no, switch now */
152 * This code from Lon Willett enclosed in #if PCVT_UPDLED_LOSES_INTR is
153 * abled because it crashes FreeBSD 1.1.5.1 at boot time.
154 * The cause is obviously that the timeout queue is not yet initialized
155 * timeout is called from here the first time.
156 * Anyway it is a pointer in the right direction so it is included for
160 #define PCVT_UPDLED_LOSES_INTR 0 /* disabled for now */
162 #if PCVT_UPDLED_LOSES_INTR || defined(_DEV_KBD_KBDREG_H_)
164 /*---------------------------------------------------------------------------*
165 * check for lost keyboard interrupts
166 *---------------------------------------------------------------------------*/
169 * The two commands to change the LEDs generate two KEYB_R_ACK responses
170 * from the keyboard, which aren't explicitly checked for (maybe they
171 * should be?). However, when a lot of other I/O is happening, one of
172 * the interrupts sometimes gets lost (I'm not sure of the details of
173 * how and why and what hardware this happens with).
175 * This may have had something to do with spltty() previously not being
176 * called before the kbd_cmd() calls in update_led().
178 * This is a real problem, because normally the keyboard is only polled
179 * by pcrint(), and no more interrupts will be generated until the ACK
180 * has been read. So the keyboard is hung. This code polls a little
181 * while after changing the LEDs to make sure that this hasn't happened.
183 * XXX Quite possibly we should poll the kbd on a regular basis anyway,
184 * in the interest of robustness. It may be possible that interrupts
185 * get lost other times as well.
188 static int lost_intr_timeout_queued = 0;
189 static struct callout_handle lost_intr_ch =
190 CALLOUT_HANDLE_INITIALIZER(&lost_intr_ch);
193 check_for_lost_intr (void *arg)
195 #ifndef _DEV_KBD_KBDREG_H_
196 lost_intr_timeout_queued = 0;
197 if (inb(CONTROLLER_CTRL) & STATUS_OUTPBF)
199 int opri = spltty ();
206 lost_intr_timeout_queued = 0;
207 if (kbd && (*kbdsw[kbd->kb_index]->lock)(kbd, TRUE)) {
209 (*kbdsw[kbd->kb_index]->lock)(kbd, FALSE);
210 if ((*kbdsw[kbd->kb_index]->check)(kbd))
215 lost_intr_ch = timeout(check_for_lost_intr, (void *)NULL, hz);
216 lost_intr_timeout_queued = 1;
217 #endif /* !_DEV_KBD_KBDREG_H_ */
220 #endif /* PCVT_UPDLED_LOSES_INTR || defined(_DEV_KBD_KBDREG_H_) */
222 /*---------------------------------------------------------------------------*
223 * update keyboard led's
224 *---------------------------------------------------------------------------*/
228 #if !PCVT_NO_LED_UPDATE
230 /* Don't update LED's unless necessary. */
232 int opri, new_ledstate;
235 #ifndef _DEV_KBD_KBDREG_H_
236 new_ledstate = (vsp->scroll_lock) |
237 (vsp->num_lock * 2) |
238 (vsp->caps_lock * 4);
240 new_ledstate = ((vsp->scroll_lock) ? LED_SCR : 0) |
241 ((vsp->num_lock) ? LED_NUM : 0) |
242 ((vsp->caps_lock) ? LED_CAP : 0);
243 #endif /* _DEV_KBD_KBDREG_H_ */
245 if (new_ledstate != ledstate)
247 #ifndef _DEV_KBD_KBDREG_H_
248 int response1, response2;
250 ledstate = LEDSTATE_UPDATE_PENDING;
252 if(kbd_cmd(KEYB_C_LEDS) != 0)
254 printf("Keyboard LED command timeout\n");
260 * For some keyboards or keyboard controllers, it is an
261 * error to issue a command without waiting long enough
262 * for an ACK for the previous command. The keyboard
263 * gets confused, and responds with KEYB_R_RESEND, but
264 * we ignore that. Wait for the ACK here. The busy
265 * waiting doesn't matter much, since we lose anyway by
266 * busy waiting to send the command.
268 * XXX actually wait for any response, since we can't
269 * handle normal scancodes here.
271 * XXX all this should be interrupt driven. Issue only
272 * one command at a time wait for a ACK before proceeding.
273 * Retry after a timeout or on receipt of a KEYB_R_RESEND.
274 * KEYB_R_RESENDs seem to be guaranteed by working
275 * keyboard controllers with broken (or disconnected)
276 * keyboards. There is another code for keyboard
277 * reconnects. The keyboard hardware is very simple and
280 response1 = kbd_response();
282 if(kbd_cmd(new_ledstate) != 0) {
283 printf("Keyboard LED data timeout\n");
287 response2 = kbd_response();
289 if (response1 == KEYB_R_ACK && response2 == KEYB_R_ACK)
290 ledstate = new_ledstate;
293 "Keyboard LED command not ACKed (responses %#x %#x)\n",
294 response1, response2);
295 #else /* _DEV_KBD_KBDREG_H_ */
298 ledstate = new_ledstate;
301 ledstate = LEDSTATE_UPDATE_PENDING;
303 if ((*kbdsw[kbd->kb_index]->ioctl)(kbd, KDSETLED,
304 (caddr_t)&new_ledstate) == 0)
305 ledstate = new_ledstate;
308 #endif /* !_DEV_KBD_KBDREG_H_ */
310 #if PCVT_UPDLED_LOSES_INTR
311 if (lost_intr_timeout_queued)
312 untimeout(check_for_lost_intr, NULL, lost_intr_ch);
314 lost_intr_ch = timeout(check_for_lost_intr, NULL, hz);
315 lost_intr_timeout_queued = 1;
316 #endif /* PCVT_UPDLED_LOSES_INTR */
320 #ifndef _DEV_KBD_KBDREG_H_
324 #endif /* !PCVT_NO_LED_UPDATE */
327 /*---------------------------------------------------------------------------*
329 *---------------------------------------------------------------------------*/
333 #ifndef _DEV_KBD_KBDREG_H_
334 tpmrate = rate & 0x7f;
335 if(kbd_cmd(KEYB_C_TYPEM) != 0)
336 printf("Keyboard TYPEMATIC command timeout\n");
337 else if(kbd_cmd(tpmrate) != 0)
338 printf("Keyboard TYPEMATIC data timeout\n");
342 tpmrate = rate & 0x7f;
343 if ((*kbdsw[kbd->kb_index]->ioctl)(kbd, KDSETRAD, (caddr_t)&tpmrate))
344 printf("pcvt: failed to set keyboard TYPEMATIC.\n");
345 #endif /* !_DEV_KBD_KBDREG_H_ */
348 #ifndef _DEV_KBD_KBDREG_H_
349 /*---------------------------------------------------------------------------*
350 * Pass command to keyboard controller (8042)
351 *---------------------------------------------------------------------------*/
357 timeo = 100000; /* > 100 msec */
358 while (inb(CONTROLLER_CTRL) & STATUS_INPBF)
361 outb(CONTROLLER_CTRL, val);
365 /*---------------------------------------------------------------------------*
366 * Pass command to keyboard itself
367 *---------------------------------------------------------------------------*/
373 timeo = 100000; /* > 100 msec */
374 while (inb(CONTROLLER_CTRL) & STATUS_INPBF)
377 outb(CONTROLLER_DATA, val);
381 #endif /* PCVT_SHOWKEYS */
386 /*---------------------------------------------------------------------------*
387 * Read response from keyboard
388 * NB: make sure to call spltty() before kbd_cmd(), kbd_response().
389 *---------------------------------------------------------------------------*/
396 timeo = 500000; /* > 500 msec (KEYB_R_SELFOK requires 87) */
397 while (!(inb(CONTROLLER_CTRL) & STATUS_OUTPBF))
401 PCVT_KBD_DELAY(); /* 7 us delay */
402 ch = inb(CONTROLLER_DATA);
406 #endif /* PCVT_SHOWKEYS */
410 #endif /* _DEV_KBD_KBDREG_H_ */
413 /*---------------------------------------------------------------------------*
414 * switch PC scan code emulation mode
415 *---------------------------------------------------------------------------*/
417 kbd_emulate_pc(int do_emulation)
419 #ifndef _DEV_KBD_KBDREG_H_
420 int cmd, timeo = 10000;
422 cmd = COMMAND_SYSFLG|COMMAND_IRQEN; /* common base cmd */
425 cmd |= COMMAND_INHOVR;
429 cmd |= COMMAND_PCSCAN;
431 kbc_8042cmd(CONTR_WRITE);
432 while (inb(CONTROLLER_CTRL) & STATUS_INPBF)
435 outb(CONTROLLER_DATA, cmd);
437 set_controller_command_byte(*(KBDC *)kbd->kb_data, KBD_TRANSLATION,
438 (do_emulation) ? KBD_TRANSLATION : 0);
439 #endif /* !_DEV_KBD_KBDREG_H_ */
442 #endif /* PCVT_SCANSET > 1 */
445 #ifndef PCVT_NONRESP_KEYB_TRY
446 #define PCVT_NONRESP_KEYB_TRY 25 /* no of times to try to detect */
447 #endif /* a nonresponding keyboard */
449 /*---------------------------------------------------------------------------*
450 * try to force keyboard into a known state ..
451 *---------------------------------------------------------------------------*/
455 #ifndef _DEV_KBD_KBDREG_H_
460 /* Enable interrupts and keyboard, etc. */
461 if (kbc_8042cmd(CONTR_WRITE) != 0)
462 printf("pcvt: doreset() - timeout controller write command\n");
464 #if PCVT_USEKBDSEC /* security enabled */
466 # if PCVT_SCANSET == 2
467 # define KBDINITCMD COMMAND_SYSFLG|COMMAND_IRQEN
468 # else /* PCVT_SCANSET != 2 */
469 # define KBDINITCMD COMMAND_PCSCAN|COMMAND_SYSFLG|COMMAND_IRQEN
470 # endif /* PCVT_SCANSET == 2 */
472 #else /* ! PCVT_USEKBDSEC */ /* security disabled */
474 # if PCVT_SCANSET == 2
475 # define KBDINITCMD COMMAND_INHOVR|COMMAND_SYSFLG|COMMAND_IRQEN
476 # else /* PCVT_SCANSET != 2 */
477 # define KBDINITCMD COMMAND_PCSCAN|COMMAND_INHOVR|COMMAND_SYSFLG\
479 # endif /* PCVT_SCANSET == 2 */
481 #endif /* PCVT_USEKBDSEC */
483 if (kbd_cmd(KBDINITCMD) != 0)
484 printf("pcvt: doreset() - timeout writing keyboard init command\n");
487 * Discard any stale keyboard activity. The 0.1 boot code isn't
488 * very careful and sometimes leaves a KEYB_R_RESEND. Versions
489 * between 1992 and Oct 1996 didn't have the delay and sometimes
490 * left a KEYB_R_RESEND.
493 if (inb(CONTROLLER_CTRL) & STATUS_OUTPBF)
497 if (!(inb(CONTROLLER_CTRL) & STATUS_OUTPBF))
502 /* Start keyboard reset */
506 if (kbd_cmd(KEYB_C_RESET) != 0)
508 printf("pcvt: doreset() - timeout for keyboard reset command\n");
509 outb(CONTROLLER_DATA, KEYB_C_RESET); /* force */
512 /* Wait for the first response to reset and handle retries */
513 while ((response = kbd_response()) != KEYB_R_ACK)
517 if(!again) /* print message only once ! */
518 printf("pcvt: doreset() - response != ack and response < 0 [one time only msg]\n");
519 response = KEYB_R_RESEND;
521 else if (response == KEYB_R_RESEND)
523 if(!again) /* print message only once ! */
524 printf("pcvt: doreset() - got KEYB_R_RESEND response ... [one time only msg]\n");
526 if (response == KEYB_R_RESEND)
528 if(++again > PCVT_NONRESP_KEYB_TRY)
530 printf("pcvt: doreset() - Caution - no PC keyboard detected!\n");
531 keyboard_type = KB_UNKNOWN;
536 if((kbd_cmd(KEYB_C_RESET) != 0) && (once == 0))
538 once++; /* print message only once ! */
539 printf("pcvt: doreset() - timeout for loop keyboard reset command [one time only msg]\n");
540 outb(CONTROLLER_DATA, KEYB_C_RESET); /* force */
545 /* Wait for the second response to reset */
547 while ((response = kbd_response()) != KEYB_R_SELFOK)
551 printf("pcvt: doreset() - response != OK and resonse < 0\n");
553 * If KEYB_R_SELFOK never arrives, the loop will
554 * finish here unless the keyboard babbles or
555 * STATUS_OUTPBF gets stuck.
567 if(kbd_cmd(KEYB_C_ID) != 0)
569 printf("pcvt: doreset() - timeout for keyboard ID command\n");
570 keyboard_type = KB_UNKNOWN;
577 if((response = kbd_response()) == KEYB_R_MF2ID1)
579 if((response = kbd_response()) == KEYB_R_MF2ID2)
581 keyboard_type = KB_MFII;
583 else if(response == KEYB_R_MF2ID2HP)
585 keyboard_type = KB_MFII;
589 printf("\npcvt: doreset() - kbdid, response 2 = [%d]\n",
591 keyboard_type = KB_UNKNOWN;
594 else if (response == KEYB_R_ACK)
598 else if (response == -1)
600 keyboard_type = KB_AT;
604 printf("\npcvt: doreset() - kbdid, response 1 = [%d]\n", response);
610 #else /* PCVT_KEYBDID */
612 keyboard_type = KB_MFII; /* force it .. */
614 #endif /* PCVT_KEYBDID */
616 #else /* _DEV_KBD_KBDREG_H_ */
619 if (!reset_keyboard) /* no, we are not ready to reset */
622 if (lost_intr_timeout_queued) {
623 untimeout(check_for_lost_intr, (void *)NULL, lost_intr_ch);
624 lost_intr_timeout_queued = 0;
628 return; /* shouldn't happen */
631 ledstate = LEDSTATE_UPDATE_PENDING;
633 #if PCVT_USEKBDSEC /* security enabled */
635 # if PCVT_SCANSET == 2
636 # define KBDINITCMD 0
637 # else /* PCVT_SCANSET != 2 */
638 # define KBDINITCMD KBD_TRANSLATION
639 # endif /* PCVT_SCANSET == 2 */
641 #else /* ! PCVT_USEKBDSEC */ /* security disabled */
643 # if PCVT_SCANSET == 2
644 # define KBDINITCMD KBD_OVERRIDE_KBD_LOCK
645 # else /* PCVT_SCANSET != 2 */
646 # define KBDINITCMD KBD_TRANSLATION | KBD_OVERRIDE_KBD_LOCK
647 # endif /* PCVT_SCANSET == 2 */
649 #endif /* PCVT_USEKBDSEC */
651 set_controller_command_byte(*(KBDC *)kbd->kb_data,
652 KBD_OVERRIDE_KBD_LOCK | KBD_TRANSLATION, KBDINITCMD);
654 keyboard_type = KB_MFII; /* force it .. */
657 (*kbdsw[kbd->kb_index]->ioctl)(kbd, KDGKBTYPE, (caddr_t)&type);
661 keyboard_type = KB_AT;
664 keyboard_type = KB_MFII;
667 keyboard_type = KB_UNKNOWN;
670 #endif /* PCVT_KEYBDID */
674 lost_intr_ch = timeout(check_for_lost_intr, (void *)NULL, hz);
675 lost_intr_timeout_queued = 1;
677 #endif /* !_DEV_KBD_KBDREG_H_ */
680 /*---------------------------------------------------------------------------*
682 *---------------------------------------------------------------------------*/
688 keyboard_is_initialized = 1;
691 /*---------------------------------------------------------------------------*
692 * init keyboard code, this initializes the keyboard subsystem
693 * just "a bit" so the very very first ddb session is able to
694 * get proper keystrokes - in other words, it's a hack ....
695 *---------------------------------------------------------------------------*/
700 keyboard_is_initialized = 1;
703 /*---------------------------------------------------------------------------*
704 * init keyboard overlay table
705 *---------------------------------------------------------------------------*/
707 void ovlinit(int force)
711 if(force || ovlinitflag==0)
713 if(ovlinitflag == 0 &&
714 (ovltbl = (Ovl_tbl *)malloc(sizeof(Ovl_tbl) * OVLTBL_SIZE,
715 M_DEVBUF, M_WAITOK)) == NULL)
716 panic("pcvt_kbd: malloc of Ovl_tbl failed");
718 for(i=0; i<OVLTBL_SIZE; i++)
722 ovltbl[i].unshift[0] =
725 ovltbl[i].altgr[0] = 0;
729 ovltbl[i].suba = KBD_SUBT_STR; /* just strings .. */
731 for(i=0; i<=MAXKEYNUM; i++)
732 key2ascii[i].type &= KBD_MASK;
737 /*---------------------------------------------------------------------------*
738 * get original key definition
739 *---------------------------------------------------------------------------*/
741 getokeydef(unsigned key, Ovl_tbl *thisdef)
743 if(key == 0 || key > MAXKEYNUM)
746 thisdef->keynum = key;
747 thisdef->type = key2ascii[key].type;
749 if(key2ascii[key].unshift.subtype == STR)
751 bcopy((u_char *)(key2ascii[key].unshift.what.string),
752 thisdef->unshift, CODE_SIZE);
753 thisdef->subu = KBD_SUBT_STR;
757 bcopy("", thisdef->unshift, CODE_SIZE);
758 thisdef->subu = KBD_SUBT_FNC;
761 if(key2ascii[key].shift.subtype == STR)
763 bcopy((u_char *)(key2ascii[key].shift.what.string),
764 thisdef->shift, CODE_SIZE);
765 thisdef->subs = KBD_SUBT_STR;
769 bcopy("",thisdef->shift,CODE_SIZE);
770 thisdef->subs = KBD_SUBT_FNC;
773 if(key2ascii[key].ctrl.subtype == STR)
775 bcopy((u_char *)(key2ascii[key].ctrl.what.string),
776 thisdef->ctrl, CODE_SIZE);
777 thisdef->subc = KBD_SUBT_STR;
781 bcopy("",thisdef->ctrl,CODE_SIZE);
782 thisdef->subc = KBD_SUBT_FNC;
785 /* deliver at least anything for ALTGR settings ... */
787 if(key2ascii[key].unshift.subtype == STR)
789 bcopy((u_char *)(key2ascii[key].unshift.what.string),
790 thisdef->altgr, CODE_SIZE);
791 thisdef->suba = KBD_SUBT_STR;
795 bcopy("",thisdef->altgr, CODE_SIZE);
796 thisdef->suba = KBD_SUBT_FNC;
801 /*---------------------------------------------------------------------------*
802 * get current key definition
803 *---------------------------------------------------------------------------*/
805 getckeydef(unsigned key, Ovl_tbl *thisdef)
807 u_short type = key2ascii[key].type;
812 if(type & KBD_OVERLOAD)
813 *thisdef = ovltbl[key2ascii[key].ovlindex];
815 getokeydef(key,thisdef);
820 /*---------------------------------------------------------------------------*
821 * translate keynumber and returns ptr to associated ascii string
822 * if key is bound to a function, executes it, and ret empty ptr
823 *---------------------------------------------------------------------------*/
825 xlatkey2ascii(U_short key)
827 static u_char capchar[2] = {0, 0};
829 static u_char metachar[3] = {0x1b, 0, 0};
831 static u_char metachar[2] = {0, 0};
833 static Ovl_tbl thisdef;
837 if(key==0) /* ignore the NON-KEY */
840 getckeydef(key&0x7F, &thisdef); /* get the current ASCII value */
842 thisdef.type &= KBD_MASK;
844 if(key&0x80) /* special handling of ALT-KEYPAD */
846 /* is the ALT Key released? */
847 if(thisdef.type==KBD_META || thisdef.type==KBD_ALTGR)
849 if(altkpflag) /* have we been in altkp mode? */
851 capchar[0] = altkpval;
860 switch(thisdef.type) /* convert the keys */
870 more_chars = (u_char *)thisdef.altgr;
872 else if(!ctrl_down && (shift_down || vsp->shift_lock))
874 if(key2ascii[key].shift.subtype == STR)
875 more_chars = (u_char *)thisdef.shift;
877 fnc = key2ascii[key].shift.what.func;
882 if(key2ascii[key].ctrl.subtype == STR)
883 more_chars = (u_char *)thisdef.ctrl;
885 fnc = key2ascii[key].ctrl.what.func;
890 if(key2ascii[key].unshift.subtype == STR)
891 more_chars = (u_char *)thisdef.unshift;
893 fnc = key2ascii[key].unshift.what.func;
897 (*fnc)(); /* execute function */
899 if((more_chars != NULL) && (more_chars[1] == 0))
901 if(vsp->caps_lock && more_chars[0] >= 'a'
902 && more_chars[0] <= 'z')
904 capchar[0] = *more_chars - ('a'-'A');
905 more_chars = capchar;
910 metachar[1] = *more_chars;
912 metachar[0] = *more_chars | 0x80;
914 more_chars = metachar;
947 if(meta_down || altgr_down)
949 if((n = keypad2num[key-91]) >= 0)
953 /* start ALT-KP mode */
967 if(key2ascii[key].shift.subtype == STR)
968 more_chars = (u_char *)thisdef.shift;
970 fnc = key2ascii[key].shift.what.func;
974 if(key2ascii[key].unshift.subtype == STR)
975 more_chars = (u_char *)thisdef.unshift;
977 fnc = key2ascii[key].unshift.what.func;
981 (*fnc)(); /* execute function */
990 if(key2ascii[key].shift.subtype == STR)
991 more_chars = (u_char *)thisdef.shift;
993 fnc = key2ascii[key].shift.what.func;
997 if(key2ascii[key].unshift.subtype == STR)
998 more_chars = (u_char *)thisdef.unshift;
1000 fnc = key2ascii[key].unshift.what.func;
1004 (*fnc)(); /* execute function */
1007 case KBD_NUM: /* special kp-num handling */
1012 more_chars = (u_char *)"\033OP"; /* PF1 */
1024 if(!(vsp->num_lock))
1026 more_chars = (u_char *)thisdef.shift;
1030 more_chars = (u_char *)thisdef.unshift;
1032 if(vsp->lnm && (*more_chars == '\r'))
1034 more_chars = (u_char *)"\r\n"; /* CR LF */
1039 metachar[1] = *more_chars;
1041 metachar[0] = *more_chars | 0x80;
1043 more_chars = metachar;
1047 case KBD_META: /* these keys are */
1048 case KBD_ALTGR: /* handled directly */
1049 case KBD_SCROLL: /* by the keyboard */
1050 case KBD_CAPS: /* handler - they are */
1051 case KBD_SHFTLOCK: /* ignored here */
1059 /*---------------------------------------------------------------------------*
1060 * get keystrokes from the keyboard.
1061 * if noblock = 0, wait until a key is pressed.
1062 * else return NULL if no characters present.
1063 *---------------------------------------------------------------------------*/
1066 extern u_char pcvt_kbd_fifo[];
1067 extern int pcvt_kbd_rptr;
1068 extern short pcvt_kbd_count;
1079 #if PCVT_KBD_FIFO && PCVT_SLOW_INTERRUPT
1083 static u_char kbd_lastkey = 0; /* last keystroke */
1087 u_char extended: 1; /* extended prefix seen */
1088 u_char ext1: 1; /* extended prefix 1 seen */
1089 u_char breakseen: 1; /* break code seen */
1090 u_char vshift: 1; /* virtual shift pending */
1091 u_char vcontrol: 1; /* virtual control pending */
1092 u_char sysrq: 1; /* sysrq pressed */
1096 static char keybuf[2] = {0}; /* the second 0 is a delimiter! */
1097 #endif /* XSERVER */
1099 #ifdef _DEV_KBD_KBDREG_H_
1101 #endif /* _DEV_KBD_KBDREG_H_ */
1105 if(noblock == 31337)
1113 #ifndef _DEV_KBD_KBDREG_H_
1117 /* see if there is data from the keyboard available either from */
1118 /* the keyboard fifo or from the 8042 keyboard controller */
1120 if (pcvt_kbd_count || (inb(CONTROLLER_CTRL) & STATUS_OUTPBF))
1122 if (!pcvt_kbd_count) /* source = 8042 */
1124 PCVT_KBD_DELAY(); /* 7 us delay */
1125 dt = inb(CONTROLLER_DATA); /* get from obuf */
1127 else /* source = keyboard fifo */
1129 dt = pcvt_kbd_fifo[pcvt_kbd_rptr++];
1130 PCVT_DISABLE_INTR();
1133 if (pcvt_kbd_rptr >= PCVT_KBD_FIFO_SZ)
1137 #else /* !PCVT_KB_FIFO */
1139 /* see if there is data from the keyboard available from the 8042 */
1141 if (inb(CONTROLLER_CTRL) & STATUS_OUTPBF)
1143 PCVT_KBD_DELAY(); /* 7 us delay */
1144 dt = inb(CONTROLLER_DATA); /* yes, get data */
1146 #endif /* !PCVT_KBD_FIFO */
1148 #else /* _DEV_KBD_KBDREG_H_ */
1151 if (pcvt_kbd_count) {
1152 dt = pcvt_kbd_fifo[pcvt_kbd_rptr++];
1153 PCVT_DISABLE_INTR();
1156 if (pcvt_kbd_rptr >= PCVT_KBD_FIFO_SZ)
1159 #endif /* PCVT_KBD_FIFO */
1161 while ((c = (*kbdsw[kbd->kb_index]->read)(kbd, TRUE)) == -1)
1165 if ((c = (*kbdsw[kbd->kb_index]->read)(kbd, FALSE)) == -1)
1172 #endif /* !_DEV_KBD_KBDREG_H_ */
1175 * If x mode is active, only care for locking keys, then
1176 * return the scan code instead of any key translation.
1177 * Additionally, this prevents us from any attempts to
1178 * execute pcvt internal functions caused by keys (such
1179 * as screen flipping).
1180 * XXX For now, only the default locking key definitions
1181 * are recognized (i.e. if you have overloaded you "A" key
1182 * as NUMLOCK, that wont effect X mode:-)
1183 * Changing this would be nice, but would require modifi-
1184 * cations to the X server. After having this, X will
1185 * deal with the LEDs itself, so we are committed.
1188 * Iff PCVT_USL_VT_COMPAT is defined, the behaviour has
1189 * been fixed. We need not care about any keys here, since
1190 * there are ioctls that deal with the lock key / LED stuff.
1196 #if PCVT_FREEBSD > 210
1197 add_keyboard_randomness(dt);
1198 #endif /* PCVT_FREEBSD > 210 */
1200 #if !PCVT_USL_VT_COMPAT
1201 if ((dt & 0x80) == 0)
1206 /* XXX on which virt screen? */ vsp->num_lock ^= 1;
1211 vsp->caps_lock ^= 1;
1216 vsp->scroll_lock ^= 1;
1220 #endif /* !PCVT_USL_VT_COMPAT */
1224 * The (mouse systems) mouse emulator. The mouse
1225 * device allocates the first device node that is
1226 * not used by a virtual terminal. (E.g., you have
1227 * eight vtys, /dev/ttyv0 thru /dev/ttyv7, so the
1228 * mouse emulator were /dev/ttyv8.)
1229 * Currently the emulator only works if the keyboard
1230 * is in raw (PC scan code) mode. This is the typic-
1231 * al case when running the X server.
1232 * It is activated if the num locks LED is active
1233 * for the current vty, and if the mouse device
1234 * has been opened by at least one process. It
1235 * grabs the numerical keypad events (but only
1236 * the "non-extended", so the separate arrow keys
1237 * continue to work), and three keys for the "mouse
1238 * buttons", preferrably F1 thru F3. Any of the
1239 * eight directions (N, NE, E, SE, S, SW, W, NW)
1240 * is supported, and frequent key presses (less
1241 * than e.g. half a second between key presses)
1242 * cause the emulator to accelerate the pointer
1243 * movement by 6, while single presses result in
1244 * single moves, so each point can be reached.
1247 * NB: the following code is spagghetti.
1248 * Only eat it with lotta tomato ketchup and
1249 * Parmesan cheese:-)
1252 * look whether we will have to steal the keys
1253 * and cook them into mouse events
1255 if(vsp->num_lock && mouse.opened)
1257 int button, accel, i;
1260 MOUSE_NW, MOUSE_N, MOUSE_NE,
1261 MOUSE_W, MOUSE_0, MOUSE_E,
1262 MOUSE_SW, MOUSE_S, MOUSE_SE
1266 dev_t dummy = makedev(0, mouse.minor);
1267 struct tty *mousetty = get_pccons(dummy);
1269 * strings to send for each mouse event,
1270 * indexed by the movement direction and
1271 * the "accelerator" value (TRUE for frequent
1272 * key presses); note that the first byte
1273 * of each string is actually overwritten
1274 * by the current button value before sending
1277 static u_char mousestrings[2][MOUSE_SE+1][5] =
1280 /* first, the non-accelerated strings*/
1281 {0x87, -1, 1, 0, 0}, /* NW */
1282 {0x87, 0, 1, 0, 0}, /* N */
1283 {0x87, 1, 1, 0, 0}, /* NE */
1284 {0x87, -1, 0, 0, 0}, /* W */
1285 {0x87, 0, 0, 0, 0}, /* 0 */
1286 {0x87, 1, 0, 0, 0}, /* E */
1287 {0x87, -1, -1, 0, 0}, /* SW */
1288 {0x87, 0, -1, 0, 0}, /* S */
1289 {0x87, 1, -1, 0, 0} /* SE */
1292 /* now, 6 steps at once */
1293 {0x87, -4, 4, 0, 0}, /* NW */
1294 {0x87, 0, 6, 0, 0}, /* N */
1295 {0x87, 4, 4, 0, 0}, /* NE */
1296 {0x87, -6, 0, 0, 0}, /* W */
1297 {0x87, 0, 0, 0, 0}, /* 0 */
1298 {0x87, 6, 0, 0, 0}, /* E */
1299 {0x87, -4, -4, 0, 0}, /* SW */
1300 {0x87, 0, -6, 0, 0}, /* S */
1301 {0x87, 4, -4, 0, 0} /* SE */
1307 /* ignore extended scan codes */
1308 mouse.extendedseen = 1;
1309 goto no_mouse_event;
1311 if(mouse.extendedseen)
1313 mouse.extendedseen = 0;
1314 goto no_mouse_event;
1316 mouse.extendedseen = 0;
1319 * Note that we cannot use a switch here
1320 * since we want to have the keycodes in
1323 if((dt & 0x7f) == mousedef.leftbutton) {
1327 else if((dt & 0x7f) == mousedef.middlebutton) {
1331 else if((dt & 0x7f) == mousedef.rightbutton) {
1336 * i would really like to give
1337 * some acustical support
1338 * (pling/plong); i am not sure
1339 * whether it is safe to call
1340 * sysbeep from within an intr
1341 * service, since it calls
1342 * timeout in turn which mani-
1343 * pulates the spl mask - jw
1346 # define PLING sysbeep(PCVT_SYSBEEPF / 1500, 2)
1347 # define PLONG sysbeep(PCVT_SYSBEEPF / 1200, 2)
1349 if(mousedef.stickybuttons)
1352 mouse.breakseen = 1;
1355 else if(mouse.buttons == button
1356 && !mouse.breakseen) {
1357 /* ignore repeats */
1361 mouse.breakseen = 0;
1362 if(mouse.buttons == button) {
1368 * eventually, release
1370 * and stick this one
1372 mouse.buttons = button;
1383 else if((mouse.buttons
1389 /*else: ignore same btn press*/
1396 else switch(dt & 0x7f)
1398 /* the arrow keys - KP 1 thru KP 9 */
1399 case 0x47: move = MOUSE_NW; goto do_move;
1400 case 0x48: move = MOUSE_N; goto do_move;
1401 case 0x49: move = MOUSE_NE; goto do_move;
1402 case 0x4b: move = MOUSE_W; goto do_move;
1403 case 0x4c: move = MOUSE_0; goto do_move;
1404 case 0x4d: move = MOUSE_E; goto do_move;
1405 case 0x4f: move = MOUSE_SW; goto do_move;
1406 case 0x50: move = MOUSE_S; goto do_move;
1407 case 0x51: move = MOUSE_SE;
1411 * arrow key break events are
1412 * of no importance for us
1416 * see whether the last move did
1417 * happen "recently", i.e. before
1418 * less than half a second
1421 timevalsub(&now, &mouse.lastmove);
1422 getmicrotime(&mouse.lastmove);
1423 accel = (now.tv_sec == 0
1425 < mousedef.acceltime);
1428 default: /* not a mouse-emulating key */
1429 goto no_mouse_event;
1431 mousestrings[accel][move][0] =
1432 0x80 + (~mouse.buttons & 7);
1433 /* finally, send the string */
1434 for(i = 0; i < 5; i++)
1435 (*linesw[mousetty->t_line].l_rint)
1436 (mousestrings[accel][move][i],
1438 return (u_char *)0; /* not a kbd event */
1442 #endif /* PCVT_EMU_MOUSE */
1444 return ((u_char *)keybuf);
1448 #else /* !XSERVER */
1450 #ifndef _DEV_KBD_KBDREG_H_
1454 /* see if there is data from the keyboard available either from */
1455 /* the keyboard fifo or from the 8042 keyboard controller */
1457 if (pcvt_kbd_count || (inb(CONTROLLER_CTRL) & STATUS_OUTPBF))
1459 if (!noblock || kbd_polling) /* source = 8042 */
1461 PCVT_KBD_DELAY(); /* 7 us delay */
1462 dt = inb(CONTROLLER_DATA);
1464 else /* source = keyboard fifo */
1466 dt = pcvt_kbd_fifo[pcvt_kbd_rptr++]; /* yes, get it ! */
1467 PCVT_DISABLE_INTR();
1470 if (pcvt_kbd_rptr >= PCVT_KBD_FIFO_SZ)
1475 #else /* !PCVT_KBD_FIFO */
1477 /* see if there is data from the keyboard available from the 8042 */
1479 if(inb(CONTROLLER_CTRL) & STATUS_OUTPBF)
1481 PCVT_KBD_DELAY(); /* 7 us delay */
1482 dt = inb(CONTROLLER_DATA); /* yes, get data ! */
1485 #endif /* !PCVT_KBD_FIFO */
1487 #else /* _DEV_KBD_KBDREG_H_ */
1490 if (pcvt_kbd_count) {
1491 dt = pcvt_kbd_fifo[pcvt_kbd_rptr++];
1492 PCVT_DISABLE_INTR();
1495 if (pcvt_kbd_rptr >= PCVT_KBD_FIFO_SZ)
1498 #endif /* PCVT_KBD_FIFO */
1500 while ((c = (*kbdsw[kbd->kb_index]->read)(kbd, TRUE)) == -1)
1504 if ((c = (*kbdsw[kbd->kb_index]->read)(kbd, FALSE)) == -1)
1509 #endif /* !_DEV_KBD_KBDREG_H_ */
1511 #endif /* !XSERVER */
1513 #ifndef _DEV_KBD_KBDREG_H_
1521 #endif /* !_DEV_KBD_KBDREG_H_ */
1525 #endif /* PCVT_SHOWKEYS */
1527 /* lets look what we got */
1530 case KEYB_R_OVERRUN0: /* keyboard buffer overflow */
1532 #if PCVT_SCANSET == 2
1533 case KEYB_R_SELFOK: /* keyboard selftest ok */
1534 #endif /* PCVT_SCANSET == 2 */
1536 case KEYB_R_ECHO: /* keyboard response to KEYB_C_ECHO */
1537 case KEYB_R_ACK: /* acknowledge after command has rx'd*/
1538 case KEYB_R_SELFBAD: /* keyboard selftest FAILED */
1539 case KEYB_R_DIAGBAD: /* keyboard self diagnostic failure */
1540 case KEYB_R_RESEND: /* keyboard wants us to resend cmnd */
1541 case KEYB_R_OVERRUN1: /* keyboard buffer overflow */
1544 case KEYB_R_EXT1: /* keyboard extended scancode pfx 2 */
1545 kbd_status.ext1 = 1;
1547 case KEYB_R_EXT0: /* keyboard extended scancode pfx 1 */
1548 kbd_status.extended = 1;
1551 #if PCVT_SCANSET == 2
1552 case KEYB_R_BREAKPFX: /* break code prefix for set 2 and 3 */
1553 kbd_status.breakseen = 1;
1555 #endif /* PCVT_SCANSET == 2 */
1558 goto regular; /* regular key */
1566 /* got a normal scan key */
1569 #if PCVT_FREEBSD > 210
1570 add_keyboard_randomness(dt);
1571 #endif /* PCVT_FREEBSD > 210 */
1573 #if PCVT_SCANSET == 1
1574 kbd_status.breakseen = dt & 0x80 ? 1 : 0;
1576 #endif /* PCVT_SCANSET == 1 */
1578 /* make a keycode from scan code */
1579 if(dt >= sizeof scantokey / sizeof(u_char))
1582 key = kbd_status.extended ? extscantokey[dt] : scantokey[dt];
1584 if(kbd_status.ext1 && key == 64)
1585 /* virtual control key */
1588 kbd_status.extended = kbd_status.ext1 = 0;
1590 if ((key == 85) && shift_down && kbd_lastkey != 85)
1592 if (vsp->scr_offset > (vsp->screen_rows - 1))
1594 if (!vsp->scrolling)
1596 vsp->scrolling += vsp->screen_rows - 2;
1597 if (vsp->Scrollback)
1599 scrollback_save_screen();
1600 if (vsp->scr_offset == vsp->max_off)
1602 bcopy(vsp->Scrollback +
1606 vsp->max_off * CHR);
1609 bcopy(vsp->Crtat + vsp->cur_offset -
1610 vsp->col, vsp->Scrollback +
1611 ((vsp->scr_offset + 1) *
1612 vsp->maxcol), vsp->maxcol * CHR);
1619 vsp->scrolling += vsp->screen_rows - 1;
1621 if (vsp->scrolling > vsp->scr_offset)
1622 vsp->scrolling = vsp->scr_offset;
1624 bcopy(vsp->Scrollback + ((vsp->scr_offset -
1625 vsp->scrolling) * vsp->maxcol), vsp->Crtat,
1626 vsp->screen_rows * vsp->maxcol * CHR);
1632 else if ((key == 86) && shift_down && kbd_lastkey != 86)
1636 if (vsp->scrolling > 0)
1638 vsp->scrolling -= vsp->screen_rows - 1;
1639 if (vsp->scrolling < 0)
1642 if (vsp->scrolling <= vsp->screen_rows)
1645 scrollback_restore_screen();
1649 bcopy(vsp->Scrollback + ((vsp->scr_offset -
1650 vsp->scrolling) * vsp->maxcol),
1651 vsp->Crtat, vsp->screen_rows *
1656 if (vsp->scrolling == 0)
1664 if (noblock == 31337)
1677 else if (vsp->scrolling && key != 128 && key != 44 && key != 85 &&
1684 #if PCVT_CTRL_ALT_DEL /* Check for cntl-alt-del */
1685 if((key == 76) && ctrl_down && (meta_down||altgr_down))
1687 #endif /* PCVT_CTRL_ALT_DEL */
1689 #if !(PCVT_NETBSD || PCVT_FREEBSD >= 200)
1690 #include "use_ddb.h"
1691 #endif /* !(PCVT_NETBSD || PCVT_FREEBSD >= 200) */
1693 #if NDDB > 0 || defined(DDB) /* Check for cntl-alt-esc */
1695 if((key == 110) && ctrl_down && (meta_down || altgr_down))
1697 static u_char in_Debugger;
1703 /* the string is actually not used... */
1715 #endif /* NDDB > 0 || defined(DDB) */
1717 /* look for keys with special handling */
1721 * virtual shift; sent around PrtScr, and around the arrow
1722 * keys if the NumLck LED is on
1724 kbd_status.vshift = !kbd_status.breakseen;
1725 key = 0; /* no key */
1730 * virtual control - the most ugly thingie at all
1731 * the Pause key sends:
1732 * <virtual control make> <numlock make> <virtual control
1733 * break> <numlock break>
1735 if(!kbd_status.breakseen)
1736 kbd_status.vcontrol = 1;
1737 /* else: let the numlock hook clear this */
1738 key = 0; /* no key */
1742 /* NumLock, look whether this is rather a Pause */
1743 if(kbd_status.vcontrol)
1746 * if this is the final break code of a Pause key,
1747 * clear the virtual control status, too
1749 if(kbd_status.vcontrol && kbd_status.breakseen)
1750 kbd_status.vcontrol = 0;
1755 * a SysRq; some keyboards are brain-dead enough to
1756 * repeat the SysRq key make code by sending PrtScr
1757 * make codes; other keyboards do not repeat SysRq
1758 * at all. We keep track of the SysRq state here.
1760 kbd_status.sysrq = !kbd_status.breakseen;
1765 * PrtScr; look whether this is really PrtScr or rather
1766 * a silly repeat of a SysRq key
1768 if(kbd_status.sysrq)
1769 /* ignore the garbage */
1773 /* in NOREPEAT MODE ignore the key if it was the same as before */
1775 if(!kbrepflag && key == kbd_lastkey && !kbd_status.breakseen)
1783 type = key2ascii[key].type;
1785 if(type & KBD_OVERLOAD)
1786 type = ovltbl[key2ascii[key].ovlindex].type;
1793 if(!kbd_status.breakseen && key != kbd_lastkey)
1795 vsp->shift_lock ^= 1;
1800 if(!kbd_status.breakseen && key != kbd_lastkey)
1802 vsp->caps_lock ^= 1;
1808 if(!kbd_status.breakseen && key != kbd_lastkey)
1810 vsp->scroll_lock ^= 1;
1813 if(!(vsp->scroll_lock))
1815 /* someone may be sleeping */
1816 wakeup((caddr_t)&(vsp->scroll_lock));
1822 shift_down = kbd_status.breakseen ? 0 : 1;
1826 meta_down = kbd_status.breakseen ? 0 : 0x80;
1830 altgr_down = kbd_status.breakseen ? 0 : 1;
1834 ctrl_down = kbd_status.breakseen ? 0 : 1;
1839 break; /* deliver a key */
1842 if(kbd_status.breakseen)
1845 kbd_status.breakseen = 0;
1846 kbd_lastkey = 0; /* -hv- I know this is a bug with */
1847 } /* N-Key-Rollover, but I ignore that */
1848 else /* because avoidance is too complicated */
1851 cp = xlatkey2ascii(key); /* have a key */
1853 if(cp == NULL && !noblock)
1859 /*---------------------------------------------------------------------------*
1860 * reflect status of locking keys & set led's
1861 *---------------------------------------------------------------------------*/
1863 setlockkeys(int snc)
1865 vsp->scroll_lock = snc & 1;
1866 vsp->num_lock = (snc & 2) ? 1 : 0;
1867 vsp->caps_lock = (snc & 4) ? 1 : 0;
1871 /*---------------------------------------------------------------------------*
1872 * remove a key definition
1873 *---------------------------------------------------------------------------*/
1879 if(key==0 || key > MAXKEYNUM)
1882 if(key2ascii[key].type & KBD_OVERLOAD)
1884 ref = &ovltbl[key2ascii[key].ovlindex];
1891 key2ascii[key].type &= KBD_MASK;
1896 /*---------------------------------------------------------------------------*
1898 *---------------------------------------------------------------------------*/
1900 setkeydef(Ovl_tbl *data)
1904 if( data->keynum > MAXKEYNUM ||
1905 (data->type & KBD_MASK) == KBD_BREAK ||
1906 (data->type & KBD_MASK) > KBD_SHFTLOCK)
1909 data->unshift[KBDMAXOVLKEYSIZE] =
1910 data->shift[KBDMAXOVLKEYSIZE] =
1911 data->ctrl[KBDMAXOVLKEYSIZE] =
1912 data->altgr[KBDMAXOVLKEYSIZE] = 0;
1917 data->suba = KBD_SUBT_STR; /* just strings .. */
1919 data->type |= KBD_OVERLOAD; /* mark overloaded */
1921 /* if key already overloaded, use that slot else find free slot */
1923 if(key2ascii[data->keynum].type & KBD_OVERLOAD)
1925 i = key2ascii[data->keynum].ovlindex;
1929 for(i=0; i<OVLTBL_SIZE; i++)
1930 if(ovltbl[i].keynum==0)
1934 return ENOSPC; /* no space, abuse of ENOSPC(!) */
1937 ovltbl[i] = *data; /* copy new data string */
1939 key2ascii[data->keynum].type |= KBD_OVERLOAD; /* mark key */
1940 key2ascii[data->keynum].ovlindex = i;
1945 /*---------------------------------------------------------------------------*
1946 * keyboard ioctl's entry
1947 *---------------------------------------------------------------------------*/
1949 kbdioctl(Dev_t dev, int cmd, caddr_t data, int flag)
1958 settpmrate(KBD_TPD500|KBD_TPM100);
1963 *(int *)data = tpmrate;
1967 settpmrate(*(int *)data);
1971 *(int *)data = kbrepflag;
1975 kbrepflag = (*(int *)data) & 1;
1979 *(int *)data = ledstate;
1983 update_led(); /* ? */
1987 *(int *)data = ( (vsp->scroll_lock) |
1988 (vsp->num_lock * 2) |
1989 (vsp->caps_lock * 4));
1993 setlockkeys(*(int *)data);
1997 key = ((Ovl_tbl *)data)->keynum;
1998 return getckeydef(key,(Ovl_tbl *)data);
2001 key = ((Ovl_tbl *)data)->keynum;
2002 return setkeydef((Ovl_tbl *)data);
2005 key = ((Ovl_tbl *)data)->keynum;
2006 return getokeydef(key,(Ovl_tbl *)data);
2010 return rmkeydef(key);
2017 /* proceed with vga ioctls */
2024 /*--------------------------------------------------------------------------*
2025 * mouse emulator ioctl
2026 *--------------------------------------------------------------------------*/
2028 mouse_ioctl(Dev_t dev, int cmd, caddr_t data)
2030 struct mousedefs *def = (struct mousedefs *)data;
2047 #endif /* PCVT_EMU_MOUSE */
2049 #if PCVT_USL_VT_COMPAT
2050 /*---------------------------------------------------------------------------*
2051 * convert ISO-8859 style keycode into IBM 437
2052 *---------------------------------------------------------------------------*/
2053 static __inline u_char
2058 return iso2ibm437[c - 0x80];
2061 /*---------------------------------------------------------------------------*
2062 * build up a USL style keyboard map
2063 *---------------------------------------------------------------------------*/
2065 get_usl_keymap(keymap_t *map)
2069 bzero((caddr_t)map, sizeof(keymap_t));
2071 map->n_keys = 0x59; /* that many keys we know about */
2073 for(i = 1; i < N_KEYNUMS; i++)
2078 int idx = key2scan1[i];
2080 if(idx == 0 || idx >= map->n_keys)
2083 getckeydef(i, &kdef);
2084 kdef.type &= KBD_MASK;
2089 map->key[idx].map[0] = iso2ibm(kdef.unshift[0]);
2090 map->key[idx].map[1] = iso2ibm(kdef.shift[0]);
2091 map->key[idx].map[2] = map->key[idx].map[3] =
2092 iso2ibm(kdef.ctrl[0]);
2093 map->key[idx].map[4] = map->key[idx].map[5] =
2094 iso2ibm(c = kdef.altgr[0]);
2096 * XXX this is a hack
2097 * since we currently do not map strings to AltGr +
2098 * shift, we attempt to use the unshifted AltGr
2099 * definition here and try to toggle the case
2100 * this should at least work for ISO8859 letters,
2101 * but also for (e.g.) russian KOI-8 style
2103 if((c & 0x7f) >= 0x40)
2104 map->key[idx].map[5] = iso2ibm(c ^ 0x20);
2108 /* we are only interested in F1 thru F12 here */
2109 if(i >= 112 && i <= 123) {
2110 map->key[idx].map[0] = i - 112 + 27;
2111 map->key[idx].spcl = 0x80;
2116 c = i == 44? 2 /* lSh */: 3 /* rSh */; goto special;
2119 c = 4; goto special;
2122 c = 5; goto special;
2125 c = 6; goto special;
2128 c = 7; goto special;
2131 c = 9; goto special;
2133 for(j = 0; j < NUM_STATES; j++)
2134 map->key[idx].map[j] = c;
2135 map->key[idx].spcl = 0xff;
2144 #endif /* PCVT_USL_VT_COMPAT */
2146 /*---------------------------------------------------------------------------*
2147 * switch keypad to numeric mode
2148 *---------------------------------------------------------------------------*/
2150 vt_keynum(struct video_state *svsp)
2156 /*---------------------------------------------------------------------------*
2157 * switch keypad to application mode
2158 *---------------------------------------------------------------------------*/
2160 vt_keyappl(struct video_state *svsp)
2166 #if !PCVT_VT220KEYB /* !PCVT_VT220KEYB, HP-like Keyboard layout */
2168 /*---------------------------------------------------------------------------*
2169 * function bound to function key 1
2170 *---------------------------------------------------------------------------*/
2176 if((vsp->vt_pure_mode == M_HPVT)
2177 && (vsp->which_fkl == SYS_FKL))
2180 more_chars = (u_char *)"\033[17~"; /* F6 */
2184 if(vsp->vt_pure_mode == M_PUREVT
2185 || (vsp->which_fkl == USR_FKL))
2186 more_chars = (u_char *)"\033[26~"; /* F14 */
2190 /*---------------------------------------------------------------------------*
2191 * function bound to function key 2
2192 *---------------------------------------------------------------------------*/
2198 if((vsp->vt_pure_mode == M_HPVT)
2199 && (vsp->which_fkl == SYS_FKL))
2202 more_chars = (u_char *)"\033[18~"; /* F7 */
2206 if(vsp->vt_pure_mode == M_PUREVT
2207 || (vsp->which_fkl == USR_FKL))
2208 more_chars = (u_char *)"\033[28~"; /* HELP */
2212 /*---------------------------------------------------------------------------*
2213 * function bound to function key 3
2214 *---------------------------------------------------------------------------*/
2220 if((vsp->vt_pure_mode == M_HPVT)
2221 && (vsp->which_fkl == SYS_FKL))
2224 more_chars = (u_char *)"\033[19~"; /* F8 */
2228 if(vsp->vt_pure_mode == M_PUREVT
2229 || (vsp->which_fkl == USR_FKL))
2230 more_chars = (u_char *)"\033[29~"; /* DO */
2234 /*---------------------------------------------------------------------------*
2235 * function bound to function key 4
2236 *---------------------------------------------------------------------------*/
2244 if((vsp->vt_pure_mode == M_HPVT)
2245 && (vsp->which_fkl == SYS_FKL))
2248 more_chars = (u_char *)"\033[20~"; /* F9 */
2250 if(vsp->vt_pure_mode == M_PUREVT
2251 || (vsp->which_fkl == USR_FKL))
2252 more_chars = (u_char *)"\033[20~"; /* F9 */
2253 #endif /* PCVT_SHOWKEYS */
2258 if(vsp->vt_pure_mode == M_PUREVT
2259 || (vsp->which_fkl == USR_FKL))
2260 more_chars = (u_char *)"\033[31~"; /* F17 */
2264 /*---------------------------------------------------------------------------*
2265 * function bound to function key 5
2266 *---------------------------------------------------------------------------*/
2272 if((vsp->vt_pure_mode == M_HPVT)
2273 && (vsp->which_fkl == SYS_FKL))
2276 more_chars = (u_char *)"\033[21~"; /* F10 */
2280 if(vsp->vt_pure_mode == M_PUREVT
2281 || (vsp->which_fkl == USR_FKL))
2282 more_chars = (u_char *)"\033[32~"; /* F18 */
2286 /*---------------------------------------------------------------------------*
2287 * function bound to function key 6
2288 *---------------------------------------------------------------------------*/
2294 if((vsp->vt_pure_mode == M_HPVT)
2295 && (vsp->which_fkl == SYS_FKL))
2296 toggl_sevenbit(vsp);
2298 more_chars = (u_char *)"\033[23~"; /* F11 */
2302 if(vsp->vt_pure_mode == M_PUREVT
2303 || (vsp->which_fkl == USR_FKL))
2304 more_chars = (u_char *)"\033[33~"; /* F19 */
2308 /*---------------------------------------------------------------------------*
2309 * function bound to function key 7
2310 *---------------------------------------------------------------------------*/
2316 if((vsp->vt_pure_mode == M_HPVT)
2317 && (vsp->which_fkl == SYS_FKL))
2320 more_chars = (u_char *)"\033[24~"; /* F12 */
2324 if(vsp->vt_pure_mode == M_PUREVT
2325 || (vsp->which_fkl == USR_FKL))
2326 more_chars = (u_char *)"\033[34~"; /* F20 */
2330 /*---------------------------------------------------------------------------*
2331 * function bound to function key 8
2332 *---------------------------------------------------------------------------*/
2338 if((vsp->vt_pure_mode == M_HPVT)
2339 && (vsp->which_fkl == SYS_FKL))
2342 more_chars = (u_char *)"\033[25~"; /* F13 */
2346 if(vsp->vt_pure_mode == M_PUREVT
2347 || (vsp->which_fkl == USR_FKL))
2348 more_chars = (u_char *)"\033[35~"; /* F21 ? !! */
2352 /*---------------------------------------------------------------------------*
2353 * function bound to function key 9
2354 *---------------------------------------------------------------------------*/
2360 if(vsp->vt_pure_mode == M_PUREVT)
2363 if(vsp->labels_on) /* toggle label display on/off */
2374 /*---------------------------------------------------------------------------*
2375 * function bound to function key 10
2376 *---------------------------------------------------------------------------*/
2382 if(vsp->vt_pure_mode != M_PUREVT && vsp->labels_on)
2384 if(vsp->which_fkl == USR_FKL)
2386 else if(vsp->which_fkl == SYS_FKL)
2396 /*---------------------------------------------------------------------------*
2397 * function bound to function key 11
2398 *---------------------------------------------------------------------------*/
2404 if(vsp->vt_pure_mode == M_PUREVT)
2405 set_emulation_mode(vsp, M_HPVT);
2406 else if(vsp->vt_pure_mode == M_HPVT)
2407 set_emulation_mode(vsp, M_PUREVT);
2415 /*---------------------------------------------------------------------------*
2416 * function bound to function key 12
2417 *---------------------------------------------------------------------------*/
2423 if(current_video_screen + 1 > totalscreens-1)
2426 do_vgapage(current_video_screen + 1);
2434 /*---------------------------------------------------------------------------*
2435 * function bound to SHIFTED function key 1
2436 *---------------------------------------------------------------------------*/
2442 if(vsp->ukt.length[0]) /* entry available ? */
2443 more_chars = (u_char *)
2444 &(vsp->udkbuf[vsp->ukt.first[0]]);
2448 if(vsp->ukt.length[9]) /* entry available ? */
2449 more_chars = (u_char *)
2450 &(vsp->udkbuf[vsp->ukt.first[9]]);
2454 /*---------------------------------------------------------------------------*
2455 * function bound to SHIFTED function key 2
2456 *---------------------------------------------------------------------------*/
2462 if(vsp->ukt.length[1]) /* entry available ? */
2463 more_chars = (u_char *)
2464 &(vsp->udkbuf[vsp->ukt.first[1]]);
2468 if(vsp->ukt.length[11]) /* entry available ? */
2469 more_chars = (u_char *)
2470 &(vsp->udkbuf[vsp->ukt.first[11]]);
2474 /*---------------------------------------------------------------------------*
2475 * function bound to SHIFTED function key 3
2476 *---------------------------------------------------------------------------*/
2482 if(vsp->ukt.length[2]) /* entry available ? */
2483 more_chars = (u_char *)
2484 &(vsp->udkbuf[vsp->ukt.first[2]]);
2488 if(vsp->ukt.length[12]) /* entry available ? */
2489 more_chars = (u_char *)
2490 &(vsp->udkbuf[vsp->ukt.first[12]]);
2494 /*---------------------------------------------------------------------------*
2495 * function bound to SHIFTED function key 4
2496 *---------------------------------------------------------------------------*/
2502 if(vsp->ukt.length[3]) /* entry available ? */
2503 more_chars = (u_char *)
2504 &(vsp->udkbuf[vsp->ukt.first[3]]);
2508 if(vsp->ukt.length[13]) /* entry available ? */
2509 more_chars = (u_char *)
2510 &(vsp->udkbuf[vsp->ukt.first[13]]);
2514 /*---------------------------------------------------------------------------*
2515 * function bound to SHIFTED function key 5
2516 *---------------------------------------------------------------------------*/
2522 if(vsp->ukt.length[4]) /* entry available ? */
2523 more_chars = (u_char *)
2524 &(vsp->udkbuf[vsp->ukt.first[4]]);
2528 if(vsp->ukt.length[14]) /* entry available ? */
2529 more_chars = (u_char *)
2530 &(vsp->udkbuf[vsp->ukt.first[14]]);
2534 /*---------------------------------------------------------------------------*
2535 * function bound to SHIFTED function key 6
2536 *---------------------------------------------------------------------------*/
2542 if(vsp->ukt.length[6]) /* entry available ? */
2543 more_chars = (u_char *)
2544 &(vsp->udkbuf[vsp->ukt.first[6]]);
2548 if(vsp->ukt.length[15]) /* entry available ? */
2549 more_chars = (u_char *)
2550 &(vsp->udkbuf[vsp->ukt.first[15]]);
2554 /*---------------------------------------------------------------------------*
2555 * function bound to SHIFTED function key 7
2556 *---------------------------------------------------------------------------*/
2562 if(vsp->ukt.length[7]) /* entry available ? */
2563 more_chars = (u_char *)
2564 &(vsp->udkbuf[vsp->ukt.first[7]]);
2568 if(vsp->ukt.length[16]) /* entry available ? */
2569 more_chars = (u_char *)
2570 &(vsp->udkbuf[vsp->ukt.first[16]]);
2574 /*---------------------------------------------------------------------------*
2575 * function bound to SHIFTED function key 8
2576 *---------------------------------------------------------------------------*/
2582 if(vsp->ukt.length[8]) /* entry available ? */
2583 more_chars = (u_char *)
2584 &(vsp->udkbuf[vsp->ukt.first[8]]);
2588 if(vsp->ukt.length[17]) /* entry available ? */
2589 more_chars = (u_char *)
2590 &(vsp->udkbuf[vsp->ukt.first[17]]);
2593 /*---------------------------------------------------------------------------*
2594 * function bound to SHIFTED function key 9
2595 *---------------------------------------------------------------------------*/
2601 /*---------------------------------------------------------------------------*
2602 * function bound to SHIFTED function key 10
2603 *---------------------------------------------------------------------------*/
2609 /*---------------------------------------------------------------------------*
2610 * function bound to SHIFTED function key 11
2611 *---------------------------------------------------------------------------*/
2617 /*---------------------------------------------------------------------------*
2618 * function bound to SHIFTED function key 12
2619 *---------------------------------------------------------------------------*/
2625 /*---------------------------------------------------------------------------*
2626 * function bound to control function key 1
2627 *---------------------------------------------------------------------------*/
2635 /*---------------------------------------------------------------------------*
2636 * function bound to control function key 2
2637 *---------------------------------------------------------------------------*/
2645 /*---------------------------------------------------------------------------*
2646 * function bound to control function key 3
2647 *---------------------------------------------------------------------------*/
2655 /*---------------------------------------------------------------------------*
2656 * function bound to control function key 4
2657 *---------------------------------------------------------------------------*/
2665 /*---------------------------------------------------------------------------*
2666 * function bound to control function key 5
2667 *---------------------------------------------------------------------------*/
2675 /*---------------------------------------------------------------------------*
2676 * function bound to control function key 6
2677 *---------------------------------------------------------------------------*/
2685 /*---------------------------------------------------------------------------*
2686 * function bound to control function key 7
2687 *---------------------------------------------------------------------------*/
2695 /*---------------------------------------------------------------------------*
2696 * function bound to control function key 8
2697 *---------------------------------------------------------------------------*/
2705 /*---------------------------------------------------------------------------*
2706 * function bound to control function key 9
2707 *---------------------------------------------------------------------------*/
2715 /*---------------------------------------------------------------------------*
2716 * function bound to control function key 10
2717 *---------------------------------------------------------------------------*/
2725 /*---------------------------------------------------------------------------*
2726 * function bound to control function key 11
2727 *---------------------------------------------------------------------------*/
2735 /*---------------------------------------------------------------------------*
2736 * function bound to control function key 12
2737 *---------------------------------------------------------------------------*/
2745 #else /* PCVT_VT220 - VT220-like Keyboard layout */
2747 /*---------------------------------------------------------------------------*
2748 * function bound to function key 1
2749 *---------------------------------------------------------------------------*/
2754 more_chars = (u_char *)"\033[23~"; /* F11 */
2759 /*---------------------------------------------------------------------------*
2760 * function bound to function key 2
2761 *---------------------------------------------------------------------------*/
2766 more_chars = (u_char *)"\033[24~"; /* F12 */
2771 /*---------------------------------------------------------------------------*
2772 * function bound to function key 3
2773 *---------------------------------------------------------------------------*/
2778 more_chars = (u_char *)"\033[25~"; /* F13 */
2783 /*---------------------------------------------------------------------------*
2784 * function bound to function key 4
2785 *---------------------------------------------------------------------------*/
2790 more_chars = (u_char *)"\033[26~"; /* F14 */
2795 /*---------------------------------------------------------------------------*
2796 * function bound to function key 5
2797 *---------------------------------------------------------------------------*/
2802 more_chars = (u_char *)"\033[28~"; /* Help */
2805 if((current_video_screen + 1) > totalscreens-1)
2808 do_vgapage(current_video_screen + 1);
2812 /*---------------------------------------------------------------------------*
2813 * function bound to function key 6
2814 *---------------------------------------------------------------------------*/
2819 more_chars = (u_char *)"\033[29~"; /* DO */
2821 more_chars = (u_char *)"\033[17~"; /* F6 */
2824 /*---------------------------------------------------------------------------*
2825 * function bound to function key 7
2826 *---------------------------------------------------------------------------*/
2831 more_chars = (u_char *)"\033[31~"; /* F17 */
2833 more_chars = (u_char *)"\033[18~"; /* F7 */
2836 /*---------------------------------------------------------------------------*
2837 * function bound to function key 8
2838 *---------------------------------------------------------------------------*/
2843 more_chars = (u_char *)"\033[32~"; /* F18 */
2845 more_chars = (u_char *)"\033[19~"; /* F8 */
2848 /*---------------------------------------------------------------------------*
2849 * function bound to function key 9
2850 *---------------------------------------------------------------------------*/
2855 more_chars = (u_char *)"\033[33~"; /* F19 */
2857 more_chars = (u_char *)"\033[20~"; /* F9 */
2860 /*---------------------------------------------------------------------------*
2861 * function bound to function key 10
2862 *---------------------------------------------------------------------------*/
2867 more_chars = (u_char *)"\033[34~"; /* F20 */
2869 more_chars = (u_char *)"\033[21~"; /* F10 */
2872 /*---------------------------------------------------------------------------*
2873 * function bound to function key 11
2874 *---------------------------------------------------------------------------*/
2879 more_chars = (u_char *)"\0x8FP"; /* PF1 */
2881 more_chars = (u_char *)"\033[23~"; /* F11 */
2884 /*---------------------------------------------------------------------------*
2885 * function bound to function key 12
2886 *---------------------------------------------------------------------------*/
2891 more_chars = (u_char *)"\0x8FQ"; /* PF2 */
2893 more_chars = (u_char *)"\033[24~"; /* F12 */
2896 /*---------------------------------------------------------------------------*
2897 * function bound to SHIFTED function key 1
2898 *---------------------------------------------------------------------------*/
2904 if(vsp->ukt.length[6]) /* entry available ? */
2905 more_chars = (u_char *)
2906 &(vsp->udkbuf[vsp->ukt.first[6]]);
2908 more_chars = (u_char *)"\033[23~"; /* F11 */
2916 /*---------------------------------------------------------------------------*
2917 * function bound to SHIFTED function key 2
2918 *---------------------------------------------------------------------------*/
2924 if(vsp->ukt.length[7]) /* entry available ? */
2925 more_chars = (u_char *)
2926 &(vsp->udkbuf[vsp->ukt.first[7]]);
2928 more_chars = (u_char *)"\033[24~"; /* F12 */
2936 /*---------------------------------------------------------------------------*
2937 * function bound to SHIFTED function key 3
2938 *---------------------------------------------------------------------------*/
2944 if(vsp->ukt.length[8]) /* entry available ? */
2945 more_chars = (u_char *)
2946 &(vsp->udkbuf[vsp->ukt.first[8]]);
2948 more_chars = (u_char *)"\033[25~"; /* F13 */
2956 /*---------------------------------------------------------------------------*
2957 * function bound to SHIFTED function key 4
2958 *---------------------------------------------------------------------------*/
2964 if(vsp->ukt.length[9]) /* entry available ? */
2965 more_chars = (u_char *)
2966 &(vsp->udkbuf[vsp->ukt.first[9]]);
2968 more_chars = (u_char *)"\033[26~"; /* F14 */
2976 /*---------------------------------------------------------------------------*
2977 * function bound to SHIFTED function key 5
2978 *---------------------------------------------------------------------------*/
2984 if(vsp->ukt.length[11]) /* entry available ? */
2985 more_chars = (u_char *)
2986 &(vsp->udkbuf[vsp->ukt.first[11]]);
2988 more_chars = (u_char *)"\033[28~"; /* Help */
2992 if(current_video_screen <= 0)
2993 do_vgapage(totalscreens-1);
2995 do_vgapage(current_video_screen - 1);
2999 /*---------------------------------------------------------------------------*
3000 * function bound to SHIFTED function key 6
3001 *---------------------------------------------------------------------------*/
3007 if(vsp->ukt.length[0]) /* entry available ? */
3008 more_chars = (u_char *)
3009 &(vsp->udkbuf[vsp->ukt.first[0]]);
3011 more_chars = (u_char *)"\033[17~"; /* F6 */
3013 else if(vsp->ukt.length[12]) /* entry available ? */
3014 more_chars = (u_char *)
3015 &(vsp->udkbuf[vsp->ukt.first[12]]);
3017 more_chars = (u_char *)"\033[29~"; /* DO */
3020 /*---------------------------------------------------------------------------*
3021 * function bound to SHIFTED function key 7
3022 *---------------------------------------------------------------------------*/
3028 if(vsp->ukt.length[1]) /* entry available ? */
3029 more_chars = (u_char *)
3030 &(vsp->udkbuf[vsp->ukt.first[1]]);
3032 more_chars = (u_char *)"\033[18~"; /* F7 */
3034 else if(vsp->ukt.length[14]) /* entry available ? */
3035 more_chars = (u_char *)
3036 &(vsp->udkbuf[vsp->ukt.first[14]]);
3038 more_chars = (u_char *)"\033[31~"; /* F17 */
3041 /*---------------------------------------------------------------------------*
3042 * function bound to SHIFTED function key 8
3043 *---------------------------------------------------------------------------*/
3049 if(vsp->ukt.length[2]) /* entry available ? */
3050 more_chars = (u_char *)
3051 &(vsp->udkbuf[vsp->ukt.first[2]]);
3053 more_chars = (u_char *)"\033[19~"; /* F8 */
3055 else if(vsp->ukt.length[14]) /* entry available ? */
3056 more_chars = (u_char *)
3057 &(vsp->udkbuf[vsp->ukt.first[15]]);
3059 more_chars = (u_char *)"\033[32~"; /* F18 */
3062 /*---------------------------------------------------------------------------*
3063 * function bound to SHIFTED function key 9
3064 *---------------------------------------------------------------------------*/
3070 if(vsp->ukt.length[3]) /* entry available ? */
3071 more_chars = (u_char *)
3072 &(vsp->udkbuf[vsp->ukt.first[3]]);
3074 more_chars = (u_char *)"\033[20~"; /* F9 */
3076 else if(vsp->ukt.length[16]) /* entry available ? */
3077 more_chars = (u_char *)
3078 &(vsp->udkbuf[vsp->ukt.first[16]]);
3080 more_chars = (u_char *)"\033[33~"; /* F19 */
3083 /*---------------------------------------------------------------------------*
3084 * function bound to SHIFTED function key 10
3085 *---------------------------------------------------------------------------*/
3091 if(vsp->ukt.length[4]) /* entry available ? */
3092 more_chars = (u_char *)
3093 &(vsp->udkbuf[vsp->ukt.first[4]]);
3095 more_chars = (u_char *)"\033[21~"; /* F10 */
3097 else if(vsp->ukt.length[17]) /* entry available ? */
3098 more_chars = (u_char *)
3099 &(vsp->udkbuf[vsp->ukt.first[17]]);
3101 more_chars = (u_char *)"\033[34~"; /* F20 */
3104 /*---------------------------------------------------------------------------*
3105 * function bound to SHIFTED function key 11
3106 *---------------------------------------------------------------------------*/
3112 if(vsp->ukt.length[6]) /* entry available ? */
3113 more_chars = (u_char *)
3114 &(vsp->udkbuf[vsp->ukt.first[6]]);
3116 more_chars = (u_char *)"\033[23~"; /* F11 */
3120 /*---------------------------------------------------------------------------*
3121 * function bound to SHIFTED function key 12
3122 *---------------------------------------------------------------------------*/
3128 if(vsp->ukt.length[7]) /* entry available ? */
3129 more_chars = (u_char *)
3130 &(vsp->udkbuf[vsp->ukt.first[7]]);
3132 more_chars = (u_char *)"\033[24~"; /* F12 */
3136 /*---------------------------------------------------------------------------*
3137 * function bound to control function key 1
3138 *---------------------------------------------------------------------------*/
3142 if(vsp->which_fkl == SYS_FKL)
3146 /*---------------------------------------------------------------------------*
3147 * function bound to control function key 2
3148 *---------------------------------------------------------------------------*/
3152 if(vsp->which_fkl == SYS_FKL)
3156 /*---------------------------------------------------------------------------*
3157 * function bound to control function key 3
3158 *---------------------------------------------------------------------------*/
3162 if(vsp->which_fkl == SYS_FKL)
3166 /*---------------------------------------------------------------------------*
3167 * function bound to control function key 4
3168 *---------------------------------------------------------------------------*/
3174 if(vsp->which_fkl == SYS_FKL)
3176 #endif /* PCVT_SHOWKEYS */
3180 /*---------------------------------------------------------------------------*
3181 * function bound to control function key 5
3182 *---------------------------------------------------------------------------*/
3186 if(vsp->which_fkl == SYS_FKL)
3190 /*---------------------------------------------------------------------------*
3191 * function bound to control function key 6
3192 *---------------------------------------------------------------------------*/
3196 if(vsp->which_fkl == SYS_FKL)
3197 toggl_sevenbit(vsp);
3200 /*---------------------------------------------------------------------------*
3201 * function bound to control function key 7
3202 *---------------------------------------------------------------------------*/
3206 if(vsp->which_fkl == SYS_FKL)
3210 /*---------------------------------------------------------------------------*
3211 * function bound to control function key 8
3212 *---------------------------------------------------------------------------*/
3216 if(vsp->which_fkl == SYS_FKL)
3220 /*---------------------------------------------------------------------------*
3221 * function bound to control function key 9
3222 *---------------------------------------------------------------------------*/
3226 if(vsp->labels_on) /* toggle label display on/off */
3232 /*---------------------------------------------------------------------------*
3233 * function bound to control function key 10
3234 *---------------------------------------------------------------------------*/
3238 if(vsp->labels_on) /* toggle user/system fkey labels */
3240 if(vsp->which_fkl == USR_FKL)
3242 else if(vsp->which_fkl == SYS_FKL)
3247 /*---------------------------------------------------------------------------*
3248 * function bound to control function key 11
3249 *---------------------------------------------------------------------------*/
3253 if(vsp->vt_pure_mode == M_PUREVT)
3254 set_emulation_mode(vsp, M_HPVT);
3255 else if(vsp->vt_pure_mode == M_HPVT)
3256 set_emulation_mode(vsp, M_PUREVT);
3259 /*---------------------------------------------------------------------------*
3260 * function bound to control function key 12
3261 *---------------------------------------------------------------------------*/
3267 #endif /* PCVT_VT220KEYB */
3269 /*---------------------------------------------------------------------------*
3271 *---------------------------------------------------------------------------*/
3273 scrollback_save_screen(void)
3278 s = sizeof(u_short) * vsp->screen_rowsize * vsp->maxcol;
3280 if (scrollback_savedscreen)
3281 free(scrollback_savedscreen, M_TEMP);
3285 if (!(scrollback_savedscreen = (u_short *)malloc(s, M_TEMP, M_NOWAIT)))
3290 bcopy(vsp->Crtat, scrollback_savedscreen, scrnsv_size);
3294 /*---------------------------------------------------------------------------*
3296 *---------------------------------------------------------------------------*/
3298 scrollback_restore_screen(void)
3300 if (scrollback_savedscreen)
3301 bcopy(scrollback_savedscreen, vsp->Crtat, scrnsv_size);
3305 #endif /* NVT > 0 */
3307 /* ------------------------------- EOF -------------------------------------*/