From 8c5829061b2294ed37a6a0ec312f424ae68ce902 Mon Sep 17 00:00:00 2001 From: AJR Date: Tue, 10 Oct 2023 10:42:45 -0400 Subject: 8042kbdc: Unbundle keyboard from device and make it optional --- src/devices/machine/8042kbdc.cpp | 13 ++++--------- src/devices/machine/8042kbdc.h | 9 +++++---- src/devices/machine/fdc37c93x.cpp | 6 ++++++ src/devices/machine/pc87306.cpp | 5 +++++ src/devices/machine/sis950_lpc.cpp | 6 ++++++ src/devices/machine/w83977tf.cpp | 8 +++++++- src/mame/be/bebox.cpp | 4 ++++ src/mame/pc/nforcepc.cpp | 5 +++++ src/mame/shared/pcshare.cpp | 5 +++++ src/mame/televideo/tv990.cpp | 5 +++++ 10 files changed, 52 insertions(+), 14 deletions(-) diff --git a/src/devices/machine/8042kbdc.cpp b/src/devices/machine/8042kbdc.cpp index c1891a89f86..4d858005166 100644 --- a/src/devices/machine/8042kbdc.cpp +++ b/src/devices/machine/8042kbdc.cpp @@ -35,7 +35,7 @@ DEFINE_DEVICE_TYPE(KBDC8042, kbdc8042_device, "kbdc8042", "8042 Keyboard/Mouse C kbdc8042_device::kbdc8042_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, KBDC8042, tag, owner, clock) - , m_keyboard_dev(*this, "at_keyboard") + , m_keyboard_dev(*this, finder_base::DUMMY_TAG) , m_mousex_port(*this, "MOUSEX") , m_mousey_port(*this, "MOUSEY") , m_mousebtn_port(*this, "MOUSEBTN") @@ -50,12 +50,6 @@ kbdc8042_device::kbdc8042_device(const machine_config &mconfig, const char *tag, m_interrupttype = KBDC8042_SINGLE; } -void kbdc8042_device::device_add_mconfig(machine_config &config) -{ - AT_KEYB(config, m_keyboard_dev, pc_keyboard_device::KEYBOARD_TYPE::AT, 1); - m_keyboard_dev->keypress().set(FUNC(kbdc8042_device::keyboard_w)); -} - /*------------------------------------------------- device_start - device-specific startup @@ -144,7 +138,7 @@ void kbdc8042_device::at_8042_receive(uint8_t data, bool mouse) void kbdc8042_device::at_8042_check_keyboard() { - if (!m_keyboard.received && !m_mouse.received) + if (!m_keyboard.received && !m_mouse.received && m_keyboard_dev.found()) { int data = m_keyboard_dev->read(); if (data) @@ -340,7 +334,8 @@ void kbdc8042_device::data_w(offs_t offset, uint8_t data) case 0: m_data = data; m_sending = 1; - m_keyboard_dev->write(data); + if (m_keyboard_dev.found()) + m_keyboard_dev->write(data); break; case 1: diff --git a/src/devices/machine/8042kbdc.h b/src/devices/machine/8042kbdc.h index 6f3552b6dde..2b9e8eab7bc 100644 --- a/src/devices/machine/8042kbdc.h +++ b/src/devices/machine/8042kbdc.h @@ -39,6 +39,8 @@ public: // construction/destruction kbdc8042_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + template void set_keyboard_tag(T &&tag) { m_keyboard_dev.set_tag(std::forward(tag)); } + void set_keyboard_type(kbdc8042_type_t keybtype) { m_keybtype = keybtype; } void set_interrupt_type(kbdc8042_interrupt_type_t interrupttype) { m_interrupttype = interrupttype; } auto system_reset_callback() { return m_system_reset_cb.bind(); } @@ -59,11 +61,12 @@ public: void at_8042_check_mouse(); void at_8042_clear_keyboard_received(); + void keyboard_w(int state); + protected: // device-level overrides virtual void device_start() override; virtual void device_reset() override; - virtual void device_add_mconfig(machine_config &config) override; virtual ioport_constructor device_input_ports() const override; TIMER_CALLBACK_MEMBER(update_timer); @@ -107,7 +110,7 @@ private: int m_poll_delay; - required_device m_keyboard_dev; + optional_device m_keyboard_dev; optional_ioport m_mousex_port; optional_ioport m_mousey_port; optional_ioport m_mousebtn_port; @@ -128,8 +131,6 @@ private: uint8_t m_mouse_btn; emu_timer * m_update_timer; - - void keyboard_w(int state); }; // device type definition diff --git a/src/devices/machine/fdc37c93x.cpp b/src/devices/machine/fdc37c93x.cpp index e154e50693a..48a50681ccd 100644 --- a/src/devices/machine/fdc37c93x.cpp +++ b/src/devices/machine/fdc37c93x.cpp @@ -11,6 +11,8 @@ SMSC FDC37C93x Plug and Play Compatible Ultra I/O Controller #include "emu.h" #include "machine/fdc37c93x.h" +#include "machine/pckeybrd.h" + #include "formats/naslite_dsk.h" DEFINE_DEVICE_TYPE(FDC37C93X, fdc37c93x_device, "fdc37c93x", "SMSC FDC37C93X Super I/O") @@ -287,6 +289,10 @@ void fdc37c93x_device::device_add_mconfig(machine_config &config) m_kbdc->input_buffer_full_mouse_callback().set(FUNC(fdc37c93x_device::irq_mouse_w)); m_kbdc->system_reset_callback().set(FUNC(fdc37c93x_device::kbdp20_gp20_reset_w)); m_kbdc->gate_a20_callback().set(FUNC(fdc37c93x_device::kbdp21_gp25_gatea20_w)); + m_kbdc->set_keyboard_tag("at_keyboard"); + + at_keyboard_device &at_keyb(AT_KEYB(config, "at_keyboard", pc_keyboard_device::KEYBOARD_TYPE::AT, 1)); + at_keyb.keypress().set(m_kbdc, FUNC(kbdc8042_device::keyboard_w)); } void fdc37c93x_device::irq_floppy_w(int state) diff --git a/src/devices/machine/pc87306.cpp b/src/devices/machine/pc87306.cpp index c06a4751967..bc26d2e5c82 100644 --- a/src/devices/machine/pc87306.cpp +++ b/src/devices/machine/pc87306.cpp @@ -13,6 +13,7 @@ TODO: #include "bus/isa/isa.h" //#include "machine/ds128x.h" #include "machine/pc87306.h" +#include "machine/pckeybrd.h" #define LOG_WARN (1U << 1) // Show warnings @@ -84,6 +85,10 @@ void pc87306_device::device_add_mconfig(machine_config &config) m_kbdc->input_buffer_full_mouse_callback().set(FUNC(pc87306_device::irq_mouse_w)); m_kbdc->system_reset_callback().set(FUNC(pc87306_device::kbdp20_gp20_reset_w)); m_kbdc->gate_a20_callback().set(FUNC(pc87306_device::kbdp21_gp25_gatea20_w)); + m_kbdc->set_keyboard_tag("at_keyboard"); + + at_keyboard_device &at_keyb(AT_KEYB(config, "at_keyboard", pc_keyboard_device::KEYBOARD_TYPE::AT, 1)); + at_keyb.keypress().set(m_kbdc, FUNC(kbdc8042_device::keyboard_w)); } void pc87306_device::remap(int space_id, offs_t start, offs_t end) diff --git a/src/devices/machine/sis950_lpc.cpp b/src/devices/machine/sis950_lpc.cpp index 949416385d5..8d00dcfa787 100644 --- a/src/devices/machine/sis950_lpc.cpp +++ b/src/devices/machine/sis950_lpc.cpp @@ -29,7 +29,9 @@ #include "emu.h" #include "sis950_lpc.h" + #include "bus/pc_kbd/keyboards.h" +#include "machine/pckeybrd.h" #include "speaker.h" #define LOG_IO (1U << 1) // log PCI register accesses @@ -164,6 +166,10 @@ void sis950_lpc_device::device_add_mconfig(machine_config &config) m_keybc->input_buffer_full_mouse_callback().set(m_pic_slave, FUNC(pic8259_device::ir4_w)); m_keybc->system_reset_callback().set(FUNC(sis950_lpc_device::cpu_reset_w)); m_keybc->gate_a20_callback().set(FUNC(sis950_lpc_device::cpu_a20_w)); + m_keybc->set_keyboard_tag("at_keyboard"); + + at_keyboard_device &at_keyb(AT_KEYB(config, "at_keyboard", pc_keyboard_device::KEYBOARD_TYPE::AT, 1)); + at_keyb.keypress().set(m_keybc, FUNC(kbdc8042_device::keyboard_w)); // TODO: unknown RTC type // Has external RTC bank select at $48, using this one as convenience diff --git a/src/devices/machine/w83977tf.cpp b/src/devices/machine/w83977tf.cpp index a2d5cbe0254..23c070c50e0 100644 --- a/src/devices/machine/w83977tf.cpp +++ b/src/devices/machine/w83977tf.cpp @@ -12,9 +12,11 @@ TODO: ***************************************************************************/ #include "emu.h" +#include "machine/w83977tf.h" + #include "bus/isa/isa.h" //#include "machine/ds128x.h" -#include "machine/w83977tf.h" +#include "machine/pckeybrd.h" #define VERBOSE (LOG_GENERAL) //#define LOG_OUTPUT_FUNC osd_printf_info @@ -84,6 +86,10 @@ void w83977tf_device::device_add_mconfig(machine_config &config) m_kbdc->gate_a20_callback().set(FUNC(w83977tf_device::kbdp21_gp25_gatea20_w)); m_kbdc->input_buffer_full_callback().set(FUNC(w83977tf_device::irq_keyboard_w)); m_kbdc->input_buffer_full_mouse_callback().set(FUNC(w83977tf_device::irq_mouse_w)); + m_kbdc->set_keyboard_tag("at_keyboard"); + + at_keyboard_device &at_keyb(AT_KEYB(config, "at_keyboard", pc_keyboard_device::KEYBOARD_TYPE::AT, 1)); + at_keyb.keypress().set(m_kbdc, FUNC(kbdc8042_device::keyboard_w)); } diff --git a/src/mame/be/bebox.cpp b/src/mame/be/bebox.cpp index 4941129854f..9a5fba66b39 100644 --- a/src/mame/be/bebox.cpp +++ b/src/mame/be/bebox.cpp @@ -241,6 +241,10 @@ void bebox_state::bebox_peripherals(machine_config &config) kbdc.set_keyboard_type(kbdc8042_device::KBDC8042_STANDARD); kbdc.system_reset_callback().set_inputline(m_ppc[0], INPUT_LINE_RESET); kbdc.input_buffer_full_callback().set(FUNC(bebox_state::bebox_keyboard_interrupt)); + kbdc.set_keyboard_tag("at_keyboard"); + + at_keyboard_device &at_keyb(AT_KEYB(config, "at_keyboard", pc_keyboard_device::KEYBOARD_TYPE::AT, 1)); + at_keyb.keypress().set("kbdc", FUNC(kbdc8042_device::keyboard_w)); /* internal ram */ RAM(config, m_ram); diff --git a/src/mame/pc/nforcepc.cpp b/src/mame/pc/nforcepc.cpp index 27eb960f73c..7e935ef383a 100644 --- a/src/mame/pc/nforcepc.cpp +++ b/src/mame/pc/nforcepc.cpp @@ -33,6 +33,7 @@ #include "bus/rs232/terminal.h" #include "cpu/i386/athlon.h" #include "machine/pci-ide.h" +#include "machine/pckeybrd.h" #include "bus/isa/isa.h" #include "video/virge_pci.h" @@ -459,6 +460,10 @@ void it8703f_device::device_add_mconfig(machine_config &config) m_kbdc->input_buffer_full_callback().set(FUNC(it8703f_device::irq_keyboard_w)); m_kbdc->system_reset_callback().set(FUNC(it8703f_device::kbdp20_gp20_reset_w)); m_kbdc->gate_a20_callback().set(FUNC(it8703f_device::kbdp21_gp25_gatea20_w)); + m_kbdc->set_keyboard_tag("at_keyboard"); + + at_keyboard_device &at_keyb(AT_KEYB(config, "at_keyboard", pc_keyboard_device::KEYBOARD_TYPE::AT, 1)); + at_keyb.keypress().set(m_kbdc, FUNC(kbdc8042_device::keyboard_w)); } uint8_t it8703f_device::read_it8703f(offs_t offset) diff --git a/src/mame/shared/pcshare.cpp b/src/mame/shared/pcshare.cpp index 82cb02b3531..fbf36a0b5cf 100644 --- a/src/mame/shared/pcshare.cpp +++ b/src/mame/shared/pcshare.cpp @@ -17,6 +17,7 @@ #include "pcshare.h" #include "cpu/i86/i286.h" +#include "machine/pckeybrd.h" /****************** DMA8237 Controller @@ -176,4 +177,8 @@ void pcat_base_state::pcat_common(machine_config &config) m_kbdc->system_reset_callback().set_inputline(m_maincpu, INPUT_LINE_RESET); m_kbdc->gate_a20_callback().set_inputline(m_maincpu, INPUT_LINE_A20); m_kbdc->input_buffer_full_callback().set(m_pic8259_1, FUNC(pic8259_device::ir1_w)); + m_kbdc->set_keyboard_tag("at_keyboard"); + + at_keyboard_device &at_keyb(AT_KEYB(config, "at_keyboard", pc_keyboard_device::KEYBOARD_TYPE::AT, 1)); + at_keyb.keypress().set(m_kbdc, FUNC(kbdc8042_device::keyboard_w)); } diff --git a/src/mame/televideo/tv990.cpp b/src/mame/televideo/tv990.cpp index 926980ad8ee..fd6a8db5116 100644 --- a/src/mame/televideo/tv990.cpp +++ b/src/mame/televideo/tv990.cpp @@ -36,6 +36,7 @@ #include "machine/ins8250.h" #include "machine/nvram.h" #include "machine/pc_lpt.h" +#include "machine/pckeybrd.h" #include "sound/beep.h" #include "emupal.h" #include "screen.h" @@ -417,6 +418,10 @@ void tv990_state::tv990(machine_config &config) KBDC8042(config, m_kbdc); m_kbdc->set_keyboard_type(kbdc8042_device::KBDC8042_STANDARD); m_kbdc->input_buffer_full_callback().set_inputline("maincpu", M68K_IRQ_2); + m_kbdc->set_keyboard_tag("at_keyboard"); + + at_keyboard_device &at_keyb(AT_KEYB(config, "at_keyboard", pc_keyboard_device::KEYBOARD_TYPE::AT, 1)); + at_keyb.keypress().set(m_kbdc, FUNC(kbdc8042_device::keyboard_w)); NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); -- cgit v1.2.3