Previous 199869 Revisions Next

r19960 Sunday 30th December, 2012 at 23:35:29 UTC by O. Galibert
input: Fix joystick constraint computations when multiple sources are possible [O. Galibert]
[src/emu]emutempl.h ioport.c ioport.h

trunk/src/emu/ioport.c
r19959r19960
893893//  digital joystick
894894//-------------------------------------------------
895895
896digital_joystick::direction_t digital_joystick::set_axis(ioport_field &field)
896digital_joystick::direction_t digital_joystick::add_axis(ioport_field &field)
897897{
898898   direction_t direction = direction_t((field.type() - (IPT_DIGITAL_JOYSTICK_FIRST + 1)) % 4);
899   m_field[direction] = &field;
899   m_field[direction].append(*global_alloc(simple_list_wrapper<ioport_field>(&field)));
900900   return direction;
901901}
902902
r19959r19960
916916   // read all the associated ports
917917   running_machine *machine = NULL;
918918   for (direction_t direction = JOYDIR_UP; direction < JOYDIR_COUNT; direction++)
919      if (m_field[direction] != NULL)
919      for (const simple_list_wrapper<ioport_field> *i = m_field[direction].first(); i != NULL; i = i->next())
920920      {
921         machine = &m_field[direction]->machine();
922         if (machine->input().seq_pressed(m_field[direction]->seq(SEQ_TYPE_STANDARD)))
921         machine = &i->object()->machine();
922         if (machine->input().seq_pressed(i->object()->seq(SEQ_TYPE_STANDARD)))
923923            m_current |= 1 << direction;
924924      }
925925
r19959r19960
23262326   if (field.is_digital_joystick())
23272327   {
23282328      joystick = &field.manager().digjoystick(field.player(), (field.type() - (IPT_DIGITAL_JOYSTICK_FIRST + 1)) / 4);
2329      joydir = joystick->set_axis(field);
2329      joydir = joystick->add_axis(field);
23302330   }
23312331
23322332   // Name keyboard key names
trunk/src/emu/ioport.h
r19959r19960
803803   UINT8 current4way() const { return m_current4way; }
804804
805805   // configuration
806   direction_t set_axis(ioport_field &field);
806   direction_t add_axis(ioport_field &field);
807807
808808   // updates
809809   void frame_update();
810810
811811private:
812812   // internal state
813   digital_joystick *   m_next;               // next joystick in the list
814   int               m_player;            // player number represented
815   int               m_number;            // joystick number represented
816   ioport_field *      m_field[JOYDIR_COUNT];   // input field for each direction
817   UINT8            m_current;            // current value
818   UINT8            m_current4way;         // current 4-way value
819   UINT8            m_previous;            // previous value
813   digital_joystick *         m_next;                                 // next joystick in the list
814   int                     m_player;                              // player number represented
815   int                     m_number;                              // joystick number represented
816   simple_list<simple_list_wrapper<ioport_field> >   m_field[JOYDIR_COUNT];   // potential input fields for each direction
817   UINT8                  m_current;                              // current value
818   UINT8                  m_current4way;                           // current 4-way value
819   UINT8                  m_previous;                              // previous value
820820};
821821DECLARE_ENUM_OPERATORS(digital_joystick::direction_t)
822822
trunk/src/emu/emutempl.h
r19959r19960
274274class simple_list_wrapper
275275{
276276public:
277   template<class U> friend class simple_list;
278
277279   // construction/destruction
278280   simple_list_wrapper(_ObjectType *object)
279281      : m_next(NULL),

Previous 199869 Revisions Next


© 1997-2024 The MAME Team