Add scancode reading capability to TTY
This commit is contained in:
parent
32f43d7571
commit
7de730afe4
@ -591,14 +591,14 @@ int try;
|
|||||||
if (ch <= 0xFF) {
|
if (ch <= 0xFF) {
|
||||||
/* A normal character. */
|
/* A normal character. */
|
||||||
buf[0] = ch;
|
buf[0] = ch;
|
||||||
(void) in_process(tp, buf, 1);
|
(void) in_process(tp, buf, 1, scode);
|
||||||
} else
|
} else
|
||||||
if (HOME <= ch && ch <= INSRT) {
|
if (HOME <= ch && ch <= INSRT) {
|
||||||
/* An ASCII escape sequence generated by the numeric pad. */
|
/* An ASCII escape sequence generated by the numeric pad. */
|
||||||
buf[0] = ESC;
|
buf[0] = ESC;
|
||||||
buf[1] = '[';
|
buf[1] = '[';
|
||||||
buf[2] = numpad_map[ch - HOME];
|
buf[2] = numpad_map[ch - HOME];
|
||||||
(void) in_process(tp, buf, 3);
|
(void) in_process(tp, buf, 3, scode);
|
||||||
} else
|
} else
|
||||||
if ((F1 <= ch && ch <= F12) || (SF1 <= ch && ch <= SF12) ||
|
if ((F1 <= ch && ch <= F12) || (SF1 <= ch && ch <= SF12) ||
|
||||||
(CF1 <= ch && ch <= CF12 && !debug_fkeys)) {
|
(CF1 <= ch && ch <= CF12 && !debug_fkeys)) {
|
||||||
@ -626,7 +626,7 @@ int try;
|
|||||||
*p++ = suffix;
|
*p++ = suffix;
|
||||||
}
|
}
|
||||||
*p++ = '~';
|
*p++ = '~';
|
||||||
(void) in_process(tp, buf, p - buf);
|
(void) in_process(tp, buf, p - buf, scode);
|
||||||
} else
|
} else
|
||||||
if (ch == ALEFT) {
|
if (ch == ALEFT) {
|
||||||
/* Choose lower numbered console as current console. */
|
/* Choose lower numbered console as current console. */
|
||||||
@ -651,6 +651,9 @@ int try;
|
|||||||
case CF8: sigchar(&tty_table[CONSOLE], SIGINT, 1); break;
|
case CF8: sigchar(&tty_table[CONSOLE], SIGINT, 1); break;
|
||||||
case CF9: sigchar(&tty_table[CONSOLE], SIGKILL, 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ PRIVATE int pty_read(tty_t *tp, int try)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Input processing. */
|
/* Input processing. */
|
||||||
if (in_process(tp, &c, 1) == 0) break;
|
if (in_process(tp, &c, 1, -1) == 0) break;
|
||||||
|
|
||||||
/* PTY writer bookkeeping. */
|
/* PTY writer bookkeeping. */
|
||||||
pp->wrcum++;
|
pp->wrcum++;
|
||||||
|
@ -619,7 +619,7 @@ PRIVATE int rs_read(tty_t *tp, int try)
|
|||||||
if (count > icount) count = icount;
|
if (count > icount) count = icount;
|
||||||
|
|
||||||
/* Perform input processing on (part of) the input buffer. */
|
/* 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 */
|
lock(); /* protect interrupt sensitive variables */
|
||||||
rs->icount -= count;
|
rs->icount -= count;
|
||||||
|
@ -1036,10 +1036,26 @@ register tty_t *tp; /* pointer to terminal to read from */
|
|||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* in_process *
|
* 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 */
|
register tty_t *tp; /* terminal on which character has arrived */
|
||||||
char *buf; /* buffer with input characters */
|
char *buf; /* buffer with input characters */
|
||||||
int count; /* number of input characters */
|
int count; /* number of input characters */
|
||||||
|
int scode; /* scan code */
|
||||||
{
|
{
|
||||||
/* Characters have just been typed in. Process, save, and echo them. Return
|
/* Characters have just been typed in. Process, save, and echo them. Return
|
||||||
* the number of characters processed.
|
* the number of characters processed.
|
||||||
@ -1048,6 +1064,11 @@ int count; /* number of input characters */
|
|||||||
int ch, sig, ct;
|
int ch, sig, ct;
|
||||||
int timeset = FALSE;
|
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++) {
|
for (ct = 0; ct < count; ct++) {
|
||||||
/* Take one character. */
|
/* Take one character. */
|
||||||
ch = *buf++ & BYTE;
|
ch = *buf++ & BYTE;
|
||||||
@ -1180,15 +1201,10 @@ int count; /* number of input characters */
|
|||||||
/* Perform the intricate function of echoing. */
|
/* Perform the intricate function of echoing. */
|
||||||
if (tp->tty_termios.c_lflag & (ECHO|ECHONL)) ch = tty_echo(tp, ch);
|
if (tp->tty_termios.c_lflag & (ECHO|ECHONL)) ch = tty_echo(tp, ch);
|
||||||
|
|
||||||
/* Save the character in the input queue. */
|
/* Send processed byte of input unless scancodes sent instead */
|
||||||
*tp->tty_inhead++ = ch;
|
if (!(tp->tty_termios.c_iflag & SCANCODES)) {
|
||||||
if (tp->tty_inhead == bufend(tp->tty_inbuf))
|
in_process_send_byte(tp, ch);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
return ct;
|
return ct;
|
||||||
}
|
}
|
||||||
@ -1502,6 +1518,9 @@ tty_t *tp;
|
|||||||
/* Setting the output speed to zero hangs up the phone. */
|
/* Setting the output speed to zero hangs up the phone. */
|
||||||
if (tp->tty_termios.c_ospeed == B0) sigchar(tp, SIGHUP, 1);
|
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. */
|
/* Set new line speed, character size, etc at the device level. */
|
||||||
(*tp->tty_ioctl)(tp, 0);
|
(*tp->tty_ioctl)(tp, 0);
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,8 @@ extern struct kmessages kmess;
|
|||||||
_PROTOTYPE( void handle_events, (struct tty *tp) );
|
_PROTOTYPE( void handle_events, (struct tty *tp) );
|
||||||
_PROTOTYPE( void sigchar, (struct tty *tp, int sig, int mayflush) );
|
_PROTOTYPE( void sigchar, (struct tty *tp, int sig, int mayflush) );
|
||||||
_PROTOTYPE( void tty_task, (void) );
|
_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,
|
_PROTOTYPE( void out_process, (struct tty *tp, char *bstart, char *bpos,
|
||||||
char *bend, int *icount, int *ocount) );
|
char *bend, int *icount, int *ocount) );
|
||||||
_PROTOTYPE( void tty_wakeup, (clock_t now) );
|
_PROTOTYPE( void tty_wakeup, (clock_t now) );
|
||||||
|
@ -146,6 +146,7 @@ _PROTOTYPE( int tcsetattr, \
|
|||||||
|
|
||||||
/* Extensions to the termios c_iflag bit map. */
|
/* Extensions to the termios c_iflag bit map. */
|
||||||
#define IXANY 0x0800 /* allow any key to continue ouptut */
|
#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
|
/* Extensions to the termios c_oflag bit map. They are only active iff
|
||||||
* OPOST is enabled. */
|
* OPOST is enabled. */
|
||||||
|
@ -315,6 +315,30 @@ is set a break is input as a single '\e0', or if
|
|||||||
.B PARMRK
|
.B PARMRK
|
||||||
is set as '\e377', '\e0', '\e0'.
|
is set as '\e377', '\e0', '\e0'.
|
||||||
(Breaks are always ignored.)
|
(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"
|
.SS "Output Modes"
|
||||||
The
|
The
|
||||||
.B c_oflag
|
.B c_oflag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user