Skip to content

Commit

Permalink
Update to peripheral API v1.0.24 - Fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
garbear committed Aug 26, 2016
1 parent ff08865 commit 4033986
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 64 deletions.
8 changes: 4 additions & 4 deletions src/api/udev/JoystickInterfaceUdev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ bool CJoystickInterfaceUdev::ScanForJoysticks(JoystickVector& joysticks)
const ButtonMap& CJoystickInterfaceUdev::GetButtonMap()
{
auto& dflt = m_buttonMap["game.controller.default"];
dflt[CJoystickUdev::MOTOR_STRONG].SetPrimitive(ADDON::DriverPrimitive::CreateMotor(CJoystickUdev::MOTOR_STRONG));
dflt[CJoystickUdev::MOTOR_WEAK].SetPrimitive(ADDON::DriverPrimitive::CreateMotor(CJoystickUdev::MOTOR_WEAK));
dflt[CJoystickUdev::MOTOR_STRONG].SetPrimitive(JOYSTICK_MOTOR_PRIMITIVE, ADDON::DriverPrimitive::CreateMotor(CJoystickUdev::MOTOR_STRONG));
dflt[CJoystickUdev::MOTOR_WEAK].SetPrimitive(JOYSTICK_MOTOR_PRIMITIVE, ADDON::DriverPrimitive::CreateMotor(CJoystickUdev::MOTOR_WEAK));

auto& ps = m_buttonMap["game.controller.ps"];
ps[CJoystickUdev::MOTOR_STRONG].SetPrimitive(ADDON::DriverPrimitive::CreateMotor(CJoystickUdev::MOTOR_STRONG));
ps[CJoystickUdev::MOTOR_WEAK].SetPrimitive(ADDON::DriverPrimitive::CreateMotor(CJoystickUdev::MOTOR_WEAK));
ps[CJoystickUdev::MOTOR_STRONG].SetPrimitive(JOYSTICK_MOTOR_PRIMITIVE, ADDON::DriverPrimitive::CreateMotor(CJoystickUdev::MOTOR_STRONG));
ps[CJoystickUdev::MOTOR_WEAK].SetPrimitive(JOYSTICK_MOTOR_PRIMITIVE, ADDON::DriverPrimitive::CreateMotor(CJoystickUdev::MOTOR_WEAK));

return m_buttonMap;
}
17 changes: 9 additions & 8 deletions src/buttonmapper/ControllerTransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,26 @@ bool CControllerTransformer::AddControllerMap(const std::string& controllerFrom,
{
if (fromFeature.Type() == feature.Type())
{
return fromFeature.Primitives() == feature.Primitives();
switch (feature.Type())
{
case JOYSTICK_FEATURE_TYPE_SCALAR:
case JOYSTICK_FEATURE_TYPE_MOTOR:
{
return fromFeature.Primitive() == feature.Primitive();
return fromFeature.Primitive(JOYSTICK_SCALAR_PRIMITIVE) == feature.Primitive(JOYSTICK_SCALAR_PRIMITIVE);
}
case JOYSTICK_FEATURE_TYPE_ANALOG_STICK:
{
return fromFeature.Up() == feature.Up() &&
fromFeature.Down() == feature.Down() &&
fromFeature.Right() == feature.Right() &&
fromFeature.Left() == feature.Left();
return fromFeature.Primitive(JOYSTICK_ANALOG_STICK_UP) == feature.Primitive(JOYSTICK_ANALOG_STICK_UP) &&
fromFeature.Primitive(JOYSTICK_ANALOG_STICK_DOWN) == feature.Primitive(JOYSTICK_ANALOG_STICK_DOWN) &&
fromFeature.Primitive(JOYSTICK_ANALOG_STICK_RIGHT) == feature.Primitive(JOYSTICK_ANALOG_STICK_RIGHT) &&
fromFeature.Primitive(JOYSTICK_ANALOG_STICK_LEFT) == feature.Primitive(JOYSTICK_ANALOG_STICK_LEFT);
}
case JOYSTICK_FEATURE_TYPE_ACCELEROMETER:
{
return fromFeature.PositiveX() == feature.PositiveX() &&
fromFeature.PositiveY() == feature.PositiveY() &&
fromFeature.PositiveZ() == feature.PositiveZ();
return fromFeature.Primitive(JOYSTICK_ACCELEROMETER_POSITIVE_X) == feature.Primitive(JOYSTICK_ACCELEROMETER_POSITIVE_X) &&
fromFeature.Primitive(JOYSTICK_ACCELEROMETER_POSITIVE_Y) == feature.Primitive(JOYSTICK_ACCELEROMETER_POSITIVE_Y) &&
fromFeature.Primitive(JOYSTICK_ACCELEROMETER_POSITIVE_Z) == feature.Primitive(JOYSTICK_ACCELEROMETER_POSITIVE_Z);
}
default:
break;
Expand Down
74 changes: 22 additions & 52 deletions src/storage/xml/ButtonMapXml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,42 +264,42 @@ bool CButtonMapXml::Serialize(const FeatureVector& features, TiXmlElement* pElem
{
case JOYSTICK_FEATURE_TYPE_SCALAR:
{
SerializePrimitive(featureElem, feature.Primitive());
SerializePrimitive(featureElem, feature.Primitive(JOYSTICK_SCALAR_PRIMITIVE));

break;
}
case JOYSTICK_FEATURE_TYPE_ANALOG_STICK:
{
if (!SerializePrimitiveTag(featureElem, feature.Up(), BUTTONMAP_XML_ELEM_UP))
if (!SerializePrimitiveTag(featureElem, feature.Primitive(JOYSTICK_ANALOG_STICK_UP), BUTTONMAP_XML_ELEM_UP))
return false;

if (!SerializePrimitiveTag(featureElem, feature.Down(), BUTTONMAP_XML_ELEM_DOWN))
if (!SerializePrimitiveTag(featureElem, feature.Primitive(JOYSTICK_ANALOG_STICK_DOWN), BUTTONMAP_XML_ELEM_DOWN))
return false;

if (!SerializePrimitiveTag(featureElem, feature.Right(), BUTTONMAP_XML_ELEM_RIGHT))
if (!SerializePrimitiveTag(featureElem, feature.Primitive(JOYSTICK_ANALOG_STICK_RIGHT), BUTTONMAP_XML_ELEM_RIGHT))
return false;

if (!SerializePrimitiveTag(featureElem, feature.Left(), BUTTONMAP_XML_ELEM_LEFT))
if (!SerializePrimitiveTag(featureElem, feature.Primitive(JOYSTICK_ANALOG_STICK_LEFT), BUTTONMAP_XML_ELEM_LEFT))
return false;

break;
}
case JOYSTICK_FEATURE_TYPE_ACCELEROMETER:
{
if (!SerializePrimitiveTag(featureElem, feature.PositiveX(), BUTTONMAP_XML_ELEM_POSITIVE_X))
if (!SerializePrimitiveTag(featureElem, feature.Primitive(JOYSTICK_ACCELEROMETER_POSITIVE_X), BUTTONMAP_XML_ELEM_POSITIVE_X))
return false;

if (!SerializePrimitiveTag(featureElem, feature.PositiveY(), BUTTONMAP_XML_ELEM_POSITIVE_Y))
if (!SerializePrimitiveTag(featureElem, feature.Primitive(JOYSTICK_ACCELEROMETER_POSITIVE_Y), BUTTONMAP_XML_ELEM_POSITIVE_Y))
return false;

if (!SerializePrimitiveTag(featureElem, feature.PositiveZ(), BUTTONMAP_XML_ELEM_POSITIVE_Z))
if (!SerializePrimitiveTag(featureElem, feature.Primitive(JOYSTICK_ACCELEROMETER_POSITIVE_Z), BUTTONMAP_XML_ELEM_POSITIVE_Z))
return false;

break;
}
case JOYSTICK_FEATURE_TYPE_MOTOR:
{
SerializePrimitive(featureElem, feature.Primitive());
SerializePrimitive(featureElem, feature.Primitive(JOYSTICK_MOTOR_PRIMITIVE));

break;
}
Expand All @@ -313,43 +313,13 @@ bool CButtonMapXml::Serialize(const FeatureVector& features, TiXmlElement* pElem

bool CButtonMapXml::IsValid(const ADDON::JoystickFeature& feature)
{
bool bIsValid = false;

switch (feature.Type())
{
case JOYSTICK_FEATURE_TYPE_SCALAR:
case JOYSTICK_FEATURE_TYPE_MOTOR:
{
if (feature.Primitive().Type() != JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN)
bIsValid = true;
break;
}
case JOYSTICK_FEATURE_TYPE_ANALOG_STICK:
{
if (feature.Up().Type() != JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN ||
feature.Down().Type() != JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN ||
feature.Right().Type() != JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN ||
feature.Left().Type() != JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN)
{
bIsValid = true;
}
break;
}
case JOYSTICK_FEATURE_TYPE_ACCELEROMETER:
auto itValid = std::find_if(feature.Primitives().begin(), feature.Primitives().end(),
[](const ADDON::DriverPrimitive& primitive)
{
if (feature.PositiveX().Type() != JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN ||
feature.PositiveY().Type() != JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN ||
feature.PositiveZ().Type() != JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN)
{
bIsValid = true;
}
break;
}
default:
break;
}
return primitive.Type() != JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN;
});

return bIsValid;
return itValid != feature.Primitives().end();
}

bool CButtonMapXml::SerializePrimitiveTag(TiXmlElement* pElement, const ADDON::DriverPrimitive& primitive, const char* tagName)
Expand Down Expand Up @@ -480,7 +450,7 @@ bool CButtonMapXml::Deserialize(const TiXmlElement* pElement, FeatureVector& fea
{
case JOYSTICK_FEATURE_TYPE_SCALAR:
{
feature.SetPrimitive(primitive);
feature.SetPrimitive(JOYSTICK_SCALAR_PRIMITIVE, primitive);
break;
}
case JOYSTICK_FEATURE_TYPE_ANALOG_STICK:
Expand Down Expand Up @@ -519,10 +489,10 @@ bool CButtonMapXml::Deserialize(const TiXmlElement* pElement, FeatureVector& fea
if (!bSuccess)
return false;

feature.SetUp(up);
feature.SetDown(down);
feature.SetRight(right);
feature.SetLeft(left);
feature.SetPrimitive(JOYSTICK_ANALOG_STICK_UP, up);
feature.SetPrimitive(JOYSTICK_ANALOG_STICK_DOWN, down);
feature.SetPrimitive(JOYSTICK_ANALOG_STICK_RIGHT, right);
feature.SetPrimitive(JOYSTICK_ANALOG_STICK_LEFT, left);

break;
}
Expand Down Expand Up @@ -555,9 +525,9 @@ bool CButtonMapXml::Deserialize(const TiXmlElement* pElement, FeatureVector& fea
if (!bSuccess)
return false;

feature.SetPositiveX(positiveX);
feature.SetPositiveY(positiveY);
feature.SetPositiveZ(positiveZ);
feature.SetPrimitive(JOYSTICK_ACCELEROMETER_POSITIVE_X, positiveX);
feature.SetPrimitive(JOYSTICK_ACCELEROMETER_POSITIVE_Y, positiveY);
feature.SetPrimitive(JOYSTICK_ACCELEROMETER_POSITIVE_Z, positiveZ);

break;
}
Expand Down

0 comments on commit 4033986

Please sign in to comment.