summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/interpro/mouse/mouse.h
blob: f10019605cb235d55ce6281f8c6d85e7b48ab0fa (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// license:BSD-3-Clause
// copyright-holders:Patrick Mackinlay
#ifndef MAME_BUS_INTERPRO_MOUSE_MOUSE_H
#define MAME_BUS_INTERPRO_MOUSE_MOUSE_H

#pragma once

class device_interpro_mouse_port_interface;

class interpro_mouse_port_device : public device_t, public device_single_card_slot_interface<device_interpro_mouse_port_interface>
{
	friend class device_interpro_mouse_port_interface;

public:
	template <typename T>
	interpro_mouse_port_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&slot_options, const char *default_option)
		: interpro_mouse_port_device(mconfig, tag, owner)
	{
		option_reset();
		slot_options(*this);
		set_default_option(default_option);
		set_fixed(false);
	}

	interpro_mouse_port_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock = 0);

	// callback configuration
	auto state_func() { return m_state_func.bind(); }

protected:
	// device-level overrides
	virtual void device_start() override;
	virtual void device_config_complete() override;

private:
	devcb_write32 m_state_func;

	device_interpro_mouse_port_interface *m_device;
};

class device_interpro_mouse_port_interface : public device_interface
{
	friend class interpro_mouse_port_device;

protected:
	device_interpro_mouse_port_interface(machine_config const &mconfig, device_t &device);

	void state_w(u32 data, u32 mem_mask) { m_port->m_state_func(offs_t(0), data, mem_mask); }

private:
	interpro_mouse_port_device *m_port;
};

class interpro_mouse_device : public device_t, public device_interpro_mouse_port_interface
{
public:
	enum state_mask
	{
		MOUSE_YPOS    = 0x000000ff,
		MOUSE_XPOS    = 0x0000ff00,
		MOUSE_LBUTTON = 0x00010000,
		MOUSE_MBUTTON = 0x00020000,
		MOUSE_RBUTTON = 0x00040000,

		MOUSE_BUTTONS = 0x00070000
	};

	// constructor/destructor
	interpro_mouse_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock);

	DECLARE_INPUT_CHANGED_MEMBER(mouse_button);
	DECLARE_INPUT_CHANGED_MEMBER(mouse_x);
	DECLARE_INPUT_CHANGED_MEMBER(mouse_y);

protected:
	// device overrides
	virtual void device_start() override;
	virtual void device_reset() override;

	virtual ioport_constructor device_input_ports() const override;

private:
};

DECLARE_DEVICE_TYPE(INTERPRO_MOUSE_PORT, interpro_mouse_port_device)
DECLARE_DEVICE_TYPE(INTERPRO_MOUSE, interpro_mouse_device)

void interpro_mouse_devices(device_slot_interface &device);

#endif // MAME_BUS_INTERPRO_MOUSE_MOUSE_H