diff options
-rw-r--r-- | src/emu/inpttype.h | 1 | ||||
-rw-r--r-- | src/emu/ioport.cpp | 31 | ||||
-rw-r--r-- | src/emu/ioport.h | 14 | ||||
-rw-r--r-- | src/frontend/mame/ui/cheatopt.cpp | 180 | ||||
-rw-r--r-- | src/frontend/mame/ui/cheatopt.h | 24 | ||||
-rw-r--r-- | src/frontend/mame/ui/ui.cpp | 15 |
6 files changed, 12 insertions, 253 deletions
diff --git a/src/emu/inpttype.h b/src/emu/inpttype.h index 9cf56fd18ee..e25045c0b85 100644 --- a/src/emu/inpttype.h +++ b/src/emu/inpttype.h @@ -839,7 +839,6 @@ inline void construct_core_types_UI(simple_list<input_type_entry> &typelist) INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RECORD_MNG, "Record MNG", input_seq(KEYCODE_F12, KEYCODE_LSHIFT, input_seq::not_code, KEYCODE_LCONTROL) ) INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RECORD_AVI, "Record AVI", input_seq(KEYCODE_F12, KEYCODE_LSHIFT, KEYCODE_LCONTROL) ) INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_TOGGLE_CHEAT, "Toggle Cheat", input_seq(KEYCODE_F6) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_TOGGLE_AUTOFIRE, "Toggle Autofire", input_seq() ) INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_UP, "UI Up", input_seq(KEYCODE_UP, input_seq::or_code, JOYCODE_Y_UP_SWITCH_INDEXED(0)) ) INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_DOWN, "UI Down", input_seq(KEYCODE_DOWN, input_seq::or_code, JOYCODE_Y_DOWN_SWITCH_INDEXED(0)) ) INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_LEFT, "UI Left", input_seq(KEYCODE_LEFT, input_seq::or_code, JOYCODE_X_LEFT_SWITCH_INDEXED(0)) ) diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp index 7e064e27698..69cc6f151a7 100644 --- a/src/emu/ioport.cpp +++ b/src/emu/ioport.cpp @@ -872,20 +872,18 @@ void ioport_field::get_user_settings(user_settings &settings) if (!m_settinglist.empty() || m_type == IPT_ADJUSTER) settings.value = m_live->value; - // if there's analog data, extract the analog settings if (m_live->analog != nullptr) { + // if there's analog data, extract the analog settings settings.sensitivity = m_live->analog->sensitivity(); settings.delta = m_live->analog->delta(); settings.centerdelta = m_live->analog->centerdelta(); settings.reverse = m_live->analog->reverse(); } - - // non-analog settings else { + // non-analog settings settings.toggle = m_live->toggle; - settings.autofire = m_live->autofire; } } @@ -911,20 +909,18 @@ void ioport_field::set_user_settings(const user_settings &settings) if (!m_settinglist.empty() || m_type == IPT_ADJUSTER) m_live->value = settings.value; - // if there's analog data, extract the analog settings if (m_live->analog != nullptr) { + // if there's analog data, extract the analog settings m_live->analog->m_sensitivity = settings.sensitivity; m_live->analog->m_delta = settings.delta; m_live->analog->m_centerdelta = settings.centerdelta; m_live->analog->m_reverse = settings.reverse; } - - // non-analog settings else { + // non-analog settings m_live->toggle = settings.toggle; - m_live->autofire = settings.autofire; } } @@ -1101,19 +1097,6 @@ void ioport_field::frame_update(ioport_value &result) // if the state changed, look for switch down/switch up bool curstate = m_digital_value || machine().input().seq_pressed(seq()); - if (m_live->autofire && !machine().ioport().get_autofire_toggle()) - { - if (curstate) - { - if (m_live->autopressed > machine().ioport().get_autofire_delay()) - m_live->autopressed = 0; - else if (m_live->autopressed > machine().ioport().get_autofire_delay() / 2) - curstate = false; - m_live->autopressed++; - } - else - m_live->autopressed = 0; - } bool changed = false; if (curstate != m_live->last) { @@ -1363,8 +1346,6 @@ ioport_field_live::ioport_field_live(ioport_field &field, analog_field *analog) last(0), toggle(field.toggle()), joydir(digital_joystick::JOYDIR_COUNT), - autofire(false), - autopressed(0), lockout(false) { // fill in the basic values @@ -1680,9 +1661,7 @@ ioport_manager::ioport_manager(running_machine &machine) m_playback_accumulated_frames(0), m_timecode_file(machine.options().input_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS), m_timecode_count(0), - m_timecode_last_time(attotime::zero), - m_autofire_toggle(false), - m_autofire_delay(3) // 1 seems too fast for a bunch of games + m_timecode_last_time(attotime::zero) { memset(m_type_to_entry, 0, sizeof(m_type_to_entry)); } diff --git a/src/emu/ioport.h b/src/emu/ioport.h index bb9a8f47830..ef9f1b4ae13 100644 --- a/src/emu/ioport.h +++ b/src/emu/ioport.h @@ -368,7 +368,6 @@ enum ioport_type IPT_UI_EXPORT, IPT_UI_AUDIT_FAST, IPT_UI_AUDIT_ALL, - IPT_UI_TOGGLE_AUTOFIRE, // additional OSD-specified UI port types (up to 16) IPT_OSD_1, @@ -1095,7 +1094,6 @@ public: struct user_settings { ioport_value value; // for DIP switches - bool autofire; // for autofire settings input_seq seq[SEQ_TYPE_TOTAL]; // sequences of all types s32 sensitivity; // for analog controls s32 delta; // for analog controls @@ -1171,8 +1169,6 @@ struct ioport_field_live bool last; // were we pressed last time? bool toggle; // current toggle setting digital_joystick::direction_t joydir; // digital joystick direction index - bool autofire; // autofire - int autopressed; // autofire status bool lockout; // user lockout std::string name; // overridden name }; @@ -1406,12 +1402,6 @@ public: ioport_type token_to_input_type(const char *string, int &player) const; std::string input_type_to_token(ioport_type type, int player); - // autofire - bool get_autofire_toggle() { return m_autofire_toggle; } - void set_autofire_toggle(bool toggle) { m_autofire_toggle = toggle; } - int get_autofire_delay() { return m_autofire_delay; } - void set_autofire_delay(int delay) { m_autofire_delay = delay; } - private: // internal helpers void init_port_types(); @@ -1477,10 +1467,6 @@ private: emu_file m_timecode_file; // timecode/frames playback file (nullptr if not recording) int m_timecode_count; attotime m_timecode_last_time; - - // autofire - bool m_autofire_toggle; // autofire toggle - int m_autofire_delay; // autofire delay }; diff --git a/src/frontend/mame/ui/cheatopt.cpp b/src/frontend/mame/ui/cheatopt.cpp index 1cf87b7f9f3..b503aba5206 100644 --- a/src/frontend/mame/ui/cheatopt.cpp +++ b/src/frontend/mame/ui/cheatopt.cpp @@ -18,16 +18,11 @@ namespace ui { + // itemrefs for key menu items #define ITEMREF_CHEATS_RESET_ALL ((void *) 0x0001) #define ITEMREF_CHEATS_RELOAD_ALL ((void *) 0x0002) -#define ITEMREF_CHEATS_AUTOFIRE_SETTINGS ((void *) 0x0003) -#define ITEMREF_CHEATS_FIRST_ITEM ((void *) 0x0004) - -// itemrefs for key menu items -#define ITEMREF_AUTOFIRE_STATUS ((void *) 0x0001) -#define ITEMREF_AUTOFIRE_DELAY ((void *) 0x0002) -#define ITEMREF_AUTOFIRE_FIRST_BUTTON ((void *) 0x0003) +#define ITEMREF_CHEATS_FIRST_ITEM ((void *) 0x0003) /*------------------------------------------------- @@ -105,12 +100,6 @@ void menu_cheat::handle() machine().popmessage(_("All cheats reloaded")); } - /* handle autofire menu */ - if (menu_event->itemref == ITEMREF_CHEATS_AUTOFIRE_SETTINGS && menu_event->iptkey == IPT_UI_SELECT) - { - menu::stack_push<menu_autofire>(ui(), container()); - } - /* if things changed, update */ if (changed) reset(reset_options::REMEMBER_REF); @@ -132,9 +121,6 @@ void menu_cheat::populate(float &customtop, float &custombottom) std::string text; std::string subtext; - // add the autofire menu - item_append(_("Autofire Settings"), "", 0, (void *)ITEMREF_CHEATS_AUTOFIRE_SETTINGS); - /* add a separator */ item_append(menu_item_type::SEPARATOR); @@ -165,166 +151,4 @@ menu_cheat::~menu_cheat() { } - - - - -/*------------------------------------------------- - menu_autofire - handle the autofire settings - menu --------------------------------------------------*/ - -menu_autofire::menu_autofire(mame_ui_manager &mui, render_container &container) : menu(mui, container), last_toggle(false) -{ - const screen_device *screen = screen_device_iterator(mui.machine().root_device()).first(); - - if (screen == nullptr) - { - refresh = 60.0; - } - else - { - refresh = ATTOSECONDS_TO_HZ(screen->refresh_attoseconds()); - } -} - -menu_autofire::~menu_autofire() -{ -} - -void menu_autofire::handle() -{ - ioport_field *field; - bool changed = false; - - /* process the menu */ - const event *menu_event = process(0); - - /* handle events */ - if (menu_event != nullptr && menu_event->itemref != nullptr) - { - // menu item is changed using left/right keys only - if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) - { - if (menu_event->itemref == ITEMREF_AUTOFIRE_STATUS) - { - // toggle autofire status - bool autofire_toggle = machine().ioport().get_autofire_toggle(); // (menu_event->iptkey == IPT_UI_LEFT); - machine().ioport().set_autofire_toggle(!autofire_toggle); - changed = true; - } - else if (menu_event->itemref == ITEMREF_AUTOFIRE_DELAY) - { - // change autofire frequency - int autofire_delay = machine().ioport().get_autofire_delay(); - if (menu_event->iptkey == IPT_UI_LEFT) - { - autofire_delay--; - if (autofire_delay < 1) - autofire_delay = 1; - } - else - { - autofire_delay++; - if (autofire_delay > 30) - autofire_delay = 30; - } - machine().ioport().set_autofire_delay(autofire_delay); - changed = true; - } - else - { - // enable autofire on specific button - field = (ioport_field *)menu_event->itemref; - ioport_field::user_settings settings; - field->get_user_settings(settings); - settings.autofire = (menu_event->iptkey == IPT_UI_RIGHT); - field->set_user_settings(settings); - changed = true; - } - } - } - - // if toggle settings changed, redraw menu to reflect new options - if (!changed) - { - changed = (last_toggle != machine().ioport().get_autofire_toggle()); - } - - /* if something changed, rebuild the menu */ - if (changed) - { - reset(reset_options::REMEMBER_REF); - } -} - - -/*------------------------------------------------- - menu_autofire_populate - populate the autofire - menu --------------------------------------------------*/ - -void menu_autofire::populate(float &customtop, float &custombottom) -{ - char temp_text[64]; - - /* add autofire toggle item */ - bool autofire_toggle = machine().ioport().get_autofire_toggle(); - item_append(_("Autofire Status"), (autofire_toggle ? _("Disabled") : _("Enabled")), - (autofire_toggle ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW), (void *)ITEMREF_AUTOFIRE_STATUS); - - /* iterate over the input ports and add autofire toggle items */ - int menu_items = 0; - for (auto &port : machine().ioport().ports()) - { - bool is_first_button = true; - for (ioport_field &field : port.second->fields()) - { - if (field.type() >= IPT_BUTTON1 && field.type() <= IPT_BUTTON16) - { - menu_items++; - ioport_field::user_settings settings; - field.get_user_settings(settings); - - if (is_first_button) - { - /* add a separator for each player */ - item_append(menu_item_type::SEPARATOR); - is_first_button = false; - } - - /* add an autofire item */ - item_append_on_off(field.name(), settings.autofire, (autofire_toggle ? FLAG_DISABLE | FLAG_INVERT : 0), (void *)&field); - } - } - } - - /* add text item if no buttons found */ - if (menu_items==0) - { - item_append(menu_item_type::SEPARATOR); - item_append(_("No buttons found on this machine!"), "", FLAG_DISABLE, nullptr); - } - - /* add a separator */ - item_append(menu_item_type::SEPARATOR); - - /* add autofire delay item */ - int value = machine().ioport().get_autofire_delay(); - snprintf(temp_text, ARRAY_LENGTH(temp_text), "%d = %.2f Hz", value, (float)refresh/value); - if (!autofire_toggle) - { - item_append(_("Autofire Delay"), temp_text, FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)ITEMREF_AUTOFIRE_DELAY); - } - else - { - item_append(_("Autofire Delay"), temp_text, FLAG_DISABLE | FLAG_INVERT, nullptr); - } - - /* add a separator */ - item_append(menu_item_type::SEPARATOR); - - last_toggle = autofire_toggle; -} - } // namespace ui diff --git a/src/frontend/mame/ui/cheatopt.h b/src/frontend/mame/ui/cheatopt.h index e95e765cb30..1d925cb2a71 100644 --- a/src/frontend/mame/ui/cheatopt.h +++ b/src/frontend/mame/ui/cheatopt.h @@ -7,15 +7,16 @@ Internal menu for the cheat interface. ***************************************************************************/ - -#pragma once - #ifndef MAME_FRONTEND_UI_CHEATOPT_H #define MAME_FRONTEND_UI_CHEATOPT_H +#pragma once + #include "ui/menu.h" + namespace ui { + class menu_cheat : public menu { public: @@ -27,21 +28,6 @@ private: virtual void handle() override; }; - -class menu_autofire : public menu -{ -public: - menu_autofire(mame_ui_manager &mui, render_container &container); - virtual ~menu_autofire() override; - -private: - virtual void populate(float &customtop, float &custombottom) override; - virtual void handle() override; - - float refresh; - bool last_toggle; -}; - } // namespace ui -#endif /* MAME_FRONTEND_UI_CHEATOPT_H */ +#endif // MAME_FRONTEND_UI_CHEATOPT_H diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index 27987bbc9c9..baca4dd1bc7 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -1234,21 +1234,6 @@ uint32_t mame_ui_manager::handler_ingame(render_container &container) if (machine().ui_input().pressed(IPT_UI_THROTTLE)) machine().video().toggle_throttle(); - // toggle autofire - if (machine().ui_input().pressed(IPT_UI_TOGGLE_AUTOFIRE)) - { - if (!machine().options().cheat()) - { - machine().popmessage(_("Autofire can't be enabled")); - } - else - { - bool autofire_toggle = machine().ioport().get_autofire_toggle(); - machine().ioport().set_autofire_toggle(!autofire_toggle); - machine().popmessage("Autofire %s", autofire_toggle ? _("Enabled") : _("Disabled")); - } - } - // check for fast forward if (machine().ioport().type_pressed(IPT_UI_FAST_FORWARD)) { |