diff options
Diffstat (limited to 'src/devices/bus/snes_ctrl/ctrl.h')
-rw-r--r-- | src/devices/bus/snes_ctrl/ctrl.h | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/devices/bus/snes_ctrl/ctrl.h b/src/devices/bus/snes_ctrl/ctrl.h index 37db69537cc..3b9ed59844d 100644 --- a/src/devices/bus/snes_ctrl/ctrl.h +++ b/src/devices/bus/snes_ctrl/ctrl.h @@ -20,11 +20,9 @@ class snes_control_port_device; // ======================> device_snes_control_port_interface -class device_snes_control_port_interface : public device_slot_card_interface +class device_snes_control_port_interface : public device_interface { public: - // construction/destruction - device_snes_control_port_interface(const machine_config &mconfig, device_t &device); virtual ~device_snes_control_port_interface(); virtual uint8_t read_pin4() { return 0; } @@ -34,20 +32,23 @@ public: virtual void port_poll() { } protected: + device_snes_control_port_interface(const machine_config &mconfig, device_t &device); + snes_control_port_device *m_port; }; -typedef device_delegate<bool (int16_t x, int16_t y)> snesctrl_onscreen_delegate; #define SNESCTRL_ONSCREEN_CB(name) bool name(int16_t x, int16_t y) -typedef device_delegate<void (int16_t x, int16_t y)> snesctrl_gunlatch_delegate; #define SNESCTRL_GUNLATCH_CB(name) void name(int16_t x, int16_t y) // ======================> snes_control_port_device -class snes_control_port_device : public device_t, public device_slot_interface +class snes_control_port_device : public device_t, public device_single_card_slot_interface<device_snes_control_port_interface> { public: + typedef device_delegate<bool (int16_t x, int16_t y)> onscreen_delegate; + typedef device_delegate<void (int16_t x, int16_t y)> gunlatch_delegate; + // construction/destruction template <typename T> snes_control_port_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&opts, char const *dflt) @@ -61,8 +62,8 @@ public: snes_control_port_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); virtual ~snes_control_port_device(); - template <typename... T> void set_onscreen_callback(T &&... args) { m_onscreen_cb = snesctrl_onscreen_delegate(std::forward<T>(args)...); } - template <typename... T> void set_gunlatch_callback(T &&... args) { m_gunlatch_cb = snesctrl_gunlatch_delegate(std::forward<T>(args)...); } + template <typename... T> void set_onscreen_callback(T &&... args) { m_onscreen_cb.set(std::forward<T>(args)...); } + template <typename... T> void set_gunlatch_callback(T &&... args) { m_gunlatch_cb.set(std::forward<T>(args)...); } uint8_t read_pin4(); uint8_t read_pin5(); @@ -70,15 +71,15 @@ public: void write_strobe(uint8_t data); void port_poll(); - bool onscreen_cb(int16_t x, int16_t y) { return m_onscreen_cb.isnull() ? true : m_onscreen_cb(x, y); } - void gunlatch_cb(int16_t x, int16_t y) { if (!m_gunlatch_cb.isnull()) m_gunlatch_cb(x, y); } + bool onscreen_cb(int16_t x, int16_t y) { return m_onscreen_cb(x, y); } + void gunlatch_cb(int16_t x, int16_t y) { m_gunlatch_cb(x, y); } protected: // device-level overrides - virtual void device_start() override; + virtual void device_start() override ATTR_COLD; - snesctrl_onscreen_delegate m_onscreen_cb; - snesctrl_gunlatch_delegate m_gunlatch_cb; + onscreen_delegate m_onscreen_cb; + gunlatch_delegate m_gunlatch_cb; device_snes_control_port_interface *m_device; }; |