# PS/2 subsystem

The PS/2 subsystem, living in sys/ps2.fs, sits on top of a driver for a PS/2
controller which needs to provide a word that corresponds to this:

(ps2@?) ( -- keycode? f )
  Check if the controller has received a keycode from its keyboard (only
  keyboard is supported for now). If it has, f=1 and keycode is the key code
  received from the device. Otherwise, f=0.

  The driver is expected to combine bytes itself and yield each press/release as
  a single keycode. For example, it is not expected to yield $e0 alone, only as
  the MSB of a 16bit keycode.

(ps2@?) is an alias in which you must plug the word provided by the driver (for
example 8042kbd@? from drv/pc/ps28042.fs).

This unit defines the PS2Keyboard struct which sits on top of (ps2@?) and maps
a particular PS/2 character set to the incoming keycodes. It also provides
structbinds to the supported sets: ps2set1

Only Set 1 is supported for now.

## Global API

ps2mods ( -- flags )
  Yields a bit flags indicating which of the special "modifier" keys are
  currently pressed. "1" means pressed. The meaning of those bits is provided by
  the constants below.

  PS2_MOD_LSHIFT
  PS2_MOD_RSHIFT
  PS2_MOD_SHIFT
  PS2_MOD_LCTRL
  PS2_MOD_RCTRL
  PS2_MOD_CTRL
  PS2_MOD_LALT
  PS2_MOD_RALT
  PS2_MOD_ALT
  PS2_MOD_LGUI
  PS2_MOD_RGUI
  PS2_MOD_GUI
  PS2_MOD_CAPSLOCK
  PS2_MOD_NUMLOCK
  PS2_MOD_SCROLLLOCK
  PS2_MOD_UARROW
  PS2_MOD_DARROW
  PS2_MOD_LARROW
  PS2_MOD_RARROW

  For example, "ps2mods PS2_MOD_SHIFT and" tells whether any of the shift keys
  is currently pressed.

### Pull system

The PS/2 subsystem isn't pushed data by the driver, it pulls its information
from it. Therefore, the information in "ps2mods" is only as current as the last
"ps2@?" call.

## PS2Keyboard struct API

:?kc@ ( self -- keycode? f )
  Calls (ps2@?) and yields the result as-is, but also update the ps2mods flags.

:kc>ascii ( kc self -- is-released c-or-0 )
  Given a keycode "kc", yield the corresponding ASCII character.
  "is-released" is a flag being 1 if "kc" indicates that the key has been
  released and 0 if it indicates that the key has been pressed. Returns only
  actual ASCII. If kc yields a "special" key (>= $80), c=0.

:?key ( self -- c? f )
  Check whether a key has been pressed. If it has, convert the key code to
  ASCII and yield it as "c".
