The PS/2 protocol describes a 6-pin connector for connecting keyboards and mice to computer systems. Purple refers to keyboards, green refers to mice connectors. Dual ports exist too.

They were ubiquitous on many old computer systems from before the 2000s and before. We nowadays use USB for keyboard and mouse input.

Basic ideas

Derived from this great video by Ben Eater.

The PS/2 protocol has a 5/6 pin connector. Out of those, we have two unused pins, one for +VCC, and one for GND. This leaves us two useful ports: one is for the device’s internal clock, and the other is for the data, which is compared against the clock.

Each PS/2 data packet consists of 11 bits sent serially. Out of these, we have a start, end, parity bit, as well as 8 data bits.

Keyboard

The keyboard outputs are 8-bit (or 2 hexadecimal number) wide scan codes. A guide is below.1 There are actually three different possible sets of scan codes. Most keyboards use a similar set but it’s possible to have one that by default uses a different set.

Mouse

There are 4 modes: reset, stream, and some others. By default stream is off so we need to force it on.

The - and -velocity are signed numbers. We can’t move too fast.

todo for controller:

  • figure out data packet stream
    • light up LEDR for l/r click

Documentation and resources

Footnotes

  1. From Prof Paul Chow/Jonathan Rose’s websites.