diff options
| author | 2026-05-10 03:07:34 +1000 | |
|---|---|---|
| committer | 2026-05-10 03:34:22 +1000 | |
| commit | d6dd21e2013c80ecbc97dc3cce3df964e8e4c2aa (patch) | |
| tree | 8a42e21bf7ed3fe4bad8769fcd8aa52b8469a48c /src/emu/ioport.cpp | |
| parent | 937399619268781d75a0f04edf5b2fd9e247ce38 (diff) | |
ui: Improved media control experience, cleaned up a lot of bad code.
ui/imgcntrl, ui/floppycntrl.cpp: Completely reworked logic -
backtracking through menus is more intuitive, and more context is
retained when encountering an error (it should be a bit easier to follow
the code as well).
ui/floppycntrl.cpp: Don't show the initial content selection menu when
opening an image to read from while writing to a separate file.
ui/filecreate.cpp: Moved the logic to enumerate floppy formats into the
menu, use headings and separators, use callbacks to notify when an item
is selected, don't pop menus when an item is selected, avoid actual work
in destructors.
ui/midiinout.cpp: Fixed infinite growth when repopulating the menu,
don't pop the menu when a port is chosen, use a callback to notify that
a port is chosen, use headings and separators, and in informative
placeholder if no ports are available.
ui/filesel.cpp: Don't show the option to write to a floppy diff (it
still isn't implemented, it can be re-added if it's ever implemented),
don't pop the menus when selecting an item, avoid actual work in
destructors.
ui/filemngr.cpp: Show more detail in the info box below the menu for
software items and presets, substantially simplified the code for
walking media devices.
ui/info.cpp: Got rid of the media information menu, added media
information to the system information menu.
ui/menu.cpp: Allow immediately adjusting the hovered item with
pen/mouse, saving a click.
emu/ioport: Fixed incorrect strings displayed for 4C_5C, 3C_4C, 2C_3C
and 3C_5C. The array absolutely must stay in order. Also added an
assertion to catch these errors early.
emu/ioport.cpp: Use a much less gross method of handling default strings
(apparently someone forgot about function overloading).
emu/ioport.cpp: Retired the crosshair mapper member macros - they don't
serve much purpose.
util/zippath.cpp: Actually report a failure to open a plain file rather
than looking for files inside non-existent archives, making every error
turn into "file not found".
formats/flopimg.cpp: Allow matching extensions on string object names,
rather than requiring a NUL-terminated string.
Diffstat (limited to 'src/emu/ioport.cpp')
| -rw-r--r-- | src/emu/ioport.cpp | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp index fc5a0de293c..12707741cd3 100644 --- a/src/emu/ioport.cpp +++ b/src/emu/ioport.cpp @@ -33,6 +33,7 @@ #include <cctype> #include <ctime> #include <sstream> +#include <type_traits> namespace { @@ -111,7 +112,7 @@ inline u8 compute_shift(ioport_value mask) const struct { - u32 id; + input_string_index id; const char *string; } input_port_default_strings[] = { @@ -145,10 +146,10 @@ const struct { INPUT_STRING_3C_3C, "3 Coins/3 Credits" }, { INPUT_STRING_2C_2C, "2 Coins/2 Credits" }, { INPUT_STRING_1C_1C, "1 Coin/1 Credit" }, - { INPUT_STRING_3C_5C, "3 Coins/5 Credits" }, { INPUT_STRING_4C_5C, "4 Coins/5 Credits" }, { INPUT_STRING_3C_4C, "3 Coins/4 Credits" }, { INPUT_STRING_2C_3C, "2 Coins/3 Credits" }, + { INPUT_STRING_3C_5C, "3 Coins/5 Credits" }, { INPUT_STRING_4C_7C, "4 Coins/7 Credits" }, { INPUT_STRING_2C_4C, "2 Coins/4 Credits" }, { INPUT_STRING_1C_2C, "1 Coin/2 Credits" }, @@ -3304,27 +3305,21 @@ ioport_configurer& ioport_configurer::field_set_gm_note(u8 note) // ioport_token to a default string //------------------------------------------------- -const char *ioport_configurer::string_from_token(const char *string) +const char *ioport_configurer::string_from_token(input_string_index string) { - // 0 is an invalid index - if (string == nullptr) - return nullptr; - - // if the index is greater than the count, assume it to be a pointer - if (uintptr_t(string) >= INPUT_STRING_COUNT) - return string; - -#if false // Set true, If you want to take care missing-token or wrong-sorting +#if 0 // Set true, If you want to take care missing-token or wrong-sorting // otherwise, scan the list for a matching string and return it for (int index = 0; index < std::size(input_port_default_strings); index++) - if (input_port_default_strings[index].id == uintptr_t(string)) + if (input_port_default_strings[index].id == string) return input_port_default_strings[index].string; return "(Unknown Default)"; #else - return input_port_default_strings[uintptr_t(string)-1].string; + auto const index = std::underlying_type_t<input_string_index>(string) - 1; + assert(input_port_default_strings[index].id == string); + return input_port_default_strings[index].string; #endif } @@ -3384,7 +3379,7 @@ ioport_configurer& ioport_configurer::field_alloc(ioport_type type, ioport_value // append the field if (type != IPT_UNKNOWN && type != IPT_UNUSED) m_curport->m_active |= mask; - m_curfield = &m_curport->m_fieldlist.append(*new ioport_field(*m_curport, type, defval, mask, string_from_token(name))); + m_curfield = &m_curport->m_fieldlist.append(*new ioport_field(*m_curport, type, defval, mask, name)); // reset the current setting m_cursetting = nullptr; @@ -3392,6 +3387,11 @@ ioport_configurer& ioport_configurer::field_alloc(ioport_type type, ioport_value return *this; } +ioport_configurer& ioport_configurer::field_alloc(ioport_type type, ioport_value defval, ioport_value mask, input_string_index name) +{ + return field_alloc(type, defval, mask, string_from_token(name)); +} + //------------------------------------------------- // field_add_char - add a character to a field @@ -3444,10 +3444,15 @@ ioport_configurer& ioport_configurer::setting_alloc(ioport_value value, const ch throw emu_fatalerror("setting_alloc called with no active field (value=%X name=%s)\n", value, name); // append a new setting - m_cursetting = &m_curfield->m_settinglist.emplace_back(*m_curfield, value & m_curfield->mask(), string_from_token(name)); + m_cursetting = &m_curfield->m_settinglist.emplace_back(*m_curfield, value & m_curfield->mask(), name); return *this; } +ioport_configurer& ioport_configurer::setting_alloc(ioport_value value, input_string_index name) +{ + return setting_alloc(value, string_from_token(name)); +} + //------------------------------------------------- // set_condition - set the condition for either @@ -3483,6 +3488,11 @@ ioport_configurer& ioport_configurer::onoff_alloc(const char *name, ioport_value return *this; } +ioport_configurer& ioport_configurer::onoff_alloc(input_string_index name, ioport_value defval, ioport_value mask, const char *diplocation) +{ + return onoff_alloc(string_from_token(name), defval, mask, diplocation); +} + /*************************************************************************** |
