summaryrefslogtreecommitdiffstats
path: root/src/mame/machine/agatkeyb.h
blob: fe56998c05d178296f05bbeed7b5b6f7d9043a93 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// license:BSD-3-Clause
// copyright-holders:Sergey Svishchev
#ifndef MAME_MACHINE_AGATKEYB_H
#define MAME_MACHINE_AGATKEYB_H

#pragma once

#include "machine/keyboard.h"


/***************************************************************************
    DEVICE TYPE GLOBALS
***************************************************************************/

DECLARE_DEVICE_TYPE(AGAT_KEYBOARD, agat_keyboard_device)


/***************************************************************************
    TYPE DECLARATIONS
***************************************************************************/


class agat_keyboard_device : public device_t, protected device_matrix_keyboard_interface<6U>
{
public:
	agat_keyboard_device(
		const machine_config &mconfig,
		const char *tag,
		device_t *owner,
		u32 clock);

	virtual ioport_constructor device_input_ports() const override;

	auto out_callback() { return m_keyboard_cb.bind(); }
	auto out_meta_callback() { return m_out_meta_cb.bind(); }
	auto out_reset_callback() { return m_out_reset_cb.bind(); }

	DECLARE_INPUT_CHANGED_MEMBER(meta_changed);
	DECLARE_INPUT_CHANGED_MEMBER(reset_changed);

protected:
	agat_keyboard_device(
		const machine_config &mconfig,
		device_type type,
		char const *tag,
		device_t *owner,
		u32 clock);
	virtual void device_start() override;
	virtual void device_reset() override;
	virtual void key_make(u8 row, u8 column) override;
	virtual void key_repeat(u8 row, u8 column) override;

	required_ioport m_modifiers;

private:
	virtual void will_scan_row(u8 row) override;

	bool translate(u8 code, u16 &translated) const;
	void send_translated(u8 code);
	attotime typematic_delay() const;
	attotime typematic_period() const;

	bool             m_meta = false;
	u16              m_last_modifiers;
	devcb_write8     m_keyboard_cb;
	devcb_write_line m_out_meta_cb;
	devcb_write_line m_out_reset_cb;
};

#endif // MAME_MACHINE_AGATKEYB_H