コード例 #1
0
ADDON::DriverPrimitive CPeripheralAddonTranslator::TranslatePrimitive(const CDriverPrimitive& primitive)
{
  ADDON::DriverPrimitive retVal;

  switch (primitive.Type())
  {
    case CDriverPrimitive::BUTTON:
    {
      retVal = ADDON::DriverPrimitive(primitive.Index());
      break;
    }
    case CDriverPrimitive::HAT:
    {
      retVal = ADDON::DriverPrimitive(primitive.Index(), TranslateHatDirection(primitive.HatDirection()));
      break;
    }
    case CDriverPrimitive::SEMIAXIS:
    {
      retVal = ADDON::DriverPrimitive(primitive.Index(), TranslateSemiAxisDirection(primitive.SemiAxisDirection()));
      break;
    }
    default:
      break;
  }

  return retVal;
}
コード例 #2
0
ADDON::DriverPrimitive CPeripheralAddonTranslator::TranslatePrimitive(const CDriverPrimitive& primitive)
{
  ADDON::DriverPrimitive retVal;

  switch (primitive.Type())
  {
    case BUTTON:
    {
      retVal = ADDON::DriverPrimitive::CreateButton(primitive.Index());
      break;
    }
    case HAT:
    {
      retVal = ADDON::DriverPrimitive(primitive.Index(), TranslateHatDirection(primitive.HatDirection()));
      break;
    }
    case SEMIAXIS:
    {
      retVal = ADDON::DriverPrimitive(primitive.Index(), primitive.Center(), TranslateSemiAxisDirection(primitive.SemiAxisDirection()), primitive.Range());
      break;
    }
    case MOTOR:
    {
      retVal = ADDON::DriverPrimitive::CreateMotor(primitive.Index());
      break;
    }
    default:
      break;
  }

  return retVal;
}
コード例 #3
0
ファイル: AddonButtonMap.cpp プロジェクト: AchimTuran/xbmc
CAddonButtonMap::DriverMap CAddonButtonMap::CreateLookupTable(const FeatureMap& features)
{
  using namespace JOYSTICK;

  DriverMap driverMap;

  for (FeatureMap::const_iterator it = features.begin(); it != features.end(); ++it)
  {
    const ADDON::JoystickFeature& feature = it->second;

    switch (feature.Type())
    {
      case JOYSTICK_FEATURE_TYPE_SCALAR:
      {
        driverMap[CPeripheralAddonTranslator::TranslatePrimitive(feature.Primitive(JOYSTICK_SCALAR_PRIMITIVE))] = it->first;
        break;
      }

      case JOYSTICK_FEATURE_TYPE_ANALOG_STICK:
      {
        std::vector<JOYSTICK_FEATURE_PRIMITIVE> primitives = {
          JOYSTICK_ANALOG_STICK_UP,
          JOYSTICK_ANALOG_STICK_DOWN,
          JOYSTICK_ANALOG_STICK_RIGHT,
          JOYSTICK_ANALOG_STICK_LEFT,
        };

        for (auto primitive : primitives)
          driverMap[CPeripheralAddonTranslator::TranslatePrimitive(feature.Primitive(primitive))] = it->first;
        break;
      }

      case JOYSTICK_FEATURE_TYPE_ACCELEROMETER:
      {
        std::vector<JOYSTICK_FEATURE_PRIMITIVE> primitives = {
          JOYSTICK_ACCELEROMETER_POSITIVE_X,
          JOYSTICK_ACCELEROMETER_POSITIVE_Y,
          JOYSTICK_ACCELEROMETER_POSITIVE_Z,
        };

        for (auto primitive : primitives)
        {
          CDriverPrimitive translatedPrimitive = CPeripheralAddonTranslator::TranslatePrimitive(feature.Primitive(primitive));
          driverMap[translatedPrimitive] = it->first;

          // Map opposite semiaxis
          CDriverPrimitive oppositePrimitive = CDriverPrimitive(translatedPrimitive.Index(), 0, translatedPrimitive.SemiAxisDirection() * -1, 1);
          driverMap[oppositePrimitive] = it->first;
        }
        break;
      }
        
      default:
        break;
    }
  }
  
  return driverMap;
}
コード例 #4
0
kodi::addon::DriverPrimitive CPeripheralAddonTranslator::TranslatePrimitive(const CDriverPrimitive& primitive)
{
  kodi::addon::DriverPrimitive retVal;

  switch (primitive.Type())
  {
    case PRIMITIVE_TYPE::BUTTON:
    {
      retVal = kodi::addon::DriverPrimitive::CreateButton(primitive.Index());
      break;
    }
    case PRIMITIVE_TYPE::HAT:
    {
      retVal = kodi::addon::DriverPrimitive(primitive.Index(), TranslateHatDirection(primitive.HatDirection()));
      break;
    }
    case PRIMITIVE_TYPE::SEMIAXIS:
    {
      retVal = kodi::addon::DriverPrimitive(primitive.Index(), primitive.Center(), TranslateSemiAxisDirection(primitive.SemiAxisDirection()), primitive.Range());
      break;
    }
    case PRIMITIVE_TYPE::MOTOR:
    {
      retVal = kodi::addon::DriverPrimitive::CreateMotor(primitive.Index());
      break;
    }
    case PRIMITIVE_TYPE::KEY:
    {
      std::string keysym = GAME::CControllerTranslator::TranslateKeycode(primitive.Keycode());
      retVal = kodi::addon::DriverPrimitive(keysym);
      break;
    }
    case PRIMITIVE_TYPE::MOUSE_BUTTON:
    {
      retVal = kodi::addon::DriverPrimitive::CreateMouseButton(TranslateMouseButton(primitive.MouseButton()));
      break;
    }
    case PRIMITIVE_TYPE::RELATIVE_POINTER:
    {
      retVal = kodi::addon::DriverPrimitive(TranslateRelPointerDirection(primitive.PointerDirection()));
      break;
    }
    default:
      break;
  }

  return retVal;
}