Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

According to this page there is no direct mapping from udev key mappings to X, it has its own mappings.

X has a (quasi) total independent way of mapping keys: X reads the kernel keycode table at startup, then maps the keycode to its independent keycode table (it is the same as the kernel keycodes but different :))

Could somebody elaborate and also maybe explain or point to explanations of why X does this, ignoring udev?

share|improve this question
1  
I'm not sure what gives you the impression that udev is involved in key mappings? –  Mat Jan 8 '12 at 11:32
    
@Mat look in /lib/udev/keymaps and /lib/udev/rules.d/95-keymap.rules. Or do you mean X key mappings? –  Dave E Jan 8 '12 at 11:49
    
Ah, I see what you mean. udev can set up keymaps for input devices, but basically it configures the input layer (stuff in /dev/input), it doesn't actively participate in it once set up. –  Mat Jan 8 '12 at 11:54
add comment

2 Answers

You're making several wrong assumptions: that X ignores udev (it doesn't); that udev directly intervenes in keyboard mappings (it only sets them up, beyond that it's the kernel acting); that X is based on Linux (it runs on other unix variants as well).

Udev only plays a very limited role in keyboard handling: it detects specific keyboard models and declares their vendor-specific keys. Udev doesn't act on standard keys like A and F1, only on vendor-specific keys like Brightness up or Wifi on/off (usually marked by icons). These keys are typically not used by application, but mapped to ACPI events.

The Linux kernel has its own mapping scheme for the usual keys, which you can set with the loadkeys command. If you have multiple keyboards plugged in, the settings performed by udev are specific to one keyboard, whereas loadkeys acts on the global kernel keymap.

The kernel's keyboard mappings don't cover nearly all the nuances afforded by X. So X has its own scheme and for the most part ignores kernel settings. X does take the keyboard-specific mappings set up through udev into account.

share|improve this answer
add comment

You guessed right: the X11 keyboard driver talks directly to the keyboard device to receive raw keypresses as keycodes.

That's because X11 wants low-level access to the keyboard, not just cooked events. The mapping between keycodes and keysyms can be specified in a number of ways:

  • setting the keyboard map with setxkbmap
  • setting individual keys with xmodmap
  • programmatically with XChangeKeyboardMapping etc
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.