mirror of https://github.com/stella-emu/stella.git
added sorting when saving JoyMap and KeyMap
This commit is contained in:
parent
ccc185de54
commit
6a35a06fcf
|
@ -189,9 +189,35 @@ JoyMap::JoyMappingArray JoyMap::getEventMapping(const Event::Type event, const E
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
json JoyMap::saveMapping(const EventMode mode) const
|
json JoyMap::saveMapping(const EventMode mode) const
|
||||||
{
|
{
|
||||||
|
using MapType = std::pair<JoyMapping, Event::Type>;
|
||||||
|
std::vector<MapType> sortedMap(myMap.begin(), myMap.end());
|
||||||
|
|
||||||
|
std::sort(sortedMap.begin(), sortedMap.end(),
|
||||||
|
[](const MapType& a, const MapType& b)
|
||||||
|
{
|
||||||
|
// Event::Type first
|
||||||
|
if(a.second != b.second)
|
||||||
|
return a.second < b.second;
|
||||||
|
|
||||||
|
if(a.first.button != b.first.button)
|
||||||
|
return a.first.button < b.first.button;
|
||||||
|
|
||||||
|
if(a.first.axis != b.first.axis)
|
||||||
|
return a.first.axis < b.first.axis;
|
||||||
|
|
||||||
|
if(a.first.adir != b.first.adir)
|
||||||
|
return a.first.adir < b.first.adir;
|
||||||
|
|
||||||
|
if(a.first.hat != b.first.hat)
|
||||||
|
return a.first.hat < b.first.hat;
|
||||||
|
|
||||||
|
return a.first.hdir < b.first.hdir;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
json eventMappings = json::array();
|
json eventMappings = json::array();
|
||||||
|
|
||||||
for (const auto& [_mapping, _event]: myMap) {
|
for (const auto& [_mapping, _event]: sortedMap) {
|
||||||
if (_mapping.mode != mode) continue;
|
if (_mapping.mode != mode) continue;
|
||||||
|
|
||||||
json eventMapping = json::object();
|
json eventMapping = json::object();
|
||||||
|
|
|
@ -221,9 +221,26 @@ KeyMap::MappingArray KeyMap::getEventMapping(const Event::Type event, const Even
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
json KeyMap::saveMapping(const EventMode mode) const
|
json KeyMap::saveMapping(const EventMode mode) const
|
||||||
{
|
{
|
||||||
|
using MapType = std::pair<Mapping, Event::Type>;
|
||||||
|
std::vector<MapType> sortedMap(myMap.begin(), myMap.end());
|
||||||
|
|
||||||
|
std::sort(sortedMap.begin(), sortedMap.end(),
|
||||||
|
[](const MapType& a, const MapType& b)
|
||||||
|
{
|
||||||
|
// Event::Type first
|
||||||
|
if(a.second != b.second)
|
||||||
|
return a.second < b.second;
|
||||||
|
|
||||||
|
if(a.first.key != b.first.key)
|
||||||
|
return a.first.key < b.first.key;
|
||||||
|
|
||||||
|
return a.first.mod < b.first.mod;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
json mappings = json::array();
|
json mappings = json::array();
|
||||||
|
|
||||||
for (const auto& [_mapping, _event]: myMap) {
|
for (const auto& [_mapping, _event]: sortedMap) {
|
||||||
if (_mapping.mode != mode) continue;
|
if (_mapping.mode != mode) continue;
|
||||||
|
|
||||||
json mapping = json::object();
|
json mapping = json::object();
|
||||||
|
|
Loading…
Reference in New Issue