linux: Use K_OFF VT KB mode over K_RAW if available.
Linux kernels since 2.6.38 (March 2011) have an VT KB mode K_OFF in which special keys (like Ctrl+C) are not interpreted and input is not buffered. Use of this mode over K_RAW removes the need for a xf86ConsoleHandler to drain the VT input buffer, removing the grief it causes when it goes wrong or is (de)initialized out-of-order. (This also saves a few needless context switches per key event.) If K_OFF is not defined or not understood by the kernel, K_RAW and the previous method is used as a fall-back. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Arthur Taylor <art@ified.ca> Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
0b113f7cdf
commit
ff891bbf68
|
@ -212,11 +212,21 @@ xf86OpenConsole(void)
|
||||||
tcgetattr(xf86Info.consoleFd, &tty_attr);
|
tcgetattr(xf86Info.consoleFd, &tty_attr);
|
||||||
SYSCALL(ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode));
|
SYSCALL(ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode));
|
||||||
|
|
||||||
|
#ifdef K_OFF
|
||||||
|
/* disable kernel special keys and buffering */
|
||||||
|
SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_OFF));
|
||||||
|
if (ret < 0)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW));
|
SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
|
FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
||||||
|
/* need to keep the buffer clean, else the kernel gets angry */
|
||||||
|
xf86SetConsoleHandler(drain_console, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
nTty = tty_attr;
|
nTty = tty_attr;
|
||||||
nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
|
nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
|
||||||
nTty.c_oflag = 0;
|
nTty.c_oflag = 0;
|
||||||
|
@ -228,9 +238,6 @@ xf86OpenConsole(void)
|
||||||
cfsetospeed(&nTty, 9600);
|
cfsetospeed(&nTty, 9600);
|
||||||
tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
|
tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
|
||||||
|
|
||||||
/* need to keep the buffer clean, else the kernel gets angry */
|
|
||||||
xf86SetConsoleHandler(drain_console, NULL);
|
|
||||||
|
|
||||||
/* we really should have a InitOSInputDevices() function instead
|
/* we really should have a InitOSInputDevices() function instead
|
||||||
* of Init?$#*&Device(). So I just place it here */
|
* of Init?$#*&Device(). So I just place it here */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue