diff options
Diffstat (limited to 'src/frontend/mame/ui')
-rw-r--r-- | src/frontend/mame/ui/inputmap.cpp | 17 | ||||
-rw-r--r-- | src/frontend/mame/ui/inputmap.h | 2 | ||||
-rw-r--r-- | src/frontend/mame/ui/keyboard.cpp | 98 | ||||
-rw-r--r-- | src/frontend/mame/ui/keyboard.h | 33 | ||||
-rw-r--r-- | src/frontend/mame/ui/mainmenu.cpp | 3 | ||||
-rw-r--r-- | src/frontend/mame/ui/miscmenu.cpp | 37 | ||||
-rw-r--r-- | src/frontend/mame/ui/miscmenu.h | 12 | ||||
-rw-r--r-- | src/frontend/mame/ui/videoopt.cpp | 2 |
8 files changed, 145 insertions, 59 deletions
diff --git a/src/frontend/mame/ui/inputmap.cpp b/src/frontend/mame/ui/inputmap.cpp index 33cbd9223e0..bfb68e40da0 100644 --- a/src/frontend/mame/ui/inputmap.cpp +++ b/src/frontend/mame/ui/inputmap.cpp @@ -93,7 +93,7 @@ void menu_input_general::populate(float &customtop, float &custombottom) item.type = ioport_manager::type_is_analog(entry.type()) ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL; item.is_optional = false; item.name = entry.name(); - item.owner_name = nullptr; + item.owner = nullptr; // stop after one, unless we're analog if (item.type == INPUT_TYPE_DIGITAL) @@ -164,7 +164,7 @@ void menu_input_specific::populate(float &customtop, float &custombottom) item.type = field.is_analog() ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL; item.is_optional = field.optional(); item.name = field.name(); - item.owner_name = field.device().tag(); + item.owner = &field.device(); // stop after one, unless we're analog if (item.type == INPUT_TYPE_DIGITAL) @@ -180,7 +180,7 @@ void menu_input_specific::populate(float &customtop, float &custombottom) data.end(), [] (const input_item_data &i1, const input_item_data &i2) { - int cmp = strcmp(i1.owner_name, i2.owner_name); + int cmp = strcmp(i1.owner->tag(), i2.owner->tag()); if (cmp < 0) return true; if (cmp > 0) @@ -431,21 +431,24 @@ void menu_input::populate_sorted(float &customtop, float &custombottom) // build the menu std::string text, subtext; - std::string prev_owner; + const device_t *prev_owner = nullptr; bool first_entry = true; for (input_item_data &item : data) { // generate the name of the item itself, based off the base name and the type assert(nameformat[item.type] != nullptr); - if (item.owner_name && strcmp(item.owner_name, prev_owner.c_str()) != 0) + if (item.owner && (item.owner != prev_owner)) { if (first_entry) first_entry = false; else item_append(menu_item_type::SEPARATOR); - item_append(string_format("[root%s]", item.owner_name), "", 0, nullptr); - prev_owner.assign(item.owner_name); + if (item.owner->owner()) + item_append(string_format(_("%1$s [root%2$s]"), item.owner->type().fullname(), item.owner->tag()), "", 0, nullptr); + else + item_append(string_format(_("[root%1$s]"), item.owner->tag()), "", 0, nullptr); + prev_owner = item.owner; } text = string_format(nameformat[item.type], item.name); diff --git a/src/frontend/mame/ui/inputmap.h b/src/frontend/mame/ui/inputmap.h index d2e41780211..01649b0b1ef 100644 --- a/src/frontend/mame/ui/inputmap.h +++ b/src/frontend/mame/ui/inputmap.h @@ -55,7 +55,7 @@ protected: input_seq seq; // copy of the live sequence const input_seq * defseq = nullptr; // pointer to the default sequence const char * name = nullptr; // pointer to the base name of the item - const char * owner_name = nullptr; // pointer to the name of the owner of the item + const device_t * owner = nullptr; // pointer to the owner of the item ioport_group group = IPG_INVALID; // group type uint8_t type = 0U; // type of port bool is_optional = false; // true if this input is considered optional diff --git a/src/frontend/mame/ui/keyboard.cpp b/src/frontend/mame/ui/keyboard.cpp new file mode 100644 index 00000000000..5d48f23cafe --- /dev/null +++ b/src/frontend/mame/ui/keyboard.cpp @@ -0,0 +1,98 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +/*************************************************************************** + + ui/keyboard.cpp + + Keyboard mode menu. + +***************************************************************************/ + +#include "emu.h" +#include "ui/keyboard.h" + +#include "natkeyboard.h" + + +namespace ui { + +namespace { + +constexpr uintptr_t ITEM_KBMODE = 0x00000100; +constexpr uintptr_t ITEM_KBDEV_FIRST = 0x00000200; + +} // anonymous namespace + + +menu_keyboard_mode::menu_keyboard_mode(mame_ui_manager &mui, render_container &container) : menu(mui, container) +{ +} + +void menu_keyboard_mode::populate(float &customtop, float &custombottom) +{ + natural_keyboard &natkbd(machine().ioport().natkeyboard()); + + if (natkbd.can_post()) + { + bool const natmode(natkbd.in_use()); + item_append( + _("Keyboard Mode"), + natmode ? _("Natural") : _("Emulated"), + natmode ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, + reinterpret_cast<void *>(ITEM_KBMODE)); + item_append(menu_item_type::SEPARATOR); + } + + uintptr_t ref(ITEM_KBDEV_FIRST); + for (size_t i = 0; natkbd.keyboard_count() > i; ++i, ++ref) + { + device_t &kbddev(natkbd.keyboard_device(i)); + bool const enabled(natkbd.keyboard_enabled(i)); + item_append( + util::string_format( + kbddev.owner() ? _("%1$s [root%2$s]") : _("[root%2$s"), + kbddev.type().fullname(), + kbddev.tag()), + enabled ? _("Enabled") : _("Disabled"), + enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, + reinterpret_cast<void *>(ref)); + } + item_append(menu_item_type::SEPARATOR); +} + +menu_keyboard_mode::~menu_keyboard_mode() +{ +} + +void menu_keyboard_mode::handle() +{ + event const *const menu_event(process(0)); + if (menu_event && uintptr_t(menu_event->itemref)) + { + natural_keyboard &natkbd(machine().ioport().natkeyboard()); + uintptr_t const ref(uintptr_t(menu_event->itemref)); + bool const left(IPT_UI_LEFT == menu_event->iptkey); + bool const right(IPT_UI_RIGHT == menu_event->iptkey); + if (ITEM_KBMODE == ref) + { + if ((left || right) && (natkbd.in_use() != right)) + { + natkbd.set_in_use(right); + reset(reset_options::REMEMBER_REF); + } + } + else if (ITEM_KBDEV_FIRST <= ref) + { + if ((left || right) && (natkbd.keyboard_enabled(ref - ITEM_KBDEV_FIRST) != right)) + { + if (right) + natkbd.enable_keyboard(ref - ITEM_KBDEV_FIRST); + else + natkbd.disable_keyboard(ref - ITEM_KBDEV_FIRST); + reset(reset_options::REMEMBER_REF); + } + } + } +} + +} // namespace ui diff --git a/src/frontend/mame/ui/keyboard.h b/src/frontend/mame/ui/keyboard.h new file mode 100644 index 00000000000..899385e74c2 --- /dev/null +++ b/src/frontend/mame/ui/keyboard.h @@ -0,0 +1,33 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +/*************************************************************************** + + ui/keyboard.h + + Keyboard mode menu. + +***************************************************************************/ +#ifndef MAME_FRONTEND_UI_KEYBOARD_H +#define MAME_FRONTEND_UI_KEYBOARD_H + +#pragma once + +#include "ui/menu.h" + + +namespace ui { + +class menu_keyboard_mode : public menu +{ +public: + menu_keyboard_mode(mame_ui_manager &mui, render_container &container); + virtual ~menu_keyboard_mode(); + +private: + virtual void populate(float &customtop, float &custombottom) override; + virtual void handle() override; +}; + +} // namespace ui + +#endif // MAME_FRONTEND_UI_KEYBOARD_H diff --git a/src/frontend/mame/ui/mainmenu.cpp b/src/frontend/mame/ui/mainmenu.cpp index bd7f274da29..b1a0e238935 100644 --- a/src/frontend/mame/ui/mainmenu.cpp +++ b/src/frontend/mame/ui/mainmenu.cpp @@ -22,6 +22,7 @@ #include "ui/info_pty.h" #include "ui/inifile.h" #include "ui/inputmap.h" +#include "ui/keyboard.h" #include "ui/miscmenu.h" #include "ui/pluginopt.h" #include "ui/selgame.h" @@ -108,7 +109,7 @@ void menu_main::populate(float &customtop, float &custombottom) if (network_interface_iterator(machine().root_device()).first() != nullptr) item_append(_("Network Devices"), "", 0, (void*)NETWORK_DEVICES); - if (ui().machine_info().has_keyboard() && machine().ioport().natkeyboard().can_post()) + if (machine().ioport().natkeyboard().keyboard_count()) item_append(_("Keyboard Mode"), "", 0, (void *)KEYBOARD_MODE); item_append(_("Slider Controls"), "", 0, (void *)SLIDERS); diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp index 82b7916e3a5..f0ab531360e 100644 --- a/src/frontend/mame/ui/miscmenu.cpp +++ b/src/frontend/mame/ui/miscmenu.cpp @@ -23,7 +23,6 @@ #include "mameopts.h" #include "pluginopts.h" #include "drivenum.h" -#include "natkeyboard.h" #include "romload.h" #include "uiinput.h" @@ -41,42 +40,6 @@ namespace ui { ***************************************************************************/ /*------------------------------------------------- - menu_keyboard_mode - menu that --------------------------------------------------*/ - -menu_keyboard_mode::menu_keyboard_mode(mame_ui_manager &mui, render_container &container) : menu(mui, container) -{ -} - -void menu_keyboard_mode::populate(float &customtop, float &custombottom) -{ - bool natural = machine().ioport().natkeyboard().in_use(); - item_append(_("Keyboard Mode:"), natural ? _("Natural") : _("Emulated"), natural ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, nullptr); -} - -menu_keyboard_mode::~menu_keyboard_mode() -{ -} - -void menu_keyboard_mode::handle() -{ - bool natural = machine().ioport().natkeyboard().in_use(); - - /* process the menu */ - const event *menu_event = process(0); - - if (menu_event != nullptr) - { - if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) - { - machine().ioport().natkeyboard().set_in_use(!natural); - reset(reset_options::REMEMBER_REF); - } - } -} - - -/*------------------------------------------------- menu_bios_selection - populates the main bios selection menu -------------------------------------------------*/ diff --git a/src/frontend/mame/ui/miscmenu.h b/src/frontend/mame/ui/miscmenu.h index acff544dee6..c8d833ae4e2 100644 --- a/src/frontend/mame/ui/miscmenu.h +++ b/src/frontend/mame/ui/miscmenu.h @@ -7,7 +7,6 @@ Internal MAME menus for the user interface. ***************************************************************************/ - #ifndef MAME_FRONTEND_UI_MISCMENU_H #define MAME_FRONTEND_UI_MISCMENU_H @@ -24,17 +23,6 @@ namespace ui { -class menu_keyboard_mode : public menu -{ -public: - menu_keyboard_mode(mame_ui_manager &mui, render_container &container); - virtual ~menu_keyboard_mode(); - -private: - virtual void populate(float &customtop, float &custombottom) override; - virtual void handle() override; -}; - class menu_network_devices : public menu { public: diff --git a/src/frontend/mame/ui/videoopt.cpp b/src/frontend/mame/ui/videoopt.cpp index 58818328d41..2a876c5a1af 100644 --- a/src/frontend/mame/ui/videoopt.cpp +++ b/src/frontend/mame/ui/videoopt.cpp @@ -141,7 +141,7 @@ void menu_video_options::handle() // process the menu event const *const menu_event(process(0)); - if (menu_event && menu_event->itemref) + if (menu_event && uintptr_t(menu_event->itemref)) { switch (reinterpret_cast<uintptr_t>(menu_event->itemref)) { |