KGI, the kernel graphics interface, is a set of loadable kernel modules with these goals:
KGI supports the multiple monitors and keyboards by creating groups of 16 ttys and 16 graph devices. One can load a kernel driver for a keyboard, which is then virtualized into 16 virtual keyboards. One can assign these keyboards to a set of 16 tty devices. One can load a kernel driver for a video card, which is virtualized into 16 virtual displays. One can then assign these displays to a set of 16 tty and 16 graph devices. One can also load a mouse driver module, which virtualizes a mouse into a set of 16 virtual mice, which one can assign to a set of 16 graph devices. If you load two independent keyboard drivers into the same set of 16 ttys, the characters from the two will be merged. Likewise if you load two mouse drivers into the same 16 graph devices.
KGI allows libggi to draw in the following manner. Libggi opens one of the graph devices, yielding a file descriptor. The file descriptor implements a few ioctls that perform simple drawing operations. There aren't many of these operations, but they are enough to do unaccelerated graphics. In addition, the file descriptor may support a half dozen device-specific "acceleration" functions. These are usually powerful, general operations like "bitblit" or "mmap the video registers". Libggi uses these when they're available. Libggi abstracts over the variation in the kernel display drivers, presenting a consistent interface to the user.