mirror of
https://github.com/holub/mame
synced 2025-07-04 17:38:08 +03:00
interpro: slotify mouse (nw) (#3543)
* interpro: slotify mouse (nw) Needed to make the mouse a slot device to enable it to be connected to graphics boards under development. * add validity check (nw)
This commit is contained in:
parent
d08cf3ce61
commit
bd9f203b65
@ -3423,6 +3423,18 @@ if (BUSES["INTERPRO_KEYBOARD"]~=null) then
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---------------------------------------------------
|
||||||
|
--
|
||||||
|
--@src/devices/bus/interpro/mouse/mouse.h,BUSES["INTERPRO_MOUSE"] = true
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
if (BUSES["INTERPRO_MOUSE"]~=null) then
|
||||||
|
files {
|
||||||
|
MAME_DIR .. "src/devices/bus/interpro/mouse/mouse.cpp",
|
||||||
|
MAME_DIR .. "src/devices/bus/interpro/mouse/mouse.h"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
--
|
--
|
||||||
--@src/devices/bus/einstein/pipe/pipe.h,BUSES["TATUNG_PIPE"] = true
|
--@src/devices/bus/einstein/pipe/pipe.h,BUSES["TATUNG_PIPE"] = true
|
||||||
|
@ -699,6 +699,7 @@ BUSES["IMI7000"] = true
|
|||||||
BUSES["INTELLEC4"] = true
|
BUSES["INTELLEC4"] = true
|
||||||
BUSES["INTERPRO_SR"] = true
|
BUSES["INTERPRO_SR"] = true
|
||||||
BUSES["INTERPRO_KEYBOARD"] = true
|
BUSES["INTERPRO_KEYBOARD"] = true
|
||||||
|
BUSES["INTERPRO_MOUSE"] = true
|
||||||
BUSES["INTV"] = true
|
BUSES["INTV"] = true
|
||||||
BUSES["INTV_CTRL"] = true
|
BUSES["INTV_CTRL"] = true
|
||||||
BUSES["IQ151"] = true
|
BUSES["IQ151"] = true
|
||||||
|
130
src/devices/bus/interpro/mouse/mouse.cpp
Normal file
130
src/devices/bus/interpro/mouse/mouse.cpp
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
// license:BSD-3-Clause
|
||||||
|
// copyright-holders:Patrick Mackinlay
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A high-level emulation implementation of the Intergraph InterPro mouse.
|
||||||
|
*
|
||||||
|
* Little information is available on this hardware. The mouse has 3 buttons,
|
||||||
|
* all of which are commonly used by the system software, but earlier InterPro
|
||||||
|
* systems appear to have supported many more buttons; it's not known if those
|
||||||
|
* earlier versions use the same port or protocol. The mouse has a male D-sub
|
||||||
|
* 9-pin connector, using an unknown, probably TTL level signalling protocol.
|
||||||
|
*
|
||||||
|
* It's probable that this mouse can be connected to the mouse port on InterPro
|
||||||
|
* system main boards as well as the mouse port(s) on EDGE graphics boards.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "emu.h"
|
||||||
|
#include "mouse.h"
|
||||||
|
|
||||||
|
#define VERBOSE (0)
|
||||||
|
|
||||||
|
#include "logmacro.h"
|
||||||
|
|
||||||
|
DEFINE_DEVICE_TYPE(INTERPRO_MOUSE_PORT, interpro_mouse_port_device, "interpro_mouse_port", "InterPro Mouse Port")
|
||||||
|
DEFINE_DEVICE_TYPE(INTERPRO_MOUSE, interpro_mouse_device, "interpro_mouse", "InterPro Mouse")
|
||||||
|
|
||||||
|
static INPUT_PORTS_START(interpro_mouse)
|
||||||
|
PORT_START("mouse_buttons")
|
||||||
|
PORT_BIT(interpro_mouse_device::MOUSE_LBUTTON, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Mouse Left Button") PORT_CODE(MOUSECODE_BUTTON1) PORT_CHANGED_MEMBER(DEVICE_SELF, interpro_mouse_device, mouse_button, nullptr)
|
||||||
|
PORT_BIT(interpro_mouse_device::MOUSE_MBUTTON, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Mouse Middle Button") PORT_CODE(MOUSECODE_BUTTON3) PORT_CHANGED_MEMBER(DEVICE_SELF, interpro_mouse_device, mouse_button, nullptr)
|
||||||
|
PORT_BIT(interpro_mouse_device::MOUSE_RBUTTON, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_NAME("Mouse Right Button") PORT_CODE(MOUSECODE_BUTTON2) PORT_CHANGED_MEMBER(DEVICE_SELF, interpro_mouse_device, mouse_button, nullptr)
|
||||||
|
|
||||||
|
PORT_START("mouse_x")
|
||||||
|
PORT_BIT(0xff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(50) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, interpro_mouse_device, mouse_x, nullptr)
|
||||||
|
PORT_START("mouse_y")
|
||||||
|
PORT_BIT(0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(50) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, interpro_mouse_device, mouse_y, nullptr)
|
||||||
|
INPUT_PORTS_END
|
||||||
|
|
||||||
|
interpro_mouse_port_device::interpro_mouse_port_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock)
|
||||||
|
: device_t(mconfig, INTERPRO_MOUSE_PORT, tag, owner, clock)
|
||||||
|
, device_slot_interface(mconfig, *this)
|
||||||
|
, m_state_func(*this)
|
||||||
|
, m_device(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void interpro_mouse_port_device::device_config_complete()
|
||||||
|
{
|
||||||
|
m_device = dynamic_cast<device_interpro_mouse_port_interface *>(get_card_device());
|
||||||
|
}
|
||||||
|
|
||||||
|
void interpro_mouse_port_device::device_validity_check(validity_checker &valid) const
|
||||||
|
{
|
||||||
|
device_t *const card(get_card_device());
|
||||||
|
|
||||||
|
if (card && !dynamic_cast<device_interpro_mouse_port_interface *>(card))
|
||||||
|
osd_printf_error("Device %s (%s) does not implement device_interpro_mouse_port_interface\n", card->tag(), card->name());
|
||||||
|
}
|
||||||
|
|
||||||
|
void interpro_mouse_port_device::device_start()
|
||||||
|
{
|
||||||
|
m_state_func.resolve_safe();
|
||||||
|
}
|
||||||
|
|
||||||
|
device_interpro_mouse_port_interface::device_interpro_mouse_port_interface(machine_config const &mconfig, device_t &device)
|
||||||
|
: device_slot_card_interface(mconfig, device)
|
||||||
|
, m_port(dynamic_cast<interpro_mouse_port_device *>(device.owner()))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
interpro_mouse_device::interpro_mouse_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock)
|
||||||
|
: device_t(mconfig, INTERPRO_MOUSE, tag, owner, clock)
|
||||||
|
, device_interpro_mouse_port_interface(mconfig, *this)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void interpro_mouse_device::device_start()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void interpro_mouse_device::device_reset()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ioport_constructor interpro_mouse_device::device_input_ports() const
|
||||||
|
{
|
||||||
|
return INPUT_PORTS_NAME(interpro_mouse);
|
||||||
|
}
|
||||||
|
|
||||||
|
void interpro_mouse_devices(device_slot_interface &device)
|
||||||
|
{
|
||||||
|
device.option_add("interpro_mouse", INTERPRO_MOUSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
INPUT_CHANGED_MEMBER(interpro_mouse_device::mouse_button)
|
||||||
|
{
|
||||||
|
const ioport_value data = field.port().read();
|
||||||
|
|
||||||
|
LOG("mouse_button 0x%02x\n", data);
|
||||||
|
|
||||||
|
state_w(machine().dummy_space(), 0, data & MOUSE_BUTTONS, MOUSE_BUTTONS);
|
||||||
|
}
|
||||||
|
|
||||||
|
INPUT_CHANGED_MEMBER(interpro_mouse_device::mouse_x)
|
||||||
|
{
|
||||||
|
// compute x delta
|
||||||
|
int delta = newval - oldval;
|
||||||
|
if (delta > 0x80)
|
||||||
|
delta -= 0x100;
|
||||||
|
else if (delta < -0x80)
|
||||||
|
delta += 0x100;
|
||||||
|
|
||||||
|
LOG("mouse_x delta %d\n", delta);
|
||||||
|
|
||||||
|
state_w(machine().dummy_space(), 0, (delta << 8) & MOUSE_XPOS, MOUSE_XPOS);
|
||||||
|
}
|
||||||
|
|
||||||
|
INPUT_CHANGED_MEMBER(interpro_mouse_device::mouse_y)
|
||||||
|
{
|
||||||
|
// compute y delta
|
||||||
|
int delta = newval - oldval;
|
||||||
|
if (delta > 0x80)
|
||||||
|
delta -= 0x100;
|
||||||
|
else if (delta < -0x80)
|
||||||
|
delta += 0x100;
|
||||||
|
|
||||||
|
LOG("mouse_y delta %d\n", delta);
|
||||||
|
|
||||||
|
state_w(machine().dummy_space(), 0, (delta << 0) & MOUSE_YPOS, MOUSE_YPOS);
|
||||||
|
}
|
83
src/devices/bus/interpro/mouse/mouse.h
Normal file
83
src/devices/bus/interpro/mouse/mouse.h
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// license:BSD-3-Clause
|
||||||
|
// copyright-holders:Patrick Mackinlay
|
||||||
|
#ifndef MAME_BUS_INTERPRO_MOUSE_MOUSE_H
|
||||||
|
#define MAME_BUS_INTERPRO_MOUSE_MOUSE_H
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define MCFG_MOUSE_STATE_CB(_state_cb) \
|
||||||
|
devcb = &downcast<interpro_mouse_port_device &>(*device).set_state_callback(DEVCB_##_state_cb);
|
||||||
|
|
||||||
|
class device_interpro_mouse_port_interface;
|
||||||
|
|
||||||
|
class interpro_mouse_port_device : public device_t, public device_slot_interface
|
||||||
|
{
|
||||||
|
friend class device_interpro_mouse_port_interface;
|
||||||
|
|
||||||
|
public:
|
||||||
|
interpro_mouse_port_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock);
|
||||||
|
|
||||||
|
template <class Object> devcb_base &set_state_callback(Object &&cb) { return m_state_func.set_callback(std::forward<Object>(cb)); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// device-level overrides
|
||||||
|
virtual void device_validity_check(validity_checker &valid) const override;
|
||||||
|
virtual void device_start() override;
|
||||||
|
virtual void device_config_complete() override;
|
||||||
|
|
||||||
|
devcb_write32 m_state_func;
|
||||||
|
|
||||||
|
private:
|
||||||
|
device_interpro_mouse_port_interface *m_device;
|
||||||
|
};
|
||||||
|
|
||||||
|
class device_interpro_mouse_port_interface : public device_slot_card_interface
|
||||||
|
{
|
||||||
|
friend class interpro_mouse_port_device;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DECLARE_WRITE32_MEMBER(state_w) { m_port->m_state_func(space, offset, data, mem_mask); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
device_interpro_mouse_port_interface(machine_config const &mconfig, device_t &device);
|
||||||
|
|
||||||
|
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
|
Loading…
Reference in New Issue
Block a user