diff options
Diffstat (limited to 'src/devices/machine/keyboard.cpp')
-rw-r--r-- | src/devices/machine/keyboard.cpp | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/src/devices/machine/keyboard.cpp b/src/devices/machine/keyboard.cpp index 2e9fa529424..ef45c8d5580 100644 --- a/src/devices/machine/keyboard.cpp +++ b/src/devices/machine/keyboard.cpp @@ -30,7 +30,7 @@ WRITE8_MEMBER( xxx_state::kbd_put ) namespace { -uint8_t const TRANSLATION_TABLE[][2][4][16] = { +u8 const TRANSLATION_TABLE[][2][4][16] = { { { // ANSI { '`', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0x08U, 0x7fU, 0x1bU }, @@ -234,7 +234,7 @@ INPUT_PORTS_END DEVICE TYPE GLOBALS ***************************************************************************/ -device_type const GENERIC_KEYBOARD = device_creator<generic_keyboard_device>; +DEFINE_DEVICE_TYPE(GENERIC_KEYBOARD, generic_keyboard_device, "generic_keyboard", "Generic Keyboard") @@ -245,24 +245,21 @@ device_type const GENERIC_KEYBOARD = device_creator<generic_keyboard_device>; generic_keyboard_device::generic_keyboard_device( machine_config const &mconfig, device_type type, - char const *name, char const *tag, device_t *owner, - uint32_t clock, - char const *shortname, - char const *source) - : device_t(mconfig, type, name, tag, owner, clock, shortname, source) + u32 clock) + : device_t(mconfig, type, tag, owner, clock) , device_matrix_keyboard_interface(mconfig, *this, "GENKBD_ROW0", "GENKBD_ROW1", "GENKBD_ROW2", "GENKBD_ROW3") , m_config(*this, "GENKBD_CFG") , m_modifiers(*this, "GENKBD_MOD") , m_last_modifiers(0U) - , m_keyboard_cb(*this) + , m_keyboard_cb() { } -generic_keyboard_device::generic_keyboard_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) - : generic_keyboard_device(mconfig, GENERIC_KEYBOARD, "Generic Keyboard", tag, owner, clock, "generic_keyboard", __FILE__) +generic_keyboard_device::generic_keyboard_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock) + : generic_keyboard_device(mconfig, GENERIC_KEYBOARD, tag, owner, clock) { } @@ -275,7 +272,7 @@ ioport_constructor generic_keyboard_device::device_input_ports() const void generic_keyboard_device::device_start() { - m_keyboard_cb.resolve_safe(); + m_keyboard_cb.bind_relative_to(*owner()); save_item(NAME(m_last_modifiers)); } @@ -297,40 +294,40 @@ void generic_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, } -void generic_keyboard_device::key_make(uint8_t row, uint8_t column) +void generic_keyboard_device::key_make(u8 row, u8 column) { send_translated((row << 4) | column); typematic_start(row, column, typematic_delay(), typematic_period()); } -void generic_keyboard_device::key_repeat(uint8_t row, uint8_t column) +void generic_keyboard_device::key_repeat(u8 row, u8 column) { send_translated((row << 4) | column); } -void generic_keyboard_device::send_key(uint8_t code) +void generic_keyboard_device::send_key(u8 code) { - m_keyboard_cb(offs_t(0), code); + m_keyboard_cb(code); } -bool generic_keyboard_device::translate(uint8_t code, uint8_t &translated) const +bool generic_keyboard_device::translate(u8 code, u8 &translated) const { unsigned const row((code >> 4) & 0x03U); unsigned const col((code >> 0) & 0x0fU); unsigned const layout(m_config->read() & 0x0001U); - uint16_t const modifiers(m_modifiers->read()); + u16 const modifiers(m_modifiers->read()); bool const shift(bool(modifiers & 0x02U) != (bool(modifiers & 0x04U) && CAPS_TABLE[row][col])); bool const ctrl(modifiers & 0x01U); bool const meta(modifiers & 0x08U); unsigned const map(ctrl ? 2U : shift ? 1U : 0U); - uint8_t const result(TRANSLATION_TABLE[map][layout][row][col]); - if (result == uint8_t(~0U)) + u8 const result(TRANSLATION_TABLE[map][layout][row][col]); + if (result == u8(~0U)) { return false; } @@ -342,9 +339,9 @@ bool generic_keyboard_device::translate(uint8_t code, uint8_t &translated) const } -void generic_keyboard_device::will_scan_row(uint8_t row) +void generic_keyboard_device::will_scan_row(u8 row) { - uint16_t const modifiers(m_modifiers->read()); + u16 const modifiers(m_modifiers->read()); if (modifiers != m_last_modifiers) typematic_restart(typematic_delay(), typematic_period()); @@ -352,9 +349,9 @@ void generic_keyboard_device::will_scan_row(uint8_t row) } -void generic_keyboard_device::send_translated(uint8_t code) +void generic_keyboard_device::send_translated(u8 code) { - uint8_t translated; + u8 translated; if (translate(code, translated)) send_key(translated); } |