if (ch <= 0xFF) {
/* A normal character. */
buf[0] = ch;
- (void) in_process(tp, buf, 1);
+ (void) in_process(tp, buf, 1, scode);
} else
if (HOME <= ch && ch <= INSRT) {
/* An ASCII escape sequence generated by the numeric pad. */
buf[0] = ESC;
buf[1] = '[';
buf[2] = numpad_map[ch - HOME];
- (void) in_process(tp, buf, 3);
+ (void) in_process(tp, buf, 3, scode);
} else
if ((F1 <= ch && ch <= F12) || (SF1 <= ch && ch <= SF12) ||
(CF1 <= ch && ch <= CF12 && !debug_fkeys)) {
*p++ = suffix;
}
*p++ = '~';
- (void) in_process(tp, buf, p - buf);
+ (void) in_process(tp, buf, p - buf, scode);
} else
if (ch == ALEFT) {
/* Choose lower numbered console as current console. */
case CF8: sigchar(&tty_table[CONSOLE], SIGINT, 1); break;
case CF9: sigchar(&tty_table[CONSOLE], SIGKILL, 1); break;
}
+ } else {
+ /* pass on scancode even though there is no character code */
+ (void) in_process(tp, NULL, 0, scode);
}
}
}
/* Input processing. */
- if (in_process(tp, &c, 1) == 0) break;
+ if (in_process(tp, &c, 1, -1) == 0) break;
/* PTY writer bookkeeping. */
pp->wrcum++;
if (count > icount) count = icount;
/* Perform input processing on (part of) the input buffer. */
- if ((count = in_process(tp, rs->itail, count)) == 0) break;
+ if ((count = in_process(tp, rs->itail, count, -1)) == 0) break;
lock(); /* protect interrupt sensitive variables */
rs->icount -= count;
/*===========================================================================*
* in_process *
*===========================================================================*/
-PUBLIC int in_process(tp, buf, count)
+PRIVATE void in_process_send_byte(tp, ch)
+tty_t *tp; /* terminal on which character has arrived */
+int ch; /* input character */
+{
+ /* Save the character in the input queue. */
+ *tp->tty_inhead++ = ch;
+ if (tp->tty_inhead == bufend(tp->tty_inbuf))
+ tp->tty_inhead = tp->tty_inbuf;
+ tp->tty_incount++;
+ if (ch & IN_EOT) tp->tty_eotct++;
+
+ /* Try to finish input if the queue threatens to overflow. */
+ if (tp->tty_incount == buflen(tp->tty_inbuf)) in_transfer(tp);
+}
+
+PUBLIC int in_process(tp, buf, count, scode)
register tty_t *tp; /* terminal on which character has arrived */
char *buf; /* buffer with input characters */
int count; /* number of input characters */
+int scode; /* scan code */
{
/* Characters have just been typed in. Process, save, and echo them. Return
* the number of characters processed.
int ch, sig, ct;
int timeset = FALSE;
+ /* Send scancode if requested */
+ if (tp->tty_termios.c_iflag & SCANCODES) {
+ in_process_send_byte(tp, (scode & BYTE) | IN_EOT);
+ }
+
for (ct = 0; ct < count; ct++) {
/* Take one character. */
ch = *buf++ & BYTE;
/* Perform the intricate function of echoing. */
if (tp->tty_termios.c_lflag & (ECHO|ECHONL)) ch = tty_echo(tp, ch);
- /* Save the character in the input queue. */
- *tp->tty_inhead++ = ch;
- if (tp->tty_inhead == bufend(tp->tty_inbuf))
- tp->tty_inhead = tp->tty_inbuf;
- tp->tty_incount++;
- if (ch & IN_EOT) tp->tty_eotct++;
-
- /* Try to finish input if the queue threatens to overflow. */
- if (tp->tty_incount == buflen(tp->tty_inbuf)) in_transfer(tp);
+ /* Send processed byte of input unless scancodes sent instead */
+ if (!(tp->tty_termios.c_iflag & SCANCODES)) {
+ in_process_send_byte(tp, ch);
+ }
}
return ct;
}
/* Setting the output speed to zero hangs up the phone. */
if (tp->tty_termios.c_ospeed == B0) sigchar(tp, SIGHUP, 1);
+ /* SCANCODES is supported only for the console */
+ if (!isconsole(tp)) tp->tty_termios.c_iflag &= ~SCANCODES;
+
/* Set new line speed, character size, etc at the device level. */
(*tp->tty_ioctl)(tp, 0);
}
_PROTOTYPE( void handle_events, (struct tty *tp) );
_PROTOTYPE( void sigchar, (struct tty *tp, int sig, int mayflush) );
_PROTOTYPE( void tty_task, (void) );
-_PROTOTYPE( int in_process, (struct tty *tp, char *buf, int count) );
+_PROTOTYPE( int in_process, (struct tty *tp, char *buf, int count,
+ int scode) );
_PROTOTYPE( void out_process, (struct tty *tp, char *bstart, char *bpos,
char *bend, int *icount, int *ocount) );
_PROTOTYPE( void tty_wakeup, (clock_t now) );
/* Extensions to the termios c_iflag bit map. */
#define IXANY 0x0800 /* allow any key to continue ouptut */
+#define SCANCODES 0x1000 /* send scancodes */
/* Extensions to the termios c_oflag bit map. They are only active iff
* OPOST is enabled. */
.B PARMRK
is set as '\e377', '\e0', '\e0'.
(Breaks are always ignored.)
+.TP
+.B SCANCODES
+Send input as keyboard scancodes rather than processed ASCII characters. This
+flag only applies to consoles; to check whether the flag is supported use the
+.B tcgetattr
+function after setting it and test whether
+.B c_iflag
+still contains the
+.B SCANCODES
+flag. Scancodes are provided directly and without any processing. As a
+consequence, the
+.B ISTRIP
+,
+.B IGNCR
+,
+.B ICRNL
+,
+.B INLCR
+,
+.B ICANON
+and
+.B IEXTEN
+flags no longer influence input if this flag is specified. However, they may
+still influence echoing if enabled. (MINIX 3 specific.)
.SS "Output Modes"
The
.B c_oflag