IBM PC Keyboard Converter - mcaple/tmk_keyboard GitHub Wiki

TMK IBM PC Keyboard Converter

Table of Contents

TMK Converter

You can buy prebuilt conveter here and support this project.

Resources

Keyboard Discrimination

This section explains how the converter determines proper protocol and scan code set for keyboard. The converter need to do that before starting to receive and translate scan codes from keyboard.

Keyboard ID

After startup the converter sends 0xF2 command to get keyboard ID and sees how the keyboard responds to the command.

Response from keyboard:

  • XT keyboard doesn’t support any command and returns no response.

  • AT keyboard should respond with 0xFA to the command but returns no keyboard ID.

  • PS/2 keyboard should respond with 0xFA to the command, followd by keyboard ID, such as 0xAB86.

  • Terminal keyboard should respond with 0xFA to the command, followed by keyboard ID, such as 0xBFBF.

  • PS/2 mouse should respond with 0xFA to the command, followd by single-byte ID 0x00.

Now we can dscriminate the keyboard and determine suitable protocol and scan code set as described below.

Protocol

  • Signals from XT keyboard are recognized by XT protocol.

  • Signals from AT, PS/2 and Terminal keyboard are recognized by AT protocol.

  • Signals from PS/2 mouse are also recognized by AT protocol.

Scan code Set

  • Scan codes from XT keyboard are handled as CodeSet1.

  • Scan codes from AT and PS/2 keyboard are handled as CodeSet2.

  • Scan codes from Terminal keyhboard are handled as CodeSet3.

Default Mapping

XT - Scan Code Set 1

XT 83-key

,-------.  ,--------------------------------------------------------------------------.
| F1| F2|  |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  BS  |NumLck |ScrLck |
|-------|  |--------------------------------------------------------------------------|
| F3| F4|  | Tab |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ] |   |  7|  8|  9|  -|
|-------|  |------------------------------------------------------|Ent|---------------|
| F5| F6|  | Ctrl |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  `|   |  4|  5|  6|   |
|-------|  |----------------------------------------------------------------------|   |
| F7| F8|  |Shif|  \|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift|  *|  1|  2|  3|  +|
|-------|  |----------------------------------------------------------------------|   |
| F9|F10|  |  Alt  |               Space                  |CapsLck|   0   |   .   |   |
`-------'  `--------------------------------------------------------------------------'
,-------.  ,--------------------------------------------------------------------------.
| 3B| 3C|  | 01| 02| 03| 04| 05| 06| 07| 08| 09| 0A| 0B| 0C| 0D|  0E  |  45   |  46   |
|-------|  |--------------------------------------------------------------------------|
| 3D| 3E|  | 0F  | 10| 11| 12| 13| 14| 15| 16| 17| 18| 19| 1A| 1B |   | 47| 48| 49| 4A|
|-------|  |------------------------------------------------------| 1C|---------------|
| 3F| 40|  | 1D   | 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 28| 29|   | 4B| 4C| 4D|   |
|-------|  |----------------------------------------------------------------------|   |
| 41| 42|  | 2A | 2B| 2C| 2D| 2E| 2F| 30| 31| 32| 33| 34| 35|  36 | 37| 4F| 50| 51| 4E|
|-------|  |----------------------------------------------------------------------|   |
| 43| 44|  |  38   |              39                      |  3A   |  52   |  53   |   |
`-------'  `--------------------------------------------------------------------------'

Full-key

        ,-----------------------------------------------.
        |F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24|
,---.   |-----------------------------------------------|     ,-----------.     ,-----------.
|Esc|   |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|     |PrS|ScL|Pau|     |VDn|VUp|Mut|
`---'   `-----------------------------------------------'     `-----------'     `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
|  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|JPY|Bsp| |Ins|Hom|PgU| |NmL|  /|  *|  -|
|-----------------------------------------------------------| |-----------| |---------------|
|Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|  \  | |Del|End|PgD| |  7|  8|  9|  +|
|-----------------------------------------------------------| `-----------' |---------------|
|CapsL |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  #|Entr|               |  4|  5|  6|KP,|
|-----------------------------------------------------------|     ,---.     |---------------|
|Shft| ^a|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /| RO|Shift |     |Up |     |  1|  2|  3|Ent|
|-----------------------------------------------------------| ,-----------. |---------------|
|Ctl|Gui|Alt|MHEN|     Space      |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| |      0|  .|KP=|
`-----------------------------------------------------------' `-----------' `---------------'
        ,-----------------------------------------------.
        | 64| 65| 66| 67| 68| 69| 6A| 6B| 6C| 6D| 6E| 76|
,---.   |-----------------------------------------------|     ,-----------.     ,-----------.
| 01|   | 3B| 3C| 3D| 3E| 3F| 40| 41| 42| 43| 44| 57| 58|     |*37| 46|*46|     |*2E|*30|*20|
`---'   `-----------------------------------------------'     `-----------'     `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
| 29| 02| 03| 04| 05| 06| 07| 08| 09| 0A| 0B| 0C| 0D| 7D| 0E| |*52|*47|*49| | 45|*35| 37| 4A|
|-----------------------------------------------------------| |-----------| |---------------|
| 0F  | 10| 11| 12| 13| 14| 15| 16| 17| 18| 19| 1A| 1B|  2B | |*53|*4F|*51| | 47| 48| 49| 4E|
|-----------------------------------------------------------| `-----------' |---------------|
| 3A   | 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 28| 56| 1C |               | 4B| 4C| 4D| 7E|
|-----------------------------------------------------------|     ,---.     |---------------|
| 2A | ^a| 2C| 2D| 2E| 2F| 30| 31| 32| 33| 34| 35| 73|  36  |     |*48|     | 4F| 50| 51|*1C|
|-----------------------------------------------------------| ,-----------. |---------------|
| 1D|*5B| 38| 7B |      39        | 79 | 70 |*38|*5C|*5D|*1D| |*4B|*50|*4D| |     52| 53| 59|
`-----------------------------------------------------------' `-----------' `---------------'
*: E0-prefixed codes. See cs1_e0code() for remapping to unimap array.
PrintScreen: E0 37 or 54(with Alt) -> 54
Pause: E1 1D 45 or E0 46(with Ctrl) -> 55
^a: ISO backslash and US backslash use identical code 2B. [3], [a]
Unsupported codes or error -> 00. UNIMAP_NUBS is unused.

AT - Scan Code Set 2

AT 84-key

,-------. ,-----------------------------------------------------------. ,---------------.
| F1| F2| |  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  \| BS| |Esc|NmL|ScL|PrS|
|-------| |-----------------------------------------------------------| |---------------|
| F3| F4| |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|  App| |  7|  8|  9|  *|
|-------| |-----------------------------------------------------------| |-----------|---|
| F5| F6| |LCtrl |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Lef| Ret| |  4|  5|  6|  -|
|-------| |-----------------------------------------------------------| |---------------|
| F7| F8| |Shif|KAN|  Z|  X|  C|  V|  B|  N|  M|  ,|  ,|  /| RO| Shift| |  1|  2|  3|  +|
|-------| |-----------------------------------------------------------| |-----------|---|
| F9|F10| | Alt|    | Gui|          Space              | Ins|    |Caps| |  #|  0|  .|F11|
`-------' `----'    `---------------------------------------'    `----' `---------------'
,-------. ,-----------------------------------------------------------. ,---------------.
| 05| 06| | 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 5D| 66| | 76| 77| 7E| 84|
|-------| |-----------------------------------------------------------| |---------------|
| 04| 0C| | 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B| -5C | | 6C| 75| 7D| 7C|
|-------| |-----------------------------------------------------------| |---------------|
| 03| 0B| | 14   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52|-53| 5A | | 6B| 73| 74| 7B|
|-------| |-----------------------------------------------------------| |---------------|
|*83| 0A| | 12 |-13| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A|-51|  59  | | 69| 72| 7A| 79|
|-------| |-----------------------------------------------------------| |---------------|
| 01| 09| | 11  |   | -19|        29                   | -39|   | 58  | |-68| 70| 71|-78|
`-------' `-----'   `---------------------------------------'   `-----' `---------------'
-: Hidden keys

Full-key

        ,-----------------------------------------------.
        |F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24|
,---.   |-----------------------------------------------|     ,-----------.     ,-----------.
|Esc|   |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|     |PrS|ScL|Pau|     |VDn|VUp|Mut|
`---'   `-----------------------------------------------'     `-----------'     `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
|  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|JPY|Bsp| |Ins|Hom|PgU| |NmL|  /|  *|  -|
|-----------------------------------------------------------| |-----------| |---------------|
|Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|  \  | |Del|End|PgD| |  7|  8|  9|  +|
|-----------------------------------------------------------| `-----------' |---------------|
|CapsL |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '| ^a|Entr|               |  4|  5|  6|KP,|
|-----------------------------------------------------------|     ,---.     |---------------|
|Shft|  <|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /| RO|Shift |     |Up |     |  1|  2|  3|Ent|
|-----------------------------------------------------------| ,-----------. |---------------|
|Ctl|Gui|Alt|MHEN|     Space      |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| |  #|  0|  .|KP=|
`-----------------------------------------------------------' `-----------' `---------------'
        ,-----------------------------------------------.
        | 08| 10| 18| 20| 28| 30| 38| 40| 48| 50| 57| 5F|
,---.   |-----------------------------------------------|     ,-----------.     ,-----------.
| 76|   | 05| 06| 04| 0C| 03| 0B| 83| 0A| 01| 09| 78| 07|     |+7C| 7E|+77|     |*21|*32|*23|
`---'   `-----------------------------------------------'     `-----------'     `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
| 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 6A| 66| |*70|*6C|*7D| | 77|*4A| 7C| 7B|
|-----------------------------------------------------------| |-----------| |---------------|
| 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B|  5D | |*71|*69|*7A| | 6C| 75| 7D| 79|
|-----------------------------------------------------------| `-----------' |---------------|
| 58   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| ^a| 5A |               | 6B| 73| 74| 6D|
|-----------------------------------------------------------|     ,---.     |---------------|
| 12 | 61| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A| 51|  59  |     |*75|     | 69| 72| 7A|*5A|
|-----------------------------------------------------------| ,-----------. |---------------|
| 14|*1F| 11| 67 |     29         | 64 | 13 |*11|*27|*2F|*14| |*6B|*72|*74| | 68| 70| 71| 63|
`-----------------------------------------------------------' `-----------' `---------------'
*: E0-prefixed codes. See cs2_e0code() for remapping to unimap array.
+: Special codes sequence
^a: ISO hash key and US backslash use identical code 5D.
51, 63, 68, 6A, 6D: Hidden keys in IBM model M [6]

Terminal - Scan Code Set 3

122-key

              ,-----------------------------------------------.
              |F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24|
              |-----------------------------------------------|
              |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|
              `-----------------------------------------------'
,-------. ,-----------------------------------------------------------. ,-----------. ,---------------.
|Mut|HEN| |  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|JPY| BS| |  /|PgU|PgD| |Esc|NmL|ScL|  *|
|-------| |-----------------------------------------------------------| |-----------| |---------------|
|VUp|Pau| |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \| |End|Ins|Del| |  7|  8|  9|  +|
|-------| |-----------------------------------------------------------| `-----------' |-----------|---|
|VDn|MHE| |CapsL |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  #| Ret| |JPY|Up |  #| |  4|  5|  6|  -|
|-------| |-----------------------------------------------------------| ,-----------. |---------------|
|PrS|App| |Shif|  \|  Z|  X|  C|  V|  B|  N|  M|  ,|  ,|  /| RO| Shift| |Lef|Hom|Rig| |  1|  2|  3|Ent|
|-------| |-----------------------------------------------------------| `-----------' |-----------|---|
|Gui|Gui| |Ctrl|    |Alt |          Space              |Alt |    |Ctrl| | RO|Dow|KAN| |  ,|  0|  .|  =|
`-------' `----'    `---------------------------------------'    `----'  ---`---'---  `---------------'
              ,-----------------------------------------------.
              | 08| 10| 18| 20| 28| 30| 38| 40| 48| 50| 57| 5F|
              |-----------------------------------------------|
              | 07| 0F| 17| 1F| 27| 2F| 37| 3F| 47| 4F| 56| 5E|
              `-----------------------------------------------'
,-------. ,-----------------------------------------------------------. ,-----------. ,---------------.
| 05| 06| | 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 5D| 66| | 67| 6E| 6F| | 76| 77| 7E|*84|
|-------| |-----------------------------------------------------------| |-----------| |---------------|
| 04| 0C| | 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B|  5C | | 64| 65| 6D| | 6C| 75| 7D| 7C|
|-------| |-----------------------------------------------------------| `-----------' |---------------|
| 03| 0B| | 14   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 53| 5A | |-26| 63|-25| | 6B| 73| 74| 7B|
|-------| |-----------------------------------------------------------| ,-----------. |---------------|
|*83| 0A| | 12 | 13| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A| 51|  59  | | 61| 62| 6A| | 69| 72| 7A| 79|
|-------| |-----------------------------------------------------------| `-----------' |---------------|
| 01| 09| | 11  |   |19  |        29                   |39  |   | 58  | |-16| 60|-1E| | 68| 70| 71| 78|
`-------' `-----'   `---------------------------------------'   `-----'  ---`---'---  `---------------'
*: Special codes remapped 83->02, 84->7F
-: G80-2551 specific 80-prefixed codes remapped: 26->5D, 25->53, 16->51, 1E->00
51, 5C, 5D, 68, 78: Hidden keys in IBM 122-key terminal keyboard [7]

101-key/102-key

,---.   ,---------------. ,---------------. ,---------------. ,-----------. 
|F13|   | F1| F2| F3| F4| | F5| F6| F7| F8| | F9|F10|F11|F12| |F23|F24|Hom| 
`---'   `---------------' `---------------' `---------------' `-----------' 
,-----------------------------------------------------------. ,-----------. ,---------------.
|  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|JPY|Bsp| |  /|PgU|PgD| |Esc|NmL|ScL|  *|
|-----------------------------------------------------------| |-----------| |---------------|
|Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|  \  | |End|Ins|Del| |  7|  8|  9|  +|
|-----------------------------------------------------------| `-----------' |-----------|---|
|CapsL |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  #|Entr|               |  4|  5|  6|  -|
|-----------------------------------------------------------|     ,---.     |---------------|
|Shft|  <|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /| RO|Shift |     |Up |     |  1|  2|  3|Ent|
|-----------------------------------------------------------| ,-----------. |-----------|---|
|Ctrl|    |Alt |          Space              |Alt |    |Ctrl| |Lef|Dow|Rig| |  ,|  0|  .|  =|
`----'    `---------------------------------------'    `----' `-----------' `---------------'
,---.   ,---------------. ,---------------. ,---------------. ,-----------.
| 08|   | 07| 0F| 17| 1F| | 27| 2F| 37| 3F| | 47| 4F| 56| 5E| | 57| 5F| 62|
`---'   `---------------' `---------------' `---------------' `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
| 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 5D| 66| | 67| 6E| 6F| | 76| 77| 7E| 84|
|-----------------------------------------------------------| |-----------| |---------------|
| 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B|  5C | | 64| 65| 6D| | 6C| 75| 7D| 7C|
|-----------------------------------------------------------| `-----------' |---------------|
| 14   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 53| 5A |               | 6B| 73| 74| 7B|
|-----------------------------------------------------------|     ,---.     |---------------|
| 12 | 13| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A| 51|  59  |     | 63|     | 69| 72| 7A| 79|
|-----------------------------------------------------------| ,-----------. |---------------|
| 11  |   |19  |        29                   |39  |   | 58  | | 61| 60| 6A| | 68| 70| 71| 78|
`-----'   `---------------------------------------'   `-----' `-----------' `---------------'
- https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#ibm-terminal-101-key102-key

IBM 5576-001

             ,---------------.  ,---------------.  ,---------------.
             |F13|F14|F15|F16|  |F17|F18|F19|F20|  |F21|F22|F23|F24|
             |----------------  |----------------  |---------------|
             | F1| F2| F3| F4|  | F5| F6| F7| F8|  | F9|F10|F11|F12|
             `---------------'  `---------------'  `---------------'
,-------. ,-----------------------------------------------------------. ,-----------. ,---------------.
|Mut|HEN| |  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|JPY| BS| |  /|PgU|PgD| |Esc|NmL|ScL|  *|
|-------| |-----------------------------------------------------------| |-----------| |---------------|
|VUp|Pau| |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|     | |End|Ins|Del| |  7|  8|  9|  +|
|-------| |------------------------------------------------------`    | `-----------' |-----------|---|
|VDn|MHE| |CapsL |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  #| Ret|     |Up |     |  4|  5|  6|   |
|-------| |-----------------------------------------------------------| ,-----------. |-----------|   |
|PrS|App| |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  ,|  /| RO| Shift| |Lef|Hom|Rig| |  1|  2|  3|Ent|
|-------| |-----------------------------------------------------------| `-----------' |-----------|   |
|Gui|Gui| |LCtrl|  |LALt |  P,   |  Spc  |  P=   |RAlt |        |RCtrl|     |Dow|     |  ,|  0|  .|   |
`-------' `-----'  `-----------------------------------'        `-----'     `---'     `---------------'
             ,---------------.  ,---------------.  ,---------------.
             | 08| 10| 18| 20|  | 28| 30| 38| 40|  | 48| 50| 57| 5F|
             |----------------  |----------------  |---------------|
             | 07| 0F| 17| 1F|  | 27| 2F| 37| 3F|  | 47| 4F| 56| 5E|
             `---------------'  `---------------'  `---------------'
,-------. ,-----------------------------------------------------------. ,-----------. ,---------------.
| 05| 06| | 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55|+13| 66| | 67| 6E| 6F| |+7E| 77|+76| 84|
|-------| |-----------------------------------------------------------| |-----------| |---------------|
| 04| 0C| | 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B|     | | 64| 65| 6D| | 6C| 75| 7D| 7C|
|-------| |------------------------------------------------------`    | `-----------' |---------------|
| 03| 0B| | 14   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 53| 5A |     | 63|     | 6B| 73| 74|   |
|-------| |-----------------------------------------------------------| ,-----------. |-----------|   |
| 83| 0A| | 12     | 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A|+5C|  59  | | 61| 62| 6A| | 69| 72| 7A| 79|
|-------| |-----------------------------------------------------------| `-----------' |-----------|   |
| 01| 09| | 11  |  | 19  | +85   |  29   | +86   | 39  |        | 58  |     | 60|     |     70| 71|   |
`-------' `-----'  `-----------------------------------'        `-----'     `---'     `---------------'
+: different from IBM 122-key Terminal
https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#ibm-5576-code-set-3

Full-key

        ,-----------------------------------------------.
        |F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24|
,---.   |-----------------------------------------------|     ,-----------.     ,-----------.
|Esc|   |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|     |PrS|ScL|Pau|     |VDn|VUp|Mut|
`---'   `-----------------------------------------------'     `-----------'     `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
|  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|JPY|Bsp| |Ins|Hom|PgU| |NmL|  /|  *|  -|
|-----------------------------------------------------------| |-----------| |---------------|
|Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|  \  | |Del|End|PgD| |  7|  8|  9|  +|
|-----------------------------------------------------------| `-----------' |---------------|
|CapsL |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  #|Entr|               |  4|  5|  6|KP,|
|-----------------------------------------------------------|     ,---.     |---------------|
|Shft|  <|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /| RO|Shift |     |Up |     |  1|  2|  3|Ent|
|-----------------------------------------------------------| ,-----------. |---------------|
|Ctl|Gui|Alt|MHEN|     Space      |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| |      0|  .|KP=|
`-----------------------------------------------------------' `-----------' `---------------'
        ,-----------------------------------------------.
        | 08| 10| 18| 20| 28| 30| 38| 40| 48| 50| 57| 5F|
,---.   |-----------------------------------------------|     ,-----------.     ,-----------.
| 76|   | 07| 0F| 17| 1F| 27| 2F| 37| 3F| 47| 4F| 56| 5E|     | 83| 7E| 6C|     | 03| 04| 05|
`---'   `-----------------------------------------------'     `-----------'     `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
| 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 5D| 66| | 65| 62| 6E| | 77| 67| 84| 7B|
|-----------------------------------------------------------| |-----------| |---------------|
| 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B|  5C | | 6D| 64| 6F| | 6C| 75| 7D| 7C|
|-----------------------------------------------------------| `-----------' |---------------|
| 14   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 53| 5A |               | 6B| 73| 74| 68|
|-----------------------------------------------------------|     ,---.     |---------------|
| 12 | 13| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A| 51|  59  |     | 63|     | 69| 72| 7A| 79|
|-----------------------------------------------------------| ,-----------. |---------------|
| 11|*8B| 19|*85 |      29        |*86 |*87 | 39|*8C|*8D| 58| | 61| 60| 6A| |     70| 71| 78|
`-----------------------------------------------------------' `-----------' `---------------'
*: Special codes remmaped

AT/XT Auto-Switching

AA with parity error

Some keyboards place tricky signaling to send AA(BAT OK) with prity error at startup to decide between AT and XT protocol.

         MSB               LSB
Clock:   A 9 8 7 6 5 4 3 2 1 0
Data:    1 0 1 0 1 0 1 0 1 0 0
AT:      S p D D D D D D D D s
XT:      D D D D D D D D s i i
(s:start bit, p:parity bit, S:stop bit, D:data bit, i:ignored)

TMK Converter displays it as ISR:AA90 on debug console.

  • AT host is expected to detetect its parity error and response with FE(Resend) or FF(Reset).

  • XT host is expected to ignore two preceding 0 before start bit and recognize it as AA.

Keyboards with this feature may have incompatibility with some of converters and hosts.

Copam K-430

This realizes protocol auto-switching by sending AA with parity error on AT protocol first. If host/converter doesn’t detect and recover the error with FE(Resend) command, the keyboard switches to XT protocol immediately and no longer receive AT command.

As of now TMK converter communicates with the keyboard on XT protocol.

This keyboard can work with some of PS/2 converters in the market at least.

Debug log
TMK:147575/LUFA:d6a7df

USB configured.

Loop start.
I558
620 PRT:10 ISR:AA90 rAA
624 PRT:22 ISR:AAC0 rAA A3559 wFF R R R R R R R R R R
3951 ERR:11 ISR:0000 X4452 rAA W4456 wF2 R R R R R R R R R R R5349
ID:FFFF(XT)
5349 ERR:11 ISR:AAC0 S5350 L5350 r1F r9F r20 rA0
https://geekhack.org/index.php?topic=111510.msg3086764#msg3086764

BTC-5161

BTC-5161 seems to require command(Reset or Resend) to start AT mode.

The keyboard sends AA with parity error repeatedly at startup to be recognized by both AT and XT host.

  • AT host reads the AA with detecting parity error and should send FE resend(or FF reset) command to recover the error.

  • XT host reads the data as AA with ingoring two preceding 0.

It sends the AA reapeadly at very high rate until receiving a command from host and this makes converter buffer full.

The keyboard speaks normal AT protocol after receiving FF command. It is not clear about how to turn it into XT protocol, XT reset is needed perhaps.

TMK converter communicates with the keyboard on AT protocol.

Debug log
ERR:40 ISR:AA90
ERR:40 ISR:AA90
...
ERR:40 ISR:AA90
ERR:40 ISR:AA90
ERR:40 ISR:AA90 A3230 wFF ISR:5520 rFA rAA W3299 wF2 b:FAAB rFA rAB r83 R3809
ID:AB83(AT) S3810 wED rFA w02 rFA L3821
https://geekhack.org/index.php?topic=103648.msg3047128#msg3047128
TMK:8ad6bfa2/LUFA


USB configured.

Keyboard start.

ERR:40 ISR:AA90
PRT:10 ISR:0000 I223
PRT:10 ISR:0000 rAA A224 wFF rFA rAA W295 wF2 b:FAAB rFA rAB r83 R805
ID:AB83(AT) S805 wED rFA w00 rFA L822
Device disconnected.
Waiting for new device:..
Listening:


TMK:8ad6bfa2/LUFA


USB configured.

Keyboard start.

ERR:40 ISR:AA90
PRT:10 ISR:0000 I419
ERR:40 ISR:AA90
PRT:10 ISR:0000 !FULL! rFF A420 wFF rFA rAA W491 wF2 b:FAAB rFA rAB r83 R1001
ID:AB83(AT) S1002 wED rFA w00 rFA L1018
https://geekhack.org/index.php?topic=103648.msg3047679#msg3047679

IBM Enhanced Keyboard

Some of Model M IBM Enhanced keyboards is known to be compatible to both AT and XT protocol.

PS/2 Mode 1 and Mode 2

Keyboard Mode Selection

The keyboard modes establish the line protocol needed for the keyboard to communicate with the host system. Based on the signals found on the keyboard 'clock' and 'data' lines immediately following POR, the keyboard selects either Mode 1 or Mode 2 for communication with the attached system unit.

The following describes the keyboard 'clock' and 'data' signal conditions necessary to establish each mode.

If the 'clock' line is active (high) immediately after POR, the keyboard sets up for Mode 1 operation. It then waits for the 'clock' line to become inactive (low), executes the basic assurance test (BAT), and returns the completion code. If the 'clock' line is inactive (low) immediately after POR, the keyboard executes the BAT, waits for the 'clock' line to become active (high), and sends the completion code in Mode 2 protocol. If the system has not made the 'data' line inactive within 40 microseconds, Mode 2 operation is established. If the 'data' line has become inactive within this time, Mode 1 is established.

Mode 1 uses scan code set 1 only. Mode 2 uses scan code set 2, but can be switched to scan code set 1 or scan code set 3 using the Select Alternate Scan Codes command. Note: After the mode is set, it can be changed only by another 'power-on-reset.'

P.4-4 IBM 7531/7532 Technical Reference

where Mode 1 indicates XT protocol and Mode 2 does AT.

Industrial version and some version of Model M are supposed to support both XT and AT.

IBM 1391401

Controller board: 1392993

Just tested briefly but this keyboard doesn’t seems to support the protocol switching. 2021-09-14

Discussions

Commodore PC 30/40 III

In fact, I’ve got an 102-key IBM PS/2 keyboard (Model M, 1391409) from 1991, and it actually worked in my early-BIOS XT too! However, as expected, the LED’s doesn’t work.

⚠️ **GitHub.com Fallback** ⚠️