trunk/src/emu/ioport.cpp
| r250280 | r250281 | |
| 744 | 744 | digital_joystick::direction_t digital_joystick::add_axis(ioport_field &field) |
| 745 | 745 | { |
| 746 | 746 | direction_t direction = direction_t((field.type() - (IPT_DIGITAL_JOYSTICK_FIRST + 1)) % 4); |
| 747 | | m_field[direction].append(field); |
| 747 | m_field[direction].append(*global_alloc(simple_list_wrapper<ioport_field>(&field))); |
| 748 | 748 | return direction; |
| 749 | 749 | } |
| 750 | 750 | |
| r250280 | r250281 | |
| 764 | 764 | // read all the associated ports |
| 765 | 765 | running_machine *machine = NULL; |
| 766 | 766 | for (direction_t direction = JOYDIR_UP; direction < JOYDIR_COUNT; ++direction) |
| 767 | | for (const ioport_field *i = m_field[direction].first(); i != NULL; i = i->next()) |
| 767 | for (const simple_list_wrapper<ioport_field> *i = m_field[direction].first(); i != NULL; i = i->next()) |
| 768 | 768 | { |
| 769 | | machine = &i->machine(); |
| 770 | | if (machine->input().seq_pressed(i->seq(SEQ_TYPE_STANDARD))) |
| 769 | machine = &i->object()->machine(); |
| 770 | if (machine->input().seq_pressed(i->object()->seq(SEQ_TYPE_STANDARD))) |
| 771 | 771 | m_current |= 1 << direction; |
| 772 | 772 | } |
| 773 | 773 | |
trunk/src/emu/ioport.h
| r250280 | r250281 | |
| 792 | 792 | digital_joystick * m_next; // next joystick in the list |
| 793 | 793 | int m_player; // player number represented |
| 794 | 794 | int m_number; // joystick number represented |
| 795 | | simple_list<ioport_field> m_field[JOYDIR_COUNT]; // potential input fields for each direction |
| 795 | simple_list<simple_list_wrapper<ioport_field> > m_field[JOYDIR_COUNT]; // potential input fields for each direction |
| 796 | 796 | UINT8 m_current; // current value |
| 797 | 797 | UINT8 m_current4way; // current 4-way value |
| 798 | 798 | UINT8 m_previous; // previous value |
trunk/src/lib/util/coretmpl.h
| r250280 | r250281 | |
| 277 | 277 | int m_count; // number of objects in the list |
| 278 | 278 | }; |
| 279 | 279 | |
| 280 | |
| 281 | // ======================> simple_list_wrapper |
| 282 | |
| 283 | // a simple_list_wrapper wraps an existing object with a next pointer so it |
| 284 | // can live in a simple_list without requiring the object to have a next |
| 285 | // pointer |
| 286 | template<class _ObjectType> |
| 287 | class simple_list_wrapper |
| 288 | { |
| 289 | public: |
| 290 | template<class U> friend class simple_list; |
| 291 | |
| 292 | // construction/destruction |
| 293 | simple_list_wrapper(_ObjectType *object) |
| 294 | : m_next(NULL), |
| 295 | m_object(object) { } |
| 296 | |
| 297 | // operators |
| 298 | operator _ObjectType *() { return m_object; } |
| 299 | operator _ObjectType *() const { return m_object; } |
| 300 | _ObjectType *operator *() { return m_object; } |
| 301 | _ObjectType *operator *() const { return m_object; } |
| 302 | |
| 303 | // getters |
| 304 | simple_list_wrapper *next() const { return m_next; } |
| 305 | _ObjectType *object() const { return m_object; } |
| 306 | |
| 307 | private: |
| 308 | // internal state |
| 309 | simple_list_wrapper * m_next; |
| 310 | _ObjectType * m_object; |
| 311 | }; |
| 312 | |
| 313 | |
| 280 | 314 | // ======================> fixed_allocator |
| 281 | 315 | |
| 282 | 316 | // a fixed_allocator is a simple class that maintains a free pool of objects |