diff options
Diffstat (limited to 'src/devices/machine/pckeybrd.cpp')
-rw-r--r-- | src/devices/machine/pckeybrd.cpp | 81 |
1 files changed, 16 insertions, 65 deletions
diff --git a/src/devices/machine/pckeybrd.cpp b/src/devices/machine/pckeybrd.cpp index 76ace041e78..2ff9f5c7261 100644 --- a/src/devices/machine/pckeybrd.cpp +++ b/src/devices/machine/pckeybrd.cpp @@ -275,43 +275,27 @@ const at_keyboard_device::extended_keyboard_code at_keyboard_device::m_extended_ }; -const device_type PC_KEYB = device_creator<pc_keyboard_device>; -const device_type AT_KEYB = device_creator<at_keyboard_device>; +DEFINE_DEVICE_TYPE(PC_KEYB, pc_keyboard_device, "pc_keyb", "PC Keyboard") +DEFINE_DEVICE_TYPE(AT_KEYB, at_keyboard_device, "at_keyb", "AT Keyboard") pc_keyboard_device::pc_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, PC_KEYB, "PC Keyboard", tag, owner, clock, "pc_keyb", __FILE__), - m_type(KEYBOARD_TYPE_PC), - m_ioport_0(*this, ":pc_keyboard_0"), - m_ioport_1(*this, ":pc_keyboard_1"), - m_ioport_2(*this, ":pc_keyboard_2"), - m_ioport_3(*this, ":pc_keyboard_3"), - m_ioport_4(*this, ":pc_keyboard_4"), - m_ioport_5(*this, ":pc_keyboard_5"), - m_ioport_6(*this, ":pc_keyboard_6"), - m_ioport_7(*this, ":pc_keyboard_7"), - m_out_keypress_func(*this) + pc_keyboard_device(mconfig, PC_KEYB, tag, owner, clock) { + m_type = KEYBOARD_TYPE::PC; } -pc_keyboard_device::pc_keyboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source) : - device_t(mconfig, type, name, tag, owner, clock, shortname, source), - m_ioport_0(*this, ":pc_keyboard_0"), - m_ioport_1(*this, ":pc_keyboard_1"), - m_ioport_2(*this, ":pc_keyboard_2"), - m_ioport_3(*this, ":pc_keyboard_3"), - m_ioport_4(*this, ":pc_keyboard_4"), - m_ioport_5(*this, ":pc_keyboard_5"), - m_ioport_6(*this, ":pc_keyboard_6"), - m_ioport_7(*this, ":pc_keyboard_7"), +pc_keyboard_device::pc_keyboard_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, type, tag, owner, clock), + m_ioport(*this, ":pc_keyboard_%u", 0), m_out_keypress_func(*this) { } at_keyboard_device::at_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - pc_keyboard_device(mconfig, AT_KEYB, "AT Keyboard", tag, owner, clock, "at_keyb", __FILE__), + pc_keyboard_device(mconfig, AT_KEYB, tag, owner, clock), m_scan_code_set(1) { - m_type = KEYBOARD_TYPE_AT; + m_type = KEYBOARD_TYPE::AT; } @@ -377,7 +361,7 @@ WRITE_LINE_MEMBER(pc_keyboard_device::enable) { if(state && !m_on) { - if(m_type == KEYBOARD_TYPE_PC) + if(m_type == KEYBOARD_TYPE::PC) reset(); else m_keyboard_timer->adjust(attotime::from_msec(5), 0, attotime::from_hz(60)); @@ -525,43 +509,10 @@ void at_keyboard_device::helper(const char *codes) uint32_t pc_keyboard_device::readport(int port) { - uint32_t result = 0; - switch(port) - { - case 0: - if (m_ioport_0.found()) - result = m_ioport_0->read(); - break; - case 1: - if (m_ioport_1.found()) - result = m_ioport_1->read(); - break; - case 2: - if (m_ioport_2.found()) - result = m_ioport_2->read(); - break; - case 3: - if (m_ioport_3.found()) - result = m_ioport_3->read(); - break; - case 4: - if (m_ioport_4.found()) - result = m_ioport_4->read(); - break; - case 5: - if (m_ioport_5.found()) - result = m_ioport_5->read(); - break; - case 6: - if (m_ioport_6.found()) - result = m_ioport_6->read(); - break; - case 7: - if (m_ioport_7.found()) - result = m_ioport_7->read(); - break; - } - return result; + if ((m_ioport.size() > port) && m_ioport[port].found()) + return m_ioport[port]->read(); + else + return 0; } void pc_keyboard_device::polling(void) @@ -614,7 +565,7 @@ void pc_keyboard_device::polling(void) } } - if(m_type != KEYBOARD_TYPE_PC) + if(m_type != KEYBOARD_TYPE::PC) { /* extended scan-codes */ for( i = 0x60; i < 0x70; i++ ) @@ -764,7 +715,7 @@ WRITE8_MEMBER(at_keyboard_device::write) queue_insert(0xfa); /* send keyboard code */ - if (m_type == KEYBOARD_TYPE_MF2) { + if (m_type == KEYBOARD_TYPE::MF2) { queue_insert(0xab); queue_insert(0x41); } |