summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/bbc/analogue/joystick.cpp
blob: 8c6aa767af6ffa961acd24aac13bc2668999a591 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************

    Joystick Controllers

    ANH01 - Acorn Analogue Joystick Controllers
    http://chrisacorns.computinghistory.org.uk/8bit_Upgrades/Acorn_ANH01_JoystickController.html

    Voltmace Delta 3b "Twin" Joystick Controllers (self centering)

**********************************************************************/

#include "emu.h"
#include "joystick.h"

//**************************************************************************
//  DEVICE DEFINITIONS
//**************************************************************************

const device_type BBC_ACORNJOY = device_creator<bbc_acornjoy_device>;
const device_type BBC_VOLTMACE3B = device_creator<bbc_voltmace3b_device>;


static INPUT_PORTS_START( acornjoy )
	PORT_START("JOY0")
	PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(0) PORT_MINMAX(0x00, 0xff) PORT_PLAYER(1)

	PORT_START("JOY1")
	PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(0) PORT_MINMAX(0x00, 0xff) PORT_PLAYER(1)

	PORT_START("JOY2")
	PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(0) PORT_MINMAX(0x00, 0xff) PORT_PLAYER(2)

	PORT_START("JOY3")
	PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(0) PORT_MINMAX(0x00, 0xff) PORT_PLAYER(2)

	PORT_START("BUTTONS")
	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1)
	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(2)
INPUT_PORTS_END

static INPUT_PORTS_START( voltmace3b )
	PORT_START("JOY0")
	PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(20) PORT_MINMAX(0x00, 0xff) PORT_PLAYER(1)

	PORT_START("JOY1")
	PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(20) PORT_MINMAX(0x00, 0xff) PORT_PLAYER(1)

	PORT_START("JOY2")
	PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(20) PORT_MINMAX(0x00, 0xff) PORT_PLAYER(2)

	PORT_START("JOY3")
	PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(20) PORT_MINMAX(0x00, 0xff) PORT_PLAYER(2)

	PORT_START("BUTTONS")
	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1)
	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(2)
INPUT_PORTS_END


//-------------------------------------------------
//  input_ports - device-specific input ports
//-------------------------------------------------

ioport_constructor bbc_acornjoy_device::device_input_ports() const
{
	return INPUT_PORTS_NAME( acornjoy );
}

ioport_constructor bbc_voltmace3b_device::device_input_ports() const
{
	return INPUT_PORTS_NAME( voltmace3b );
}


//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

//-------------------------------------------------
//  bbc_joystick_device - constructor
//-------------------------------------------------

bbc_joystick_device::bbc_joystick_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),
	device_bbc_analogue_interface(mconfig, *this),
	m_joy(*this, "JOY%u", 0),
	m_buttons(*this, "BUTTONS")
{
}

bbc_acornjoy_device::bbc_acornjoy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	bbc_joystick_device(mconfig, BBC_ACORNJOY, "Acorn Analogue Joysticks", tag, owner, clock, "bbc_acornjoy", __FILE__)
{
}

bbc_voltmace3b_device::bbc_voltmace3b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	bbc_joystick_device(mconfig, BBC_VOLTMACE3B, "Voltmace Delta 3b Twin Joysticks", tag, owner, clock, "bbc_voltmace3b", __FILE__)
{
}


//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void bbc_joystick_device::device_start()
{
}


//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void bbc_joystick_device::device_reset()
{
}


//**************************************************************************
//  IMPLEMENTATION
//**************************************************************************

uint8_t bbc_joystick_device::ch_r(int channel)
{
	return m_joy[channel]->read();
}

uint8_t bbc_joystick_device::pb_r()
{
	return m_buttons->read();
}