From 4ccfe06061b0bf98f25e0a34157e2b7f1bd72c3c Mon Sep 17 00:00:00 2001 From: AJR Date: Sat, 31 Aug 2019 17:14:48 -0400 Subject: Distinguish DIP switches that belong to different devices but have the same name in UI menu. This is most likely to occur when multiple instances of the same device type are configured on bus slots. --- src/frontend/mame/ui/inputmap.cpp | 5 +++-- src/frontend/mame/ui/inputmap.h | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/frontend/mame/ui/inputmap.cpp b/src/frontend/mame/ui/inputmap.cpp index a2bbf3b7a21..eb90215520e 100644 --- a/src/frontend/mame/ui/inputmap.cpp +++ b/src/frontend/mame/ui/inputmap.cpp @@ -592,7 +592,7 @@ void menu_settings::populate(float &customtop, float &custombottom) /* find the matching switch name */ for (dip = diplist; dip != nullptr; dip = dip->next) - if (strcmp(dip->name, diploc.name()) == 0) + if (dip->owner == &field.device() && strcmp(dip->name, diploc.name()) == 0) break; /* allocate new if none */ @@ -601,6 +601,7 @@ void menu_settings::populate(float &customtop, float &custombottom) dip = (dip_descriptor *)m_pool_alloc(sizeof(*dip)); dip->next = nullptr; dip->name = diploc.name(); + dip->owner = &field.device(); dip->mask = dip->state = 0; *diplist_tailptr = dip; diplist_tailptr = &dip->next; @@ -659,7 +660,7 @@ void menu_settings_dip_switches::custom_render(void *selectedref, float top, flo if (field != nullptr && !field->diplocations().empty()) for (const ioport_diplocation &diploc : field->diplocations()) - if (strcmp(dip->name, diploc.name()) == 0) + if (dip->owner == &field->device() && strcmp(dip->name, diploc.name()) == 0) selectedmask |= 1 << (diploc.number() - 1); } diff --git a/src/frontend/mame/ui/inputmap.h b/src/frontend/mame/ui/inputmap.h index eaa0eaa76f1..a37a297a2f8 100644 --- a/src/frontend/mame/ui/inputmap.h +++ b/src/frontend/mame/ui/inputmap.h @@ -110,8 +110,9 @@ protected: { dip_descriptor * next; const char * name; - uint32_t mask; - uint32_t state; + device_t * owner; + uint32_t mask; + uint32_t state; }; dip_descriptor * diplist; -- cgit v1.2.3