From 830082c1b0219b95ad4f38d1f0270fd210d9b511 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Mon, 5 Jun 2023 22:38:57 +0100 Subject: Add a keyboard driver Defines for some of the keys. --- src/keyb.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/keyb.c (limited to 'src/keyb.c') diff --git a/src/keyb.c b/src/keyb.c new file mode 100644 index 0000000..3862871 --- /dev/null +++ b/src/keyb.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include + +volatile uint8_t keys[0xff] = { 0 }; + +static _go32_dpmi_seginfo old_handler, new_handler; + +static void keyb_handler() +{ + uint8_t k = inportb(0x60); + + if (k & 128) + keys[k & 127] = 0; + else + keys[k] = 1; +} + +void keyb_init() +{ + _go32_dpmi_get_protected_mode_interrupt_vector(9, &old_handler); + new_handler.pm_offset = (unsigned long)keyb_handler; + new_handler.pm_selector = _go32_my_cs(); + _go32_dpmi_chain_protected_mode_interrupt_vector(9, &new_handler); +} + +void keyb_free() +{ + if (_go32_dpmi_set_protected_mode_interrupt_vector(9, &old_handler) == -1) + fprintf(stderr, "Failed to free the keyb :(\n"); +} -- cgit v1.2.3