From b918f61820f1b7cdb975e41e73f549c96d8f2dc7 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Wed, 16 May 2007 13:14:37 +0000 Subject: [PATCH] Boot monitor flag that enables 'sticky right-alt', permanent change to col selected from the keymap untill right-alt is pressed again. Sticky alt code and russian keymap contributed by Roman Ignatov and Yaroslav Schekin. --- drivers/tty/keyboard.c | 19 ++++- drivers/tty/keymaps/Makefile | 5 ++ drivers/tty/keymaps/russian.src | 139 ++++++++++++++++++++++++++++++++ drivers/tty/tty.c | 7 ++ drivers/tty/tty.h | 2 + 5 files changed, 169 insertions(+), 3 deletions(-) create mode 100644 drivers/tty/keymaps/russian.src diff --git a/drivers/tty/keyboard.c b/drivers/tty/keyboard.c index 6ab1ad0a2..34331fed0 100644 --- a/drivers/tty/keyboard.c +++ b/drivers/tty/keyboard.c @@ -87,12 +87,14 @@ PRIVATE int shift; /* either shift key */ PRIVATE int num_down; /* num lock key depressed */ PRIVATE int caps_down; /* caps lock key depressed */ PRIVATE int scroll_down; /* scroll lock key depressed */ +PRIVATE int alt_down; /* alt key depressed */ PRIVATE int locks[NR_CONS]; /* per console lock keys state */ /* Lock key active bits. Chosen to be equal to the keyboard LED bits. */ #define SCROLL_LOCK 0x01 #define NUM_LOCK 0x02 #define CAPS_LOCK 0x04 +#define ALT_LOCK 0x08 PRIVATE char numpad_map[] = {'H', 'Y', 'A', 'B', 'D', 'C', 'V', 'U', 'G', 'S', 'T', '@'}; @@ -134,6 +136,8 @@ PRIVATE int kbd_watchdog_set= 0; PRIVATE int kbd_alive= 1; PRIVATE timer_t tmr_kbd_wd; +int sticky_alt_mode = 0; + FORWARD _PROTOTYPE( void handle_req, (struct kbd *kbdp, message *m) ); FORWARD _PROTOTYPE( int handle_status, (struct kbd *kbdp, message *m) ); FORWARD _PROTOTYPE( void kbc_cmd0, (int cmd) ); @@ -477,9 +481,14 @@ int scode; if (ctrl || alt_r) column = 3; /* Ctrl + Alt == AltGr */ if (caps) column = 4; } else { - column = 0; - if (caps) column = 1; - if (ctrl) column = 5; + if (sticky_alt_mode && (lk & ALT_LOCK)) { + column = 2; + if (caps) column = 4; + } else { + column = 0; + if (caps) column = 1; + if (ctrl) column = 5; + } } return keyrow[column] & ~HASCAPS; } @@ -721,6 +730,10 @@ int scode; /* scan code of key just struck or released */ case ALT: /* Left or right alt key */ *(escape ? &alt_r : &alt_l) = make; alt = alt_l | alt_r; + if (sticky_alt_mode && (alt_r && (alt_down < make))) { + locks[ccurrent] ^= ALT_LOCK; + } + alt_down = make; break; case CALOCK: /* Caps lock - toggle on 0 -> 1 transition */ if (caps_down < make) { diff --git a/drivers/tty/keymaps/Makefile b/drivers/tty/keymaps/Makefile index bd82dec6c..4993cedc4 100644 --- a/drivers/tty/keymaps/Makefile +++ b/drivers/tty/keymaps/Makefile @@ -18,6 +18,7 @@ all: \ latin-america.map \ olivetti.map \ polish.map \ + russian.map \ scandinavian.map \ spanish.map \ uk.map \ @@ -34,6 +35,7 @@ install: \ $(LK)/latin-america.map \ $(LK)/olivetti.map \ $(LK)/polish.map \ + $(LK)/russian.map \ $(LK)/scandinavian.map \ $(LK)/spanish.map \ $(LK)/uk.map \ @@ -70,6 +72,9 @@ $(LK)/olivetti.map: olivetti.map $(LK)/polish.map: polish.map install -c $? $@ +$(LK)/russian.map: russian.map + install -c $? $@ + $(LK)/scandinavian.map: scandinavian.map install -c $? $@ diff --git a/drivers/tty/keymaps/russian.src b/drivers/tty/keymaps/russian.src new file mode 100644 index 000000000..ccce9099d --- /dev/null +++ b/drivers/tty/keymaps/russian.src @@ -0,0 +1,139 @@ +/* + * Keymap for russian keyboard. + * Modified by Roman V. Ignatov + * Charset: koi8-r + */ + +u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { + +/* scan-code !Shift Shift Alt1 Alt2 Alt+Sh Ctrl */ +/* ==================================================================== */ +/* 00 - none */ 0, 0, 0, 0, 0, 0, +/* 01 - ESC */ C('['), C('['), CA('['),CA('['),CA('['),C('['), +/* 02 - '1' */ '1', '!', '1', A('1'), '!', C('A'), +/* 03 - '2' */ '2', '@', '2', A('2'), '"', C('@'), +/* 04 - '3' */ '3', '#', '3', A('3'), 'N', C('C'), +/* 05 - '4' */ '4', '$', '4', A('4'), ';', C('D'), +/* 06 - '5' */ '5', '%', '5', A('5'), '%', C('E'), +/* 07 - '6' */ '6', '^', '6', A('6'), ':', C('^'), +/* 08 - '7' */ '7', '&', '7', A('7'), '?', C('G'), +/* 09 - '8' */ '8', '*', '8', A('8'), '*', C('H'), +/* 10 - '9' */ '9', '(', '9', A('9'), '(', C('I'), +/* 11 - '0' */ '0', ')', '0', A('0'), ')', C('@'), +/* 12 - '-' */ '-', '_', '-', A('-'), '_', C('_'), +/* 13 - '=' */ '=', '+', '=', A('='), '+', C('@'), +/* 14 - BS */ C('H'), C('H'), C('H'), CA('H'), C('H'),0177, +/* 15 - TAB */ C('I'), C('I'), C('I'), CA('I'),C('I'), C('I'), +/* 16 - 'q' */ L('q'), 'Q', A('J'), A('q'), A('j'), C('Q'), +/* 17 - 'w' */ L('w'), 'W', A(195), A('w'), A(227), C('W'), +/* 18 - 'e' */ L('e'), 'E', A(213), A('e'), A(245), C('E'), +/* 19 - 'r' */ L('r'), 'R', A(203), A('r'), A(235), C('R'), +/* 20 - 't' */ L('t'), 'T', A(197), A('t'), A(229), C('T'), +/* 21 - 'y' */ L('y'), 'Y', A(206), A('y'), A(238), C('Y'), +/* 22 - 'u' */ L('u'), 'U', A(199), A('u'), A(231), C('U'), +/* 23 - 'i' */ L('i'), 'I', A(219), A('i'), A(251), C('I'), +/* 24 - 'o' */ L('o'), 'O', A(221), A('o'), A(253), C('O'), +/* 25 - 'p' */ L('p'), 'P', A(218), A('p'), A(250), C('P'), +/* 26 - '[' */ '[', '{', A(200), A('['), A(232), C('['), +/* 27 - ']' */ ']', '}', A(223), A(']'), A(255), C(']'), +/* 28 - CR/LF */ C('M'), C('M'), C('M'), CA('M'), C('M') ,C('J'), +/* 29 - Ctrl */ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, +/* 30 - 'a' */ L('a'), 'A', A(198), A('a'), A(230), C('A'), +/* 31 - 's' */ L('s'), 'S', A(217), A('s'), A(249), C('S'), +/* 32 - 'd' */ L('d'), 'D', A(215), A('d'), A(247), C('D'), +/* 33 - 'f' */ L('f'), 'F', A(193), A('f'), A(225), C('F'), +/* 34 - 'g' */ L('g'), 'G', A(208), A('g'), A(240), C('G'), +/* 35 - 'h' */ L('h'), 'H', A(210), A('h'), A(242), C('H'), +/* 36 - 'j' */ L('j'), 'J', A(207), A('j'), A(239), C('J'), +/* 37 - 'k' */ L('k'), 'K', A(204), A('k'), A(236), C('K'), +/* 38 - 'l' */ L('l'), 'L', A(196), A('l'), A(228), C('L'), +/* 39 - ';' */ ';', ':', A(214), A(';'), A(246), C('@'), +/* 40 - '\'' */ '\'', '"', A(220), A('\''),A(252), C('@'), +/* 41 - '`' */ '`', '~', A(163), A('`'), A(179), C('@'), +/* 42 - l. SHIFT*/ SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, +/* 43 - '\\' */ '\\', '|', '\\', A('\\'), '|', C('\\'), +/* 44 - 'z' */ L('z'), 'Z', A(209), A('z'), A(241), C('Z'), +/* 45 - 'x' */ L('x'), 'X', A(222), A('x'), A(254), C('X'), +/* 46 - 'c' */ L('c'), 'C', A(211), A('c'), A(243), C('C'), +/* 47 - 'v' */ L('v'), 'V', A(205), A('v'), A(237), C('V'), +/* 48 - 'b' */ L('b'), 'B', A(201), A('b'), A(233), C('B'), +/* 49 - 'n' */ L('n'), 'N', A(212), A('n'), A(244), C('N'), +/* 50 - 'm' */ L('m'), 'M', A(216), A('m'), A(248), C('M'), +/* 51 - ',' */ ',', '<', A(194), A(','), A(226), C('@'), +/* 52 - '.' */ '.', '>', A(192), A('.'), A(224), C('@'), +/* 53 - '/' */ '/', '?', '.', A('/'), ',', C('@'), +/* 54 - r. SHIFT*/ SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, +/* 55 - '*' */ '*', '*', '*', A('*'), '*', C('@'), +/* 56 - ALT */ ALT, ALT, ALT, ALT, ALT, ALT, +/* 57 - ' ' */ ' ', ' ', ' ', A(' '), ' ', C('@'), +/* 58 - CapsLck */ CALOCK, CALOCK, CALOCK, CALOCK, CALOCK, CALOCK, +/* 59 - F1 */ F1, SF1, F1, AF1, SF1, CF1, +/* 60 - F2 */ F2, SF2, F2, AF2, SF2, CF2, +/* 61 - F3 */ F3, SF3, F3, AF3, SF3, CF3, +/* 62 - F4 */ F4, SF4, F4, AF4, SF4, CF4, +/* 63 - F5 */ F5, SF5, F5, AF5, SF5, CF5, +/* 64 - F6 */ F6, SF6, F6, AF6, SF6, CF6, +/* 65 - F7 */ F7, SF7, F7, AF7, SF7, CF7, +/* 66 - F8 */ F8, SF8, F8, AF8, SF8, CF8, +/* 67 - F9 */ F9, SF9, F9, AF9, SF9, CF9, +/* 68 - F10 */ F10, SF10, F10, AF10, SF10, CF10, +/* 69 - NumLock */ NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, +/* 70 - ScrLock */ SLOCK, SLOCK, SLOCK, SLOCK, SLOCK, SLOCK, +/* 71 - Home */ HOME, '7', HOME, AHOME, '7', CHOME, +/* 72 - CurUp */ UP, '8', UP, AUP, '8', CUP, +/* 73 - PgUp */ PGUP, '9', PGUP, APGUP, '9', CPGUP, +/* 74 - '-' */ NMIN, '-', NMIN, ANMIN, '-', CNMIN, +/* 75 - Left */ LEFT, '4', LEFT, ALEFT, '4', CLEFT, +/* 76 - MID */ MID, '5', MID, AMID, '5', CMID, +/* 77 - Right */ RIGHT, '6', RIGHT, ARIGHT, '6', CRIGHT, +/* 78 - '+' */ PLUS, '+', PLUS, APLUS, '+', CPLUS, +/* 79 - End */ END, '1', END, AEND, '1', CEND, +/* 80 - Down */ DOWN, '2', DOWN, ADOWN, '2', CDOWN, +/* 81 - PgDown */ PGDN, '3', PGDN, APGDN, '3', CPGDN, +/* 82 - Insert */ INSRT, '0', INSRT, AINSRT, '0', CINSRT, +/* 83 - Delete */ 0177, '.', 0177, A(0177),'.', 0177, +/* 84 - Enter */ C('M'), C('M'), C('M'), CA('M'), C('M'),C('J'), +/* 85 - ??? */ 0, 0, 0, 0, 0, 0, +/* 86 - ??? */ '<', '>', '<', A('|'), '>', C('@'), +/* 87 - F11 */ F11, SF11, F11, AF11, SF11, CF11, +/* 88 - F12 */ F12, SF12, F12, AF12, SF12, CF12, +/* 89 - ??? */ 0, 0, 0, 0, 0, 0, +/* 90 - ??? */ 0, 0, 0, 0, 0, 0, +/* 91 - ??? */ 0, 0, 0, 0, 0, 0, +/* 92 - ??? */ 0, 0, 0, 0, 0, 0, +/* 93 - ??? */ 0, 0, 0, 0, 0, 0, +/* 94 - ??? */ 0, 0, 0, 0, 0, 0, +/* 95 - ??? */ 0, 0, 0, 0, 0, 0, +/* 96 - EXT_KEY */ EXTKEY, EXTKEY, EXTKEY, EXTKEY, EXTKEY, EXTKEY, +/* 97 - ??? */ 0, 0, 0, 0, 0, 0, +/* 98 - ??? */ 0, 0, 0, 0, 0, 0, +/* 99 - ??? */ 0, 0, 0, 0, 0, 0, +/*100 - ??? */ 0, 0, 0, 0, 0, 0, +/*101 - ??? */ 0, 0, 0, 0, 0, 0, +/*102 - ??? */ 0, 0, 0, 0, 0, 0, +/*103 - ??? */ 0, 0, 0, 0, 0, 0, +/*104 - ??? */ 0, 0, 0, 0, 0, 0, +/*105 - ??? */ 0, 0, 0, 0, 0, 0, +/*106 - ??? */ 0, 0, 0, 0, 0, 0, +/*107 - ??? */ 0, 0, 0, 0, 0, 0, +/*108 - ??? */ 0, 0, 0, 0, 0, 0, +/*109 - ??? */ 0, 0, 0, 0, 0, 0, +/*110 - ??? */ 0, 0, 0, 0, 0, 0, +/*111 - ??? */ 0, 0, 0, 0, 0, 0, +/*112 - ??? */ 0, 0, 0, 0, 0, 0, +/*113 - ??? */ 0, 0, 0, 0, 0, 0, +/*114 - ??? */ 0, 0, 0, 0, 0, 0, +/*115 - ??? */ 0, 0, 0, 0, 0, 0, +/*116 - ??? */ 0, 0, 0, 0, 0, 0, +/*117 - ??? */ 0, 0, 0, 0, 0, 0, +/*118 - ??? */ 0, 0, 0, 0, 0, 0, +/*119 - ??? */ 0, 0, 0, 0, 0, 0, +/*120 - ??? */ 0, 0, 0, 0, 0, 0, +/*121 - ??? */ 0, 0, 0, 0, 0, 0, +/*122 - ??? */ 0, 0, 0, 0, 0, 0, +/*123 - ??? */ 0, 0, 0, 0, 0, 0, +/*124 - ??? */ 0, 0, 0, 0, 0, 0, +/*125 - ??? */ 0, 0, 0, 0, 0, 0, +/*126 - ??? */ 0, 0, 0, 0, 0, 0, +/*127 - ??? */ 0, 0, 0, 0, 0, 0 +}; diff --git a/drivers/tty/tty.c b/drivers/tty/tty.c index 07532c4b1..780dbda34 100644 --- a/drivers/tty/tty.c +++ b/drivers/tty/tty.c @@ -1530,6 +1530,7 @@ PRIVATE void tty_init() register tty_t *tp; int s; struct sigaction sa; + char env[100]; /* Initialize the terminal lines. */ for (tp = FIRST_TTY,s=0; tp < END_TTY; tp++,s++) { @@ -1560,6 +1561,12 @@ PRIVATE void tty_init() } } + if(env_get_param("sticky_alt", env, sizeof(env)-1) == OK + && atoi(env) == 1) { + sticky_alt_mode = 1; + } + + #if DEAD_CODE /* Install signal handlers. Ask PM to transform signal into message. */ sa.sa_handler = SIG_MESS; diff --git a/drivers/tty/tty.h b/drivers/tty/tty.h index 67a7e9349..2f3f24c9d 100644 --- a/drivers/tty/tty.h +++ b/drivers/tty/tty.h @@ -115,6 +115,8 @@ extern unsigned long rs_irq_set; extern int panicing; /* From panic.c in sysutil */ +extern int sticky_alt_mode; /* right-alt sticky to switch codepages */ + /* Values for the fields. */ #define NOT_ESCAPED 0 /* previous character is not LNEXT (^V) */ #define ESCAPED 1 /* previous character was LNEXT (^V) */ -- 2.44.0