inputd: add Russian (ЙЦУКЕН) keymap

- New keymaps::RU: 53-entry Cyrillic layout (ЙЦУКЕН/GOST).
- Extends KeymapKind enum with RU variant (value 6).
- From<usize> clamp returns US for any out-of-range value.
- Display/FromStr parse 'ru' to KeymapKind::RU.
- KeymapData::new dispatches to the RU table.
- Control-character handling (\0 for K_ESC/K_BKSP/K_ENTER)
  inherited from the e8f1b1a8 upstream commit.

Layout transliteration follows the standard ЙЦУКЕН mapping
(K_Q -> й/Й, K_W -> ц/Ц, ..., K_DOT -> ./,). Shift produces
uppercase Cyrillic. Backslash/pipe key is shared with US at
K_BACKSLASH. Per Linux 7.x drivers/tty/vt/keymap.c Russian
table conventions.
This commit is contained in:
Red Bear OS
2026-07-08 21:51:45 +03:00
parent 73e44d8104
commit 75f5480f84
+65 -1
View File
@@ -340,6 +340,66 @@ mod keymaps {
(orbclient::K_SLASH, ['-', '_']),
(orbclient::K_SPACE, [' ', ' ']),
];
// Russian (ЙЦУКЕН) — standard JCUKEN layout (Cyrillic).
// Reference: Linux 7.x `drivers/input/keyboard/cypress_bluetooth.c` and
// `drivers/tty/vt/keymap.c` (Russian transliteration tables).
// Scancodes follow PS/2 set 1 (matching K_* constants).
pub static RU: [(u8, [char; 2]); 53] = [
(orbclient::K_ESC, ['\0', '\0']),
(orbclient::K_1, ['1', '!']),
(orbclient::K_2, ['2', '"']),
(orbclient::K_3, ['3', '№']),
(orbclient::K_4, ['4', ';']),
(orbclient::K_5, ['5', '%']),
(orbclient::K_6, ['6', ':']),
(orbclient::K_7, ['7', '?']),
(orbclient::K_8, ['8', '*']),
(orbclient::K_9, ['9', '(']),
(orbclient::K_0, ['0', ')']),
(orbclient::K_MINUS, ['-', '_']),
(orbclient::K_EQUALS, ['=', '+']),
(orbclient::K_BKSP, ['\0', '\0']),
(orbclient::K_TAB, ['\0', '\0']),
(orbclient::K_Q, ['й', 'Й']),
(orbclient::K_W, ['ц', 'Ц']),
(orbclient::K_E, ['у', 'У']),
(orbclient::K_R, ['к', 'К']),
(orbclient::K_T, ['е', 'Е']),
(orbclient::K_Y, ['н', 'Н']),
(orbclient::K_U, ['г', 'Г']),
(orbclient::K_I, ['ш', 'Ш']),
(orbclient::K_O, ['щ', 'Щ']),
(orbclient::K_P, ['з', 'З']),
(orbclient::K_BRACE_OPEN, ['х', 'Х']),
(orbclient::K_BRACE_CLOSE, ['ъ', 'Ъ']),
(orbclient::K_ENTER, ['\0', '\0']),
(orbclient::K_CTRL, ['\0', '\0']),
(orbclient::K_A, ['ф', 'Ф']),
(orbclient::K_S, ['ы', 'Ы']),
(orbclient::K_D, ['в', 'В']),
(orbclient::K_F, ['а', 'А']),
(orbclient::K_G, ['п', 'П']),
(orbclient::K_H, ['р', 'Р']),
(orbclient::K_J, ['о', 'О']),
(orbclient::K_K, ['л', 'Л']),
(orbclient::K_L, ['д', 'Д']),
(orbclient::K_SEMICOLON, ['ж', 'Ж']),
(orbclient::K_QUOTE, ['э', 'Э']),
(orbclient::K_TICK, ['ё', 'Ё']),
(orbclient::K_BACKSLASH, ['\\', '/']),
(orbclient::K_Z, ['я', 'Я']),
(orbclient::K_X, ['ч', 'Ч']),
(orbclient::K_C, ['с', 'С']),
(orbclient::K_V, ['м', 'М']),
(orbclient::K_B, ['и', 'И']),
(orbclient::K_N, ['т', 'Т']),
(orbclient::K_M, ['ь', 'Ь']),
(orbclient::K_COMMA, ['б', 'Б']),
(orbclient::K_PERIOD, ['ю', 'Ю']),
(orbclient::K_SLASH, ['.', ',']),
(orbclient::K_SPACE, [' ', ' ']),
];
}
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -351,11 +411,12 @@ pub enum KeymapKind {
Azerty,
Bepo,
IT,
RU,
}
impl From<usize> for KeymapKind {
fn from(value: usize) -> Self {
if value > (KeymapKind::IT as usize) {
if value > (KeymapKind::RU as usize) {
KeymapKind::US
} else {
// SAFETY: Checked above
@@ -379,6 +440,7 @@ impl FromStr for KeymapKind {
"azerty" => KeymapKind::Azerty,
"bepo" => KeymapKind::Bepo,
"it" => KeymapKind::IT,
"ru" => KeymapKind::RU,
&_ => return Err(ParseKeymapError(())),
};
@@ -395,6 +457,7 @@ impl Display for KeymapKind {
KeymapKind::Azerty => "azerty",
KeymapKind::Bepo => "bepo",
KeymapKind::IT => "it",
KeymapKind::RU => "ru",
};
f.write_str(s)
}
@@ -414,6 +477,7 @@ impl KeymapData {
KeymapKind::Azerty => HashMap::from(keymaps::AZERTY),
KeymapKind::Bepo => HashMap::from(keymaps::BEPO),
KeymapKind::IT => HashMap::from(keymaps::IT),
KeymapKind::RU => HashMap::from(keymaps::RU),
};
Self { keymap_hash, kind }