I am using a generic usb keyboard, Linux 2.6.27 with gnome desktop, gnome-terminal and bash shell. I am interested to know what happens in the software. How are special characters from my keyboard interpreted with some encoding to characters and where do the character pictures come from?
What happens in your computer when you press a key on your keyboard? First, a switch beneath the key closes, and current flows into a small chip in a keyboard. Each key has a scan code number, which corresponds to its position on the keyboard. The keyboard transmits this number as binary data to the computer's CPU.
When a key is pressed, a keyboard interacts with : Keyboard controller.
Answer: When you press a key, it presses a switch, completing the circuit and allowing a tiny amount of current to flow through. ... When the processor finds a circuit that is closed, it compares the location of that circuit on the key matrix to the character map in its read-only memory (ROM).
The Linux input layer with the USB drivers gets scancodes (basically "KEY 1 DOWN" "KEY 1 UP") from the keyboard.
X uses its keymap to convert scancodes into keycodes and X input events.
The GTK input method converts the sequence of input events into composed unicode characters.
Gnome-terminal encodes these in UTF-8 for the shell.
The Shell doesn't care. it just knows that it's dealing with a multibyte encoding.
The shell echoes multibyte-encoded text back through the TTY.
Gnome-terminal decodes the incoming text and determines unicode code points.
Gnome-terminal draws characters using GTK+ facilities.
GTK+ uses Pango to render the text, and calls the X library to draw the pixels to the screen.
The X server draws characters into the screen buffer and the video card displays them.
Here is my attempt at a diagram:
alt text http://osoft.us/system_layers.png
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With