Skip to content

Commit

Permalink
[buttonmapper] Remove separate models for geometry and family
Browse files Browse the repository at this point in the history
This removes the addition of geometry- and family-specific models in
ed237b8.
  • Loading branch information
garbear committed Aug 16, 2016
1 parent ce0cab7 commit b0d9715
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 30 deletions.
27 changes: 2 additions & 25 deletions src/buttonmapper/ControllerTransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,12 @@ void CControllerTransformer::OnAdd(const DevicePtr& driverInfo, const ButtonMap&
else
return;

const std::string& familyName = m_familyManager.GetFamily(driverInfo->Name(), driverInfo->Provider());

CJoystickFamily family(familyName);
CDriverGeometry geometry(driverInfo->ButtonCount(),
driverInfo->HatCount(),
driverInfo->AxisCount());

CControllerModel& familyModel = m_familyModels[family];
CControllerModel& geometryModel = m_geometryModels[geometry];

for (auto itTo = buttonMap.begin(); itTo != buttonMap.end(); ++itTo)
{
// Only allow controller map items where "from" compares before "to"
for (auto itFrom = buttonMap.begin(); itFrom->first < itTo->first; ++itFrom)
{
if (family.IsValid())
AddControllerMap(familyModel, itFrom->first, itFrom->second, itTo->first, itTo->second);
if (geometry.IsValid())
AddControllerMap(geometryModel, itFrom->first, itFrom->second, itTo->first, itTo->second);
AddControllerMap(m_controllerModel, itFrom->first, itFrom->second, itTo->first, itTo->second);
}
}
}
Expand Down Expand Up @@ -143,17 +130,7 @@ void CControllerTransformer::TransformFeatures(const ADDON::Joystick& driverInfo
ControllerMapItem needle = { bSwap ? toController : fromController,
bSwap ? fromController : toController };

const std::string& familyName = m_familyManager.GetFamily(driverInfo.Name(), driverInfo.Provider());

CJoystickFamily family(familyName);
CDriverGeometry geometry(driverInfo.ButtonCount(),
driverInfo.HatCount(),
driverInfo.AxisCount());

CControllerModel& familyModel = m_familyModels[family];
CControllerModel& geometryModel = m_geometryModels[geometry];

std::array<CControllerModel*, 2> models = { &familyModel, &geometryModel };
std::array<CControllerModel*, 1> models = { &m_controllerModel };

for (CControllerModel* model : models)
{
Expand Down
6 changes: 1 addition & 5 deletions src/buttonmapper/ControllerTransformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ namespace JOYSTICK
const std::string& controllerFrom, const FeatureVector& featuresFrom,
const std::string& controllerTo, const FeatureVector& featuresTo);

typedef std::map<CJoystickFamily, CControllerModel> FamilyMap;
typedef std::map<CDriverGeometry, CControllerModel> GeomoetryMap;

FamilyMap m_familyModels;
GeomoetryMap m_geometryModels;
CControllerModel m_controllerModel;
DeviceSet m_observedDevices;
CJoystickFamilyManager& m_familyManager;
};
Expand Down

0 comments on commit b0d9715

Please sign in to comment.