3 * Intel 8042 keyboard controller library.
4 * (C) 2008-2012 Jonathan Campbell.
5 * Hackipedia DOS library.
7 * This code is licensed under the LGPL.
8 * <insert LGPL legal text here>
10 * Compiles for intended target environments:
11 * - MS-DOS [pure DOS mode, or Windows or OS/2 DOS Box]
13 * On "IBM compatible" hardware the keyboard controller is responsible for
14 * receiving scan codes from the keyboard. On newer (post 1990) systems,
15 * the controller also handles PS/2 mouse input and communication (AUX).
17 * Note that on recent hardware (1999 or later) it's entirely possible the
18 * BIOS is using System Management Mode and/or a USB mouse & keyboard to
19 * fake 8042 I/O ports and communications for backwards compatibility. */
22 #include <conio.h> /* this is where Open Watcom hides the outp() etc. functions */
25 #include <hw/cpu/cpu.h>
26 #include <hw/8042/8042.h>
28 unsigned char k8042_flags = 0;
29 unsigned char k8042_last_status = 0;
31 /* drain the 8042 buffer entirely */
32 void k8042_drain_buffer() {
37 c = inp(K8042_STATUS);
39 k8042_last_status = c;
42 /* probe for the existence of the 8042 controller I/O ports.
43 * obviously as a DOS program the ports are there. but someday...
44 * it's possible the newer BIOSes will stop emulating it sooner or later. */
46 if (inp(K8042_STATUS) == 0xFF)