From d98751e40faf3ae9121aa722fc41b0457f000b6e Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 18 Apr 2024 03:51:56 +0200 Subject: [PATCH] Added the ability to enable/disable the KBC (used by the FDC37C93x Super I/O chips). --- src/device/kbc_at.c | 15 +++++++++++++-- src/include/86box/keyboard.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/device/kbc_at.c b/src/device/kbc_at.c index bc4a1f366..d8b308d6b 100644 --- a/src/device/kbc_at.c +++ b/src/device/kbc_at.c @@ -1986,6 +1986,18 @@ kbc_at_close(void *priv) free(dev); } +void +kbc_at_handler(int set, void *priv) +{ + io_removehandler(0x0060, 1, kbc_at_read, NULL, NULL, kbc_at_write, NULL, NULL, priv); + io_removehandler(0x0064, 1, kbc_at_read, NULL, NULL, kbc_at_write, NULL, NULL, priv); + + if (set) { + io_sethandler(0x0060, 1, kbc_at_read, NULL, NULL, kbc_at_write, NULL, NULL, priv); + io_sethandler(0x0064, 1, kbc_at_read, NULL, NULL, kbc_at_write, NULL, NULL, priv); + } +} + static void * kbc_at_init(const device_t *info) { @@ -2003,8 +2015,7 @@ kbc_at_init(const device_t *info) if (info->flags & DEVICE_PCI) dev->misc_flags |= FLAG_PCI; - io_sethandler(0x0060, 1, kbc_at_read, NULL, NULL, kbc_at_write, NULL, NULL, dev); - io_sethandler(0x0064, 1, kbc_at_read, NULL, NULL, kbc_at_write, NULL, NULL, dev); + kbc_at_handler(1, dev); timer_add(&dev->kbc_poll_timer, kbc_at_poll, dev, 1); timer_add(&dev->pulse_cb, pulse_poll, dev, 0); diff --git a/src/include/86box/keyboard.h b/src/include/86box/keyboard.h index 759fad714..0d8b2e745 100644 --- a/src/include/86box/keyboard.h +++ b/src/include/86box/keyboard.h @@ -276,6 +276,7 @@ extern int keyboard_isfsexit_up(void); extern int keyboard_ismsexit(void); extern void keyboard_set_is_amstrad(int ams); +extern void kbc_at_handler(int set, void *priv); extern uint8_t kbc_at_dev_queue_pos(atkbc_dev_t *dev, uint8_t main); extern void kbc_at_dev_queue_add(atkbc_dev_t *dev, uint8_t val, uint8_t main); extern void kbc_at_dev_reset(atkbc_dev_t *dev, int do_fa);