Esempio n. 1
0
bool CAddonButtonMap::AddScalar(const FeatureName& feature, const CDriverPrimitive& primitive)
{
  if (!primitive.IsValid())
  {
    FeatureMap::iterator it = m_features.find(feature);
    if (it != m_features.end())
      m_features.erase(it);
  }
  else
  {
    UnmapPrimitive(primitive);

    ADDON::JoystickFeature scalar(feature, JOYSTICK_FEATURE_TYPE_SCALAR);
    scalar.SetPrimitive(CPeripheralAddonTranslator::TranslatePrimitive(primitive));

    m_features[feature] = scalar;
  }

  m_driverMap = CreateLookupTable(m_features);

  if (auto addon = m_addon.lock())
    return addon->MapFeatures(m_device, m_strControllerId, m_features);

  return false;
}
Esempio n. 2
0
bool CPrimitiveDetector::MapPrimitive(const CDriverPrimitive &primitive)
{
  if (primitive.IsValid())
    return m_buttonMapping->MapPrimitive(primitive);

  return false;
}
Esempio n. 3
0
bool CAddonButtonMap::AddAnalogStick(const FeatureName& feature,
                                             const CDriverPrimitive& up,
                                             const CDriverPrimitive& down,
                                             const CDriverPrimitive& right,
                                             const CDriverPrimitive& left)
{
  if (!up.IsValid() && !down.IsValid() && !right.IsValid() && !left.IsValid())
  {
    FeatureMap::iterator it = m_features.find(feature);
    if (it != m_features.end())
      m_features.erase(it);
  }
  else
  {
    ADDON::JoystickFeature analogStick(feature, JOYSTICK_FEATURE_TYPE_ANALOG_STICK);

    if (up.IsValid())
    {
      UnmapPrimitive(up);
      analogStick.SetUp(CPeripheralAddonTranslator::TranslatePrimitive(up));
    }
    if (down.IsValid())
    {
      UnmapPrimitive(down);
      analogStick.SetDown(CPeripheralAddonTranslator::TranslatePrimitive(down));
    }
    if (right.IsValid())
    {
      UnmapPrimitive(right);
      analogStick.SetRight(CPeripheralAddonTranslator::TranslatePrimitive(right));
    }
    if (left.IsValid())
    {
      UnmapPrimitive(left);
      analogStick.SetLeft(CPeripheralAddonTranslator::TranslatePrimitive(left));
    }

    m_features[feature] = analogStick;
  }

  m_driverMap = CreateLookupTable(m_features);

  if (auto addon = m_addon.lock())
    return addon->MapFeatures(m_device, m_strControllerId, m_features);

  return false;
}
Esempio n. 4
0
bool CAddonButtonMap::AddAccelerometer(const FeatureName& feature,
                                               const CDriverPrimitive& positiveX,
                                               const CDriverPrimitive& positiveY,
                                               const CDriverPrimitive& positiveZ)
{
  if (positiveX.IsValid() && positiveY.IsValid() && positiveZ.IsValid())
  {
    FeatureMap::iterator it = m_features.find(feature);
    if (it != m_features.end())
      m_features.erase(it);
  }
  else
  {
    ADDON::JoystickFeature accelerometer(feature, JOYSTICK_FEATURE_TYPE_ACCELEROMETER);

    if (positiveX.IsValid())
    {
      UnmapPrimitive(positiveX);
      accelerometer.SetPositiveX(CPeripheralAddonTranslator::TranslatePrimitive(positiveX));
    }
    if (positiveY.IsValid())
    {
      UnmapPrimitive(positiveY);
      accelerometer.SetPositiveY(CPeripheralAddonTranslator::TranslatePrimitive(positiveY));
    }
    if (positiveZ.IsValid())
    {
      UnmapPrimitive(positiveZ);
      accelerometer.SetPositiveZ(CPeripheralAddonTranslator::TranslatePrimitive(positiveZ));
    }

    // TODO: Unmap complementary semiaxes

    m_features[feature] = accelerometer;
  }

  m_driverMap = CreateLookupTable(m_features);

  if (auto addon = m_addon.lock())
    return addon->MapFeatures(m_device, m_strControllerId, m_features);

  return false;
}