From 6a0e8e3b805555aebe1abb86afda115506ca6763 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Wed, 4 Feb 2009 17:04:16 +0000 Subject: [PATCH] Added a separate keymap for escaped scancodes. This makes the code a little cleaner (escaped scancodes are less of a special case) and lets us be completely flexible when assigning meaning to them. Future: a tool and ioctl to load the escaped keymap. --- drivers/tty/keyboard.c | 23 +++++++++++++---------- drivers/tty/keymaps/Makefile | 5 +++++ drivers/tty/keymaps/dvorak.src | 4 ---- drivers/tty/keymaps/french.src | 3 --- drivers/tty/keymaps/genmap.c | 2 ++ drivers/tty/keymaps/german.src | 3 --- drivers/tty/keymaps/italian.src | 3 --- drivers/tty/keymaps/japanese.src | 3 --- drivers/tty/keymaps/latin-america.src | 3 --- drivers/tty/keymaps/olivetti.src | 3 --- drivers/tty/keymaps/polish.src | 4 ---- drivers/tty/keymaps/russian-cp866.src | 3 --- drivers/tty/keymaps/russian.src | 3 --- drivers/tty/keymaps/scandinavian.src | 3 --- drivers/tty/keymaps/spanish.src | 3 --- drivers/tty/keymaps/uk.src | 3 --- drivers/tty/keymaps/us-std-esc.src | 6 +++--- drivers/tty/keymaps/us-std.src | 3 --- drivers/tty/keymaps/us-swap.src | 3 --- 19 files changed, 23 insertions(+), 60 deletions(-) diff --git a/drivers/tty/keyboard.c b/drivers/tty/keyboard.c index 234858912..5e093574e 100644 --- a/drivers/tty/keyboard.c +++ b/drivers/tty/keyboard.c @@ -18,7 +18,14 @@ #include #include #include "tty.h" + +u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { #include "keymaps/us-std.src" +}; + +u16_t keymap_escaped[NR_SCAN_CODES * MAP_COLS] = { +#include "keymaps/us-std-esc.src" +}; int irq_hook_id = -1; int aux_irq_hook_id = -1; @@ -467,7 +474,10 @@ int scode; if (scode == SLASH_SCAN && esc) return '/'; /* don't map numeric slash */ - keyrow = &keymap[scode * MAP_COLS]; + if(esc) + keyrow = &keymap[scode * MAP_COLS]; + else + keyrow = &keymap_escaped[scode * MAP_COLS]; caps = shift; lk = locks[ccurrent]; @@ -737,7 +747,6 @@ int scode; /* scan code of key just struck or released */ alt_down = make; break; case CALOCK: /* Caps lock - toggle on 0 -> 1 transition */ - if(escape) return -1; if (caps_down < make) { locks[ccurrent] ^= CAPS_LOCK; set_leds(); @@ -745,7 +754,6 @@ int scode; /* scan code of key just struck or released */ caps_down = make; break; case NLOCK: /* Num lock */ - if(escape) return -1; if (num_down < make) { locks[ccurrent] ^= NUM_LOCK; set_leds(); @@ -753,7 +761,6 @@ int scode; /* scan code of key just struck or released */ num_down = make; break; case SLOCK: /* Scroll lock */ - if(escape) return -1; if (scroll_down < make) { locks[ccurrent] ^= SCROLL_LOCK; set_leds(); @@ -764,13 +771,9 @@ int scode; /* scan code of key just struck or released */ esc = 1; /* Next key is escaped */ return(-1); default: /* A normal key */ - if(escape) { - printf("tty: ignoring escaped 0x%x\n", scode); - return -1; - } if(!ch) { - printf("tty: ignoring unrecognized scancode 0x%x\n", - scode); + printf("tty: ignoring unrecognized %s scancode 0x%x\n", + esc ? "escaped" : "straight", scode); return -1; } if(make) return(ch); diff --git a/drivers/tty/keymaps/Makefile b/drivers/tty/keymaps/Makefile index 952a806d5..dfaf1b29a 100644 --- a/drivers/tty/keymaps/Makefile +++ b/drivers/tty/keymaps/Makefile @@ -24,6 +24,7 @@ all: \ spanish.map \ uk.map \ us-std.map \ + us-std-esc.map \ us-swap.map \ install: \ @@ -42,6 +43,7 @@ install: \ $(LK)/spanish.map \ $(LK)/uk.map \ $(LK)/us-std.map \ + $(LK)/us-std-esc.map \ $(LK)/us-swap.map \ clean: @@ -92,5 +94,8 @@ $(LK)/uk.map: uk.map $(LK)/us-std.map: us-std.map install -c $? $@ +$(LK)/us-std-esc.map: us-std-esc.map + install -c $? $@ + $(LK)/us-swap.map: us-swap.map install -c $? $@ diff --git a/drivers/tty/keymaps/dvorak.src b/drivers/tty/keymaps/dvorak.src index abcd82ff7..0cfd965a6 100644 --- a/drivers/tty/keymaps/dvorak.src +++ b/drivers/tty/keymaps/dvorak.src @@ -3,8 +3,6 @@ * Contributed by: Ulrich Hobelmann */ -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, @@ -135,5 +133,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*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/keymaps/french.src b/drivers/tty/keymaps/french.src index 5326c4d4d..01a61cdc1 100644 --- a/drivers/tty/keymaps/french.src +++ b/drivers/tty/keymaps/french.src @@ -1,7 +1,5 @@ /* Keymap for the French keyboard. */ -u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { - /* scan-code !Shift Shift Alt AltGr Alt+Sh Ctrl */ /* ==================================================================== */ /* 00 - none */ 0, 0, 0, 0, 0, 0, @@ -132,4 +130,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*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/keymaps/genmap.c b/drivers/tty/keymaps/genmap.c index 1d5c809a7..5093cb7e2 100644 --- a/drivers/tty/keymaps/genmap.c +++ b/drivers/tty/keymaps/genmap.c @@ -8,7 +8,9 @@ #include #include +u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { #include KEYSRC +}; u8_t comprmap[4 + NR_SCAN_CODES * MAP_COLS * 9/8 * 2 + 1]; diff --git a/drivers/tty/keymaps/german.src b/drivers/tty/keymaps/german.src index 264436c2e..8cbab636d 100644 --- a/drivers/tty/keymaps/german.src +++ b/drivers/tty/keymaps/german.src @@ -1,7 +1,5 @@ /* Keymap for German MF-2 keyboard. */ -u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { - /* scan-code unsh Shift Alt AltGr Alt+Sh Strg */ /* ==================================================================== */ /* 00 - none */ 0, 0, 0, 0, 0, 0, @@ -132,4 +130,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*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/keymaps/italian.src b/drivers/tty/keymaps/italian.src index 56a4ea064..95c64ee91 100644 --- a/drivers/tty/keymaps/italian.src +++ b/drivers/tty/keymaps/italian.src @@ -2,8 +2,6 @@ /* Modified by Ernesto Del Prete in October 1997 */ /* ernesto@cclix1.polito.it or s84508@cclix1.polito.it */ -u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { - /* scan-code !Shift Shift Alt AltGr Alt+Sh Ctrl */ /* ==================================================================== */ /* 00 - none */ 0, 0, 0, 0, 0, 0, @@ -134,4 +132,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*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/keymaps/japanese.src b/drivers/tty/keymaps/japanese.src index d9b9391da..7ab519f43 100644 --- a/drivers/tty/keymaps/japanese.src +++ b/drivers/tty/keymaps/japanese.src @@ -22,8 +22,6 @@ #error NR_SCAN_CODES mis-match #endif -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, @@ -154,4 +152,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*125 - YEN */ '\\', '|', A('\\'),A('\\'),A('|'), C('\\'), /*126 - ??? */ 0, 0, 0, 0, 0, 0, /*127 - ??? */ 0, 0, 0, 0, 0, 0 -}; diff --git a/drivers/tty/keymaps/latin-america.src b/drivers/tty/keymaps/latin-america.src index 4dc40ecfc..5c4071581 100644 --- a/drivers/tty/keymaps/latin-america.src +++ b/drivers/tty/keymaps/latin-america.src @@ -18,8 +18,6 @@ #error NR_SCAN_CODES mis-match #endif -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, @@ -150,4 +148,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*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/keymaps/olivetti.src b/drivers/tty/keymaps/olivetti.src index a18d4fd31..25deb961d 100644 --- a/drivers/tty/keymaps/olivetti.src +++ b/drivers/tty/keymaps/olivetti.src @@ -1,7 +1,5 @@ /* Keymap for the Olivetti M24. */ -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, @@ -132,4 +130,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*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/keymaps/polish.src b/drivers/tty/keymaps/polish.src index 21ec112a7..b8a2d5ec5 100644 --- a/drivers/tty/keymaps/polish.src +++ b/drivers/tty/keymaps/polish.src @@ -4,9 +4,6 @@ * Charset: ISO-8859-2 - [Polska Norma PN-93 T-42118] */ - -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, @@ -137,4 +134,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*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/keymaps/russian-cp866.src b/drivers/tty/keymaps/russian-cp866.src index 92015b158..470d99ff5 100644 --- a/drivers/tty/keymaps/russian-cp866.src +++ b/drivers/tty/keymaps/russian-cp866.src @@ -3,8 +3,6 @@ * Modified by Roman V. Ignatov * Charset: cp866 */ - -u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /* scan-code !Shift Shift Alt1 Alt2 Alt+Sh Ctrl */ /* ==================================================================== */ @@ -136,4 +134,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*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/keymaps/russian.src b/drivers/tty/keymaps/russian.src index ccce9099d..94a420e25 100644 --- a/drivers/tty/keymaps/russian.src +++ b/drivers/tty/keymaps/russian.src @@ -3,8 +3,6 @@ * 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 */ /* ==================================================================== */ @@ -136,4 +134,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*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/keymaps/scandinavian.src b/drivers/tty/keymaps/scandinavian.src index a4afba929..3c21af313 100644 --- a/drivers/tty/keymaps/scandinavian.src +++ b/drivers/tty/keymaps/scandinavian.src @@ -3,8 +3,6 @@ * preliminary version, 8 Sept 1996 */ -u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { - /* scan-code unsh Shift Alt AltGr Alt+Sh Ctrl */ /* ==================================================================== */ /* 00 - none */ 0, 0, 0, 0, 0, 0, @@ -135,4 +133,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*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/keymaps/spanish.src b/drivers/tty/keymaps/spanish.src index 096ef3738..2404e40da 100644 --- a/drivers/tty/keymaps/spanish.src +++ b/drivers/tty/keymaps/spanish.src @@ -1,8 +1,6 @@ /* Keymap for Spanish MF-2 keyboard. */ /* Modified by Javier Garcia Martin jawa@inf.deusto.es */ -u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { - /* scan-code !Shift Shift Alt AltGr Alt+Sh Ctrl */ /* ==================================================================== @@ -135,4 +133,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*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/keymaps/uk.src b/drivers/tty/keymaps/uk.src index e7cc9fbd8..4b3245b65 100644 --- a/drivers/tty/keymaps/uk.src +++ b/drivers/tty/keymaps/uk.src @@ -1,7 +1,5 @@ /* Keymap for standard UK keyboard. Author: Darren Mason */ -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, @@ -132,4 +130,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*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/keymaps/us-std-esc.src b/drivers/tty/keymaps/us-std-esc.src index 82059ffc2..8e99995ea 100644 --- a/drivers/tty/keymaps/us-std-esc.src +++ b/drivers/tty/keymaps/us-std-esc.src @@ -60,7 +60,7 @@ /* 55 - '*' */ '*', '*', A('*'), A('*'), A('*'), C('@'), /* 56 - ALT */ ALT, ALT, ALT, ALT, ALT, ALT, /* 57 - ' ' */ ' ', ' ', A(' '), A(' '), A(' '), C('@'), -/* 58 - CapsLck */ CALOCK, CALOCK, CALOCK, CALOCK, CALOCK, CALOCK, +/* 58 - CapsLck */ 0, 0, 0, 0, 0, 0, /* 59 - F1 */ F1, SF1, AF1, AF1, ASF1, CF1, /* 60 - F2 */ F2, SF2, AF2, AF2, ASF2, CF2, /* 61 - F3 */ F3, SF3, AF3, AF3, ASF3, CF3, @@ -71,8 +71,8 @@ /* 66 - F8 */ F8, SF8, AF8, AF8, ASF8, CF8, /* 67 - F9 */ F9, SF9, AF9, AF9, ASF9, CF9, /* 68 - F10 */ F10, SF10, AF10, AF10, ASF10, CF10, -/* 69 - NumLock */ NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, -/* 70 - ScrLock */ SLOCK, SLOCK, SLOCK, SLOCK, SLOCK, SLOCK, +/* 69 - NumLock */ 0, 0, 0, 0, 0, 0, +/* 70 - ScrLock */ 0, 0, 0, 0, 0, 0, /* 71 - Home */ HOME, '7', AHOME, AHOME, A('7'), CHOME, /* 72 - CurUp */ UP, '8', AUP, AUP, A('8'), CUP, /* 73 - PgUp */ PGUP, '9', APGUP, APGUP, A('9'), CPGUP, diff --git a/drivers/tty/keymaps/us-std.src b/drivers/tty/keymaps/us-std.src index ea4e33432..82059ffc2 100644 --- a/drivers/tty/keymaps/us-std.src +++ b/drivers/tty/keymaps/us-std.src @@ -1,7 +1,5 @@ /* Keymap for US MF-2 keyboard. */ -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, @@ -132,4 +130,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*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/keymaps/us-swap.src b/drivers/tty/keymaps/us-swap.src index 16d84a012..e4be4dbfe 100644 --- a/drivers/tty/keymaps/us-swap.src +++ b/drivers/tty/keymaps/us-swap.src @@ -1,7 +1,5 @@ /* Keymap for US MF-2 keyboard with the Caps Lock and Control key swapped. */ -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, @@ -132,4 +130,3 @@ u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { /*125 - ??? */ 0, 0, 0, 0, 0, 0, /*126 - ??? */ 0, 0, 0, 0, 0, 0, /*127 - ??? */ 0, 0, 0, 0, 0, 0 -}; -- 2.44.0