summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/pcd_kbd.h
blob: b8f95c2853ab136eafbd64641923de41cd1d32b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// license:BSD-3-Clause
// copyright-holders:Carl
#ifndef MAME_INCLUDES_PCD_KBD_H
#define MAME_INCLUDES_PCD_KBD_H

#pragma once

#define MCFG_PCD_KEYBOARD_OUT_TX_HANDLER(_devcb) \
	devcb = &downcast<pcd_keyboard_device &>(*device).set_out_tx_handler(DEVCB_##_devcb);

class pcd_keyboard_device : public device_t
{
public:
	pcd_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	template <class Object> devcb_base &set_out_tx_handler(Object &&cb) { return m_out_tx_handler.set_callback(std::forward<Object>(cb)); }

	DECLARE_WRITE_LINE_MEMBER( t0_w );

	void pcd_keyboard_map(address_map &map);
protected:
	virtual const tiny_rom_entry *device_rom_region() const override;
	virtual void device_add_mconfig(machine_config &config) override;
	virtual ioport_constructor device_input_ports() const override;

	void device_start() override;

private:
	required_ioport_array<17> m_rows;
	uint8_t m_p1;
	bool m_t0;
	devcb_write_line m_out_tx_handler;

	DECLARE_READ8_MEMBER( bus_r );
	DECLARE_READ8_MEMBER( p1_r );
	DECLARE_WRITE8_MEMBER( p1_w );
	DECLARE_READ_LINE_MEMBER( t0_r );
};

DECLARE_DEVICE_TYPE(PCD_KEYBOARD, pcd_keyboard_device)

#endif // MAME_INCLUDES_PCD_KBD_H