Previous 199869 Revisions Next

r20624 Thursday 31st January, 2013 at 04:06:46 UTC by Carl
[mess] psxanalog: add analog joystick [Carl]
[mess] psxanalog: rename analog pad to dualshock to avoid confusion with the dual analog pad (nw)
[src/mess/machine]psxanalog.c psxanalog.h psxcport.c

trunk/src/mess/machine/psxanalog.c
r20623r20624
11#include "machine/psxanalog.h"
22
3const device_type PSX_ANALOG_CONTROLLER = &device_creator<psx_analog_controller_device>;
3const device_type PSX_ANALOG_JOYSTICK = &device_creator<psx_analog_joystick_device>;
4const device_type PSX_DUALSHOCK = &device_creator<psx_dualshock_device>;
45
5psx_analog_controller_device::psx_analog_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
6      device_t(mconfig, PSX_ANALOG_CONTROLLER, "Playstation Analog Controller", tag, owner, clock),
6psx_analog_controller_device::psx_analog_controller_device(const machine_config &mconfig, device_type type, const char* name, const char *tag, device_t *owner, UINT32 clock) :
7      device_t(mconfig, type, name, tag, owner, clock),
78      device_psx_controller_interface(mconfig, *this),
89      m_pad0(*this, "PSXPAD0"),
910      m_pad1(*this, "PSXPAD1"),
r20623r20624
1415{
1516}
1617
18psx_dualshock_device::psx_dualshock_device(const machine_config& mconfig, const char* tag, device_t* owner, UINT32 clock) :
19      psx_analog_controller_device(mconfig, PSX_DUALSHOCK, "Playstation Dualshock Pad", tag, owner, clock)
20{
21   m_type = DUALSHOCK;
22}
23
24psx_analog_joystick_device::psx_analog_joystick_device(const machine_config& mconfig, const char* tag, device_t* owner, UINT32 clock) :
25      psx_analog_controller_device(mconfig, PSX_ANALOG_JOYSTICK, "Playstation Analog Joystick", tag, owner, clock)
26{
27   m_type = JOYSTICK;
28}
29
1730void psx_analog_controller_device::device_reset()
1831{
1932   m_confmode = false;
r20623r20624
3043   {
3144      case 2:
3245         data = m_pad0->read();
33         if(!analog)
46         if(!analog || (m_type == JOYSTICK))
3447            data |= 6; // l3/r3
3548         break;
3649      case 3:
r20623r20624
147160      switch(count)
148161      {
149162         case 0:
150            *odata = 0x73;
163            if(m_type == JOYSTICK)
164               *odata = 0x53;
165            else
166               *odata = 0x73;
151167            break;
152168         case 1:
153169            m_cmd = idata;
r20623r20624
244260   if(!m_analoglock)
245261      m_analogmode = newval;
246262}
263
trunk/src/mess/machine/psxanalog.h
r20623r20624
33
44#include "machine/psxcport.h"
55
6extern const device_type PSX_ANALOG_CONTROLLER;
6extern const device_type PSX_DUALSHOCK;
7extern const device_type PSX_ANALOG_JOYSTICK;
78
89class psx_analog_controller_device :   public device_t,
910                              public device_psx_controller_interface
1011{
1112public:
12   psx_analog_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
13   psx_analog_controller_device(const machine_config &mconfig, device_type type, const char* name, const char *tag, device_t *owner, UINT32 clock);
1314
1415   virtual ioport_constructor device_input_ports() const;
1516   DECLARE_INPUT_CHANGED_MEMBER(change_mode);
1617protected:
1718   virtual void device_reset();
1819   virtual void device_start() {}
19   virtual void device_config_complete() { m_shortname = "psx_analog_controller"; }
20   enum {
21      JOYSTICK,
22      DUALSHOCK
23   } m_type;
2024private:
2125   virtual bool get_pad(int count, UINT8 *odata, UINT8 idata);
2226   UINT8 pad_data(int count, bool analog);
r20623r20624
3640   required_ioport m_lsticky;
3741};
3842
43class psx_dualshock_device : public psx_analog_controller_device
44{
45public:
46   psx_dualshock_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
47protected:
48   virtual void device_config_complete() { m_shortname = "psx_dualshock_pad"; }
49};
50
51class psx_analog_joystick_device : public psx_analog_controller_device
52{
53public:
54   psx_analog_joystick_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
55protected:
56   virtual void device_config_complete() { m_shortname = "psx_analog_joystick"; }
57};
58
3959#endif /* PSXANALOG_H_ */
trunk/src/mess/machine/psxcport.c
r20623r20624
4444
4545SLOT_INTERFACE_START(psx_controllers)
4646   SLOT_INTERFACE("digital_pad", PSX_STANDARD_CONTROLLER)
47   SLOT_INTERFACE("analog_pad", PSX_ANALOG_CONTROLLER)
47   SLOT_INTERFACE("dualshock_pad", PSX_DUALSHOCK)
48   SLOT_INTERFACE("analog_joystick", PSX_ANALOG_JOYSTICK)
4849SLOT_INTERFACE_END
4950
5051void psxcontrollerports_device::data_in( int data, int mask )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team