Project

General

Profile

Actions

Bug #16552

open

KIOCTRANS effect should reset when KIOCSDIRECT does

Added by Joshua M. Clulow 15 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
kernel
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

The system provides a virtual keyboard device that aggregates the input from, and synchronises the LED indicators of, all of the keyboards attached to the system. The public device name is /dev/kbd and though there is not a good manual page covering how it works, there are comments in sys/kbio.h and sys/kbd.h and obviously one can inspect the source.

There are two broad consumers of keyboard input: the wscons terminal emulator device (the "text" console), and then any windowing system (e.g., X11) that might want to take control of the keyboard while it also has control of the system framebuffer.

To take control of keyboard input in such a way that it does not simultaneously leak back to the text console, the KIOCSDIRECT ioctl is used. Enabling direct mode means only the current file descriptor will receive keyboard input, and the text console will not. By default, the keyboard input is heavily preprocessed into a stream of ASCII bytes, using sun-color terminal escape sequences to represent keystrokes that don't have a clear mapping to an ASCII character. After enabling direct mode, the windowing system consumer can also use KIOCTRANS to change the translation mode from TR_ASCII to TR_EVENT; subsequent reads on the device will produce (binary) "firm event" objects that include structured information about which keys were pressed and which modifiers were held, etc.

When the windowing system closes its file descriptor, the effect of KIOCSDIRECT is immediately undone. This means keyboard input is once again sent to the text console. Unfortunately, it seems like the effect of KIOCTRANS is not undone, leaving the previous translation mode in effect. This means that when the user subsequently tries to type into the text console, all they get is a spray of mostly unprintable firm event objects, which totally messes up the console and is useless for logging in.

At a high level: when we reset direct mode, we should also reset translation to TR_ASCII; or, at least, the console should have some way to make sure it always has a TR_ASCII stream.

No data to display

Actions

Also available in: Atom PDF