trunk/src/emu/ioport.c
| r19959 | r19960 | |
| 893 | 893 | // digital joystick |
| 894 | 894 | //------------------------------------------------- |
| 895 | 895 | |
| 896 | | digital_joystick::direction_t digital_joystick::set_axis(ioport_field &field) |
| 896 | digital_joystick::direction_t digital_joystick::add_axis(ioport_field &field) |
| 897 | 897 | { |
| 898 | 898 | 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))); |
| 900 | 900 | return direction; |
| 901 | 901 | } |
| 902 | 902 | |
| r19959 | r19960 | |
| 916 | 916 | // read all the associated ports |
| 917 | 917 | running_machine *machine = NULL; |
| 918 | 918 | 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()) |
| 920 | 920 | { |
| 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))) |
| 923 | 923 | m_current |= 1 << direction; |
| 924 | 924 | } |
| 925 | 925 | |
| r19959 | r19960 | |
| 2326 | 2326 | if (field.is_digital_joystick()) |
| 2327 | 2327 | { |
| 2328 | 2328 | 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); |
| 2330 | 2330 | } |
| 2331 | 2331 | |
| 2332 | 2332 | // Name keyboard key names |
trunk/src/emu/ioport.h
| r19959 | r19960 | |
| 803 | 803 | UINT8 current4way() const { return m_current4way; } |
| 804 | 804 | |
| 805 | 805 | // configuration |
| 806 | | direction_t set_axis(ioport_field &field); |
| 806 | direction_t add_axis(ioport_field &field); |
| 807 | 807 | |
| 808 | 808 | // updates |
| 809 | 809 | void frame_update(); |
| 810 | 810 | |
| 811 | 811 | private: |
| 812 | 812 | // 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 |
| 820 | 820 | }; |
| 821 | 821 | DECLARE_ENUM_OPERATORS(digital_joystick::direction_t) |
| 822 | 822 | |