mirror of https://github.com/stella-emu/stella.git
2nd attempt to fix #620
This commit is contained in:
parent
4400ba42c0
commit
f290f9ead1
|
@ -66,6 +66,16 @@ PhysicalKeyboardHandler::PhysicalKeyboardHandler(OSystem& system, EventHandler&
|
|||
setDefaultMapping(Event::NoType, EventMode::kMenuMode, true);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PhysicalKeyboardHandler::isMappingUsed(EventMapping map)
|
||||
{
|
||||
for(int i = 0; i < int(EventMode::kNumModes); ++i)
|
||||
if(myKeyMap.check(EventMode(i), map.key, map.mod))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// Depending on parameters, this method does the following:
|
||||
// 1. update all events with default (event == Event::NoType, updateDefault == true)
|
||||
|
@ -83,7 +93,7 @@ void PhysicalKeyboardHandler::setDefaultKey(EventMapping map, Event::Type event,
|
|||
// if there is no existing mapping for the event and
|
||||
// the default mapping for the event is unused, set default key for event
|
||||
if (myKeyMap.getEventMapping(map.event, mode).size() == 0 &&
|
||||
!myKeyMap.check(mode, map.key, map.mod))
|
||||
!isMappingUsed(map))
|
||||
{
|
||||
addMapping(map.event, mode, map.key, StellaMod(map.mod));
|
||||
}
|
||||
|
|
|
@ -87,6 +87,9 @@ class PhysicalKeyboardHandler
|
|||
};
|
||||
using EventMappingArray = std::vector<EventMapping>;
|
||||
|
||||
// Checks if the given mapping is used by any event mode
|
||||
bool isMappingUsed(EventMapping map);
|
||||
|
||||
void setDefaultKey(EventMapping map, Event::Type event = Event::NoType,
|
||||
EventMode mode = EventMode::kEmulationMode, bool updateDefaults = false);
|
||||
|
||||
|
|
|
@ -82,7 +82,8 @@ enum class EventMode {
|
|||
kPaddlesMode,
|
||||
kKeypadMode,
|
||||
kCompuMateMode, // cannot be remapped
|
||||
kCommonMode // mapping common between controllers
|
||||
kCommonMode, // mapping common between controllers
|
||||
kNumModes
|
||||
};
|
||||
|
||||
namespace GUI
|
||||
|
|
Loading…
Reference in New Issue