Blob Blame History Raw
Edward Flottwell <edward@mudhoney.mitropa.com> wrote the following
about his kernel patch for allowing the kernel to work with an
adapted AS400 keyboard.

(In fact no kernel patch is required - the utility setkeycodes will do.
But the technical info below might be useful for somebody.)
----aeb

"Keyboard.c patch for IBM Keyboards" (Aug  9, 20:04):

> The last 2 Weekends I spent on hacking a little bit in the keyboard code to
> make a keyboard from a IBM AS400 Terminal work with LinuX. It's a very nice
> piece of hardware, 122 keys and 2 kg :-), mostly used in Banks and
> Companies. I got mine from a bank service company for 10 Marks (aprox.
> 7.5$).
> 
> The patch against keyboard.c from 1.3.15 and a README is following:
> 
> --------------------------------schnipp-----------------------------------

--- keyboard.1.3.15.orig	Wed Aug  9 12:51:28 1995
+++ keyboard.c	Wed Aug  9 13:11:56 1995
@@ -39,6 +39,11 @@
 #define KBD_REPORT_ERR
 #define KBD_REPORT_UNKN
 /* #define KBD_IS_FOCUS_9000 */
+/* #define KBD_IS_IBM_AS400 */
+
+/* When using an original IBM AS_400 Keyboard you should enable both
+ * KBD_IS_FOCUS_9000 and KBD_IS_IBM_AS400
+ */
 
 #ifndef KBD_DEFMODE
 #define KBD_DEFMODE ((1 << VC_REPEAT) | (1 << VC_META))
@@ -228,6 +233,29 @@
 
 #define E1_PAUSE   119
 
+#ifdef KBD_IS_IBM_AS400 
+#define E0_GR      105
+#define E0_SIGN    43
+#define E0_LINE    108
+#define IBM_PF9    112
+#define IBM_PF10   113
+#define IBM_PF11   114
+#define IBM_PF12   115
+#define IBM_PF13   116
+#define IBM_PF14   117
+#define IBM_PF15   118
+#define IBM_PF16   120
+#define IBM_PF17   121
+#define IBM_PF18   122
+#define IBM_PF19   123
+#define IBM_PF20   124
+#define IBM_PF21   125
+#define IBM_PF22   126
+#define IBM_PF23   127
+#define IBM_PF24   119
+#endif
+
+
 /*
  * The keycodes below are randomly located in 89-95,112-118,120-127.
  * They could be thrown away (and all occurrences below replaced by 0),
@@ -262,6 +290,7 @@
 #define RGN3 126
 #define RGN4 127
 
+#ifndef KBD_IS_IBM_AS400
 static unsigned char high_keys[128 - SC_LIM] = {
   RGN1, RGN2, RGN3, RGN4, 0, 0, 0,                   /* 0x59-0x5f */
   0, 0, 0, 0, 0, 0, 0, 0,                            /* 0x60-0x67 */
@@ -270,6 +299,20 @@
   FOCUS_PF4, FOCUS_PF5, FOCUS_PF6, FOCUS_PF7,        /* 0x78-0x7b */
   FOCUS_PF8, JAP_86, FOCUS_PF10, 0                   /* 0x7c-0x7f */
 };
+#endif
+#ifdef KBD_IS_IBM_AS400
+static unsigned char high_keys[128 - SC_LIM] = {
+  FOCUS_PF2, FOCUS_PF3, FOCUS_PF4, FOCUS_PF5, FOCUS_PF6,
+  FOCUS_PF7, FOCUS_PF8,          /* 0x59-0x5f */
+  IBM_PF9, IBM_PF10, IBM_PF11, IBM_PF12,
+  IBM_PF13, IBM_PF14, IBM_PF15, IBM_PF16,    /* 0x60-0x67 */
+  IBM_PF17, IBM_PF18, IBM_PF19, IBM_PF20, IBM_PF21, 
+  IBM_PF22, IBM_PF23, E0_PGUP, /* 0x68-0x6f */
+  E0_GR, E0_RCTRL, E0_RALT, 0, E0_SIGN, 0, IBM_PF24, E0_LINE, /* 0x70-0x77 */
+  E0_UP, E0_DEL, E0_END, E0_INS,        /* 0x78-0x7b */
+  0, E0_RIGHT, E0_PGDN, E0_HOME                /* 0x7c-0x7f */
+};
+#endif
 
 /* BTC */
 #define E0_MACRO   112

--------------------------------schnipp-----------------------------------

This is an explaining README.  ( README.AS400 )

--------------------------------schnipp-----------------------------------

	Connecting and using a non standard IBM keyboard

				by 
			Edward von Flottwell 
		     edward@mudhoney.mitropa.com

If you would like to use an old IBM 122-key AS400 Terminal keyboard with Linux,
you should to do some small things:

1. Get your 'new' keyboard from a recycling company. 
   If you haven't done this already :-)
2. Solder a new 5pin DIN Connector instead of the RJ/??? Plug to the wire.
3. Patch the kernel and build an new one.
4. Load a new keymap and fit it to your needs.

I hope you managed the first step - so I'll continue with the second one:
Get a keyboard connector from your nearest electronic-shop, cut off the
original plug and you will hopefully find 4 colored wires: black, red,
yellow and white. Connect them in the following way with the DIN Plug:

	Wire	Signal	DIN	  ___	
	Black	+5V	4	 / 3 \  Soldering
	White	GND	2	(2   4)	View
	Red	Data	3	 \1^5/
	Yellow	Clock	1	  
			
BUT BE VERY CAREFUL!!! Connecting the wrong signals can damage or blow up 
your keyboard or your mainboard! The table above comes with NO warranty,
because I don't believe IBM always use the same type of cable :-}
You should open the keyboard and trace the wires to find the matching out.
And you should consult your mainboard for the keyboard-plug layout!

Now you're ready to switch on the computer... Some mainboard bioses will
produce a keyboard error. You can ignore this :-) BTW the F1 key is the 
very left of the function-key group near the tabulator key.
O.K., now you can try to type something, e.g. LILO: linux :-)
You will find out that some keys are swapped, others are dead. To make all
of the keys work apply the kernel-patch to 
/usr/src/linux/drivers/char/keyboard.c and comment the lines with

/* #define KBD_IS_FOCUS_9000 */
/* #define KBD_IS_IBM_AS400 */

out. Recompile and install the new kernel.

Now you need the last missing part: the keymap. At the end of this README
you will find an example for German users. How to make it fit to your
national keyboard is explained in the Keystroke-HOWTO. Most other questions 
about keymaps, scancodes,... are explained there, too. 
I would also suggest you read the manpages of showkey and loadkeys. 
Don't forget to load the keymap every time you boot, 
I prefer the rc.local shellscript doing this for me :-)

The keymap:

#
# File:        AS400.map
#

keycode   0 =
keycode   1 = Escape           Escape
	alt     keycode   1 = Meta_Escape
	shift alt keycode 1 = Meta_Escape

keycode   2 = one              exclam
	alt     keycode   2 = Meta_one
	shift alt keycode 2 = Meta_exclam

keycode   3 = two              quotedbl         twosuperior
	control keycode   3 = nul
	alt     keycode   3 = Meta_two
	shift alt keycode 3 = Meta_quotedbl

keycode   4 = three            section          threesuperior
	control keycode   4 = Escape
	alt     keycode   4 = Meta_three

keycode   5 = four             dollar           dollar
	control keycode   5 = Control_backslash
	alt     keycode   5 = Meta_four
	shift alt keycode 5 = Meta_dollar
    
keycode   6 = five             percent
	control keycode   6 = Control_bracketright
	alt     keycode   6 = Meta_five
	shift alt keycode 6 = Meta_percent
       
keycode   7 = six              ampersand
	control keycode   7 = Control_asciicircum
	alt     keycode   7 = Meta_six
	shift alt keycode 7 = Meta_ampersand

keycode   8 = seven            slash            braceleft
	control keycode   8 = Control_underscore
	alt     keycode   8 = Meta_seven
	shift alt keycode 8 = Meta_slash
  
keycode   9 = eight            parenleft        bracketleft
	control keycode   9 = Delete
	alt     keycode   9 = Meta_eight
	shift alt keycode 9 = Meta_parenleft

keycode  10 = nine             parenright       bracketright
	alt     keycode  10 = Meta_nine
 	control altgr keycode 10 = Control_bracketright
	shift alt keycode 10 = Meta_parenright

keycode  11 = zero             equal            braceright
	alt     keycode  11 = Meta_zero
	shift alt keycode 11 = Meta_equal

keycode  12 = ssharp           question         backslash
	control keycode  12 = Control_underscore
	alt     keycode  12 = Meta_minus
 	control altgr keycode  12 = Control_backslash
	shift alt keycode 12 = Meta_question
	alt altgr keycode 12 = Meta_backslash

keycode  13 = apostrophe       grave
	alt     keycode  13 = Meta_equal
	shift alt keycode 13 = Meta_grave

keycode  14 = Delete           Delete
	alt     keycode  14 = Meta_Delete

keycode  15 = Tab              Tab
	alt     keycode  15 = Meta_Tab

keycode  16 = q
	altgr	keycode 16 = at
	control keycode 16 = Control_q
	alt	keycode 16 = Meta_q
	shift alt keycode 16 = Meta_Q
	altgr	alt	keycode 16 = Meta_at

keycode  17 = w
	control keycode 17 = Control_w
	alt	keycode 17 = Meta_w
	shift alt keycode 17 = Meta_W

keycode  18 = e
	control keycode 18 = Control_e
	alt	keycode 18 = Meta_e
	shift alt keycode 18 = Meta_E

keycode  19 = r
	control keycode 19 = Control_r
	alt	keycode 19 = Meta_r
	shift alt keycode 19 = Meta_R

keycode  20 = t
	control keycode 20 = Control_t
	alt	keycode 20 = Meta_t
	shift alt keycode 20 = Meta_T

keycode  21 = z
	control keycode 21 = Control_z
	alt	keycode 21 = Meta_z
	shift alt keycode 21 = Meta_Z

keycode  22 = u
	control keycode 22 = Control_u
	alt	keycode 22 = Meta_u
	shift alt keycode 22 = Meta_U

keycode  23 = i
	alt	keycode 23 = Meta_i
	shift alt keycode 23 = Meta_I

keycode  24 = o
	control keycode 24 = Control_o
	alt	keycode 24 = Meta_o
	shift alt keycode 24 = Meta_O

keycode  25 = p
	control keycode 25 = Control_p
	alt	keycode 25 = Meta_p
	shift alt keycode 25 = Meta_P

keycode  26 = +udiaeresis       +Udiaeresis
	control keycode  26 = Escape
	alt     keycode  26 = Meta_bracketleft
	shift alt keycode 26 = Meta_braceleft

keycode  27 = plus             asterisk         asciitilde
	control keycode  27 = Control_bracketright
	alt     keycode  27 = Meta_bracketright
	shift alt keycode 27 = Meta_braceright

keycode  28 = Return
	alt     keycode  28 = 0x080d

keycode  29 = Caps_Lock

keycode  30 = a
	control keycode 30 = Control_a
	alt	keycode 30 = Meta_a
	shift alt keycode 30 = Meta_A

keycode  31 = s
	control keycode 31 = Control_s
	alt	keycode 31 = Meta_s
	shift alt keycode 31 = Meta_S

keycode  32 = d
	control keycode 32 = Control_d
	alt	keycode 32 = Meta_d
	shift alt keycode 32 = Meta_D

keycode  33 = f
	control keycode 33 = Control_f
	alt	keycode 33 = Meta_f
	shift alt keycode 33 = Meta_F

keycode  34 = g
	control keycode 34 = Control_g
	alt	keycode 34 = Meta_g
	shift alt keycode 34 = Meta_G

keycode  35 = h
	alt	keycode 35 = Meta_h
	shift alt keycode 35 = Meta_H

keycode  36 = j
	alt	keycode 36 = Meta_j
	shift alt keycode 36 = Meta_J

keycode  37 = k
	control keycode 37 = Control_k
	alt	keycode 37 = Meta_k
	shift alt keycode 37 = Meta_K

keycode  38 = l
	control keycode 38 = Control_l
	alt	keycode 38 = Meta_l
	shift alt keycode 38 = Meta_L

keycode  39 = +odiaeresis       +Odiaeresis
	alt     keycode  39 = Meta_semicolon
	shift alt keycode 39 = Meta_colon
	shift keycode  39 = Odiaeresis

keycode  40 = +adiaeresis       +Adiaeresis
	control keycode  40 = Control_g
	alt     keycode  40 = Meta_apostrophe
	shift alt keycode 40 = Meta_quotedbl

keycode  41 = asciicircum  degree
	control keycode  41 = nul
	alt     keycode  41 = Meta_grave
	shift alt keycode 41 = Meta_asciitilde

keycode  42 = Shift

keycode  43 = numbersign       apostrophe
	control keycode  43 = Control_backslash
	alt     keycode  43 = Meta_backslash
	shift alt keycode 43 = Meta_apostrophe

keycode  44 = y
	control keycode 44 = Control_y
	alt	keycode 44 = Meta_y
	shift alt keycode 44 = Meta_Y

keycode  45 = x
	control keycode 45 = Control_x
	alt	keycode 45 = Meta_x
	shift alt keycode 45 = Meta_X

keycode  46 = c
	control keycode 46 = Control_c
	alt	keycode 46 = Meta_c
	shift alt keycode 46 = Meta_C

keycode  47 = v
	control keycode 47 = Control_v
	alt	keycode 47 = Meta_v
	shift alt keycode 47 = Meta_V

keycode  48 = b
	control keycode 48 = Control_b
	alt	keycode 48 = Meta_b
	shift alt keycode 48 = Meta_B

keycode  49 = n
	control keycode 49 = Control_n
	alt	keycode 49 = Meta_n
	shift alt keycode 49 = Meta_N

keycode  50 = m
	altgr	keycode 50 = mu
	control keycode 50 = Control_m
	alt	keycode 50 = Meta_m
	shift alt keycode 50 = Meta_M

keycode  51 = comma            semicolon
	alt     keycode  51 = Meta_comma
	alt shift keycode 51 = Meta_semicolon

keycode  52 = period           colon
	alt     keycode  52 = Meta_period
	alt shift keycode 21 = Meta_colon

keycode  53 = minus            underscore
	control keycode  53 = Delete
	alt     keycode  53 = Meta_slash
	shift control keycode 53 = Control_underscore

keycode  54 = Shift

keycode  55 = KP_Multiply

keycode  56 = Control
     
keycode  57 = space            space
	control keycode  57 = nul
	alt     keycode  57 = Meta_space

keycode 58 = Control

keycode  59 = Escape           Escape
	alt     keycode   1 = Meta_Escape
	shift alt keycode 1 = Meta_Escape

keycode  60 = Control_z

keycode  61 = 

keycode  62 = Last_Console

keycode  63 = Control_a

keycode  64 = Up

keycode  65 = Control_backslash
	control keycode  99 = Control_backslash
	alt     keycode  99 = Control_backslash

keycode  66 = Control_c

keycode  67 = Control_q

keycode  68 = Control_s

keycode  69 = Num_Lock

keycode  70 = Control_r

keycode  71 = KP_7
	alt     keycode  71 = Ascii_7

keycode  72 = KP_8
	alt     keycode  72 = Ascii_8

keycode  73 = KP_9
	alt     keycode  73 = Ascii_9

keycode  74 = KP_Subtract

keycode  75 = KP_4
	alt     keycode  75 = Ascii_4

keycode  76 = KP_5
	alt     keycode  76 = Ascii_5

keycode  77 = KP_6
	alt     keycode  77 = Ascii_6

keycode  78 = KP_Enter

keycode  79 = KP_1
	alt     keycode  79 = Ascii_1

keycode  80 = KP_2
	alt     keycode  80 = Ascii_2

keycode  81 = KP_3
	alt     keycode  81 = Ascii_3

keycode  82 = KP_0
	alt     keycode  82 = Ascii_0

keycode  83 = KP_Comma
	altgr   control keycode  83 = Boot
	control alt     keycode  83 = Boot

keycode  84 = slash

keycode  85 = Down

keycode  86 = Left

keycode  87 = F11              F11              Console_23
	control keycode  87 = F11
	alt     keycode  87 = Console_11
	control	alt     keycode  87 = Console_11

keycode  88 = F1               F11              Console_13
	control keycode  88 = F1
	alt     keycode  88 = Console_1
	control	alt     keycode  88 = Console_1

keycode  89 = F2               F12              Console_14
	control keycode  89 = F2
	alt     keycode  89 = Console_2
	control	alt     keycode  89 = Console_2

keycode  90 = F3               F13              Console_15
	control keycode  90 = F3
	alt     keycode  90 = Console_3
	control	alt     keycode  90 = Console_3

keycode  91 = F4               F14              Console_16
	control keycode  91 = F4
	alt     keycode  91 = Console_4
	control	alt     keycode  91 = Console_4

keycode  92 = F5               F15              Console_17
	control keycode  92 = F5
	alt     keycode  92 = Console_5
	control	alt     keycode  92 = Console_5

keycode  93 = F6               F16              Console_18
	control keycode  93 = F6
	alt     keycode  93 = Console_6
	control	alt     keycode  93 = Console_6

keycode  94 = F7               F17              Console_19
	control keycode  94 = F7
	alt     keycode  94 = Console_7
	control	alt     keycode  94 = Console_7

keycode  95 = F8               F18              Console_20
	control keycode  95 = F8
	alt     keycode  95 = Console_8
	control	alt     keycode  95 = Console_8

keycode  96 = KP_Enter

keycode  97 = Alt

keycode  98 = KP_Divide

keycode  99 = 

keycode 100 = AltGr

keycode 101 = Break

keycode 102 = Find

keycode 103 = Up

keycode 104 = Prior
	shift   keycode 104 = Scroll_Backward

keycode 105 = less	greater		bar
 	alt     keycode  86 = Meta_less
 	shift alt keycode  86 = Meta_greater
	altgr alt keycode  86 = Meta_bar

keycode 106 = Right

keycode 107 = Select

keycode 108 = F25

keycode 109 = Next            
	shift   keycode 109 = Scroll_Forward  

keycode 110 = Insert          

keycode 111 = Remove          
	altgr   control keycode 111 = Boot            
	control alt     keycode 111 = Boot            

keycode 112 = F9
keycode 113 = F10
keycode 114 = F11
keycode 115 = F12
keycode 116 = Console_1
keycode 117 = Console_2
keycode 118 = Console_3
keycode 119 = 
keycode 120 = Console_4
keycode 121 = Console_5
keycode 122 = Console_6
keycode 123 = Console_7
keycode 124 = Console_8
keycode 125 = F21
keycode 126 = F22
keycode 127 = F23

# mom
string F1 = "\033[[A"
string F2 = "\033[[B"
string F3 = "\033[[C"
string F4 = "\033[[D"
string F5 = "\033[[E"
string F6 = "\033[17~"
string F7 = "\033[18~"
string F8 = "\033[19~"
string F9 = "\033[20~"
string F10 = "\033[21~"
string F11 = "\033[23~"
string F12 = "\033[24~"
string F13 = "\033[25~"
string F14 = "\033[26~"
string F15 = "\033[28~"
string F16 = "\033[29~"
string F17 = "\033[31~"
string F18 = "\033[32~"
string F19 = "\033[33~"
string F20 = "\033[34~"
string Find = "\033[1~"
string Insert = "\033[2~"
string Remove = "\033[3~"
string Select = "\033[4~"
string Prior = "\033[5~"
string Next = "\033[6~"
string F21 = ""
string F22 = ""
string F23 = ""
string F24 = ""
string F25 = ""
string F26 = ""