CDriverPrimitive CPeripheralAddonTranslator::TranslatePrimitive(const ADDON::DriverPrimitive& primitive) { CDriverPrimitive retVal; switch (primitive.Type()) { case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: { retVal = CDriverPrimitive(PRIMITIVE_TYPE::BUTTON, primitive.DriverIndex()); break; } case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION: { retVal = CDriverPrimitive(primitive.DriverIndex(), TranslateHatDirection(primitive.HatDirection())); break; } case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: { retVal = CDriverPrimitive(primitive.DriverIndex(), primitive.Center(), TranslateSemiAxisDirection(primitive.SemiAxisDirection()), primitive.Range()); break; } case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: { retVal = CDriverPrimitive(PRIMITIVE_TYPE::MOTOR, primitive.DriverIndex()); break; } default: break; } return retVal; }
std::string ButtonMapTranslator::ToString(const ADDON::DriverPrimitive& primitive) { std::stringstream strPrimitive; switch (primitive.Type()) { case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: { strPrimitive << primitive.DriverIndex(); break; } case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION: { strPrimitive << HAT_CHAR; strPrimitive << primitive.DriverIndex(); strPrimitive << JoystickTranslator::TranslateHatDir(primitive.HatDirection()); break; } case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: { const char* dir = JoystickTranslator::TranslateSemiAxisDir(primitive.SemiAxisDirection()); if (*dir != '\0') { strPrimitive << dir; strPrimitive << primitive.DriverIndex(); } break; } default: break; } return strPrimitive.str(); }
ADDON::DriverPrimitive CPeripheralAddonTranslator::Opposite(const ADDON::DriverPrimitive& primitive) { return ADDON::DriverPrimitive(primitive.DriverIndex(), primitive.Center() * -1, primitive.SemiAxisDirection() * -1, primitive.Range()); }