bool CButtonMapXml::IsValid(const ADDON::JoystickFeature& feature) { bool bIsValid = false; switch (feature.Type()) { case JOYSTICK_FEATURE_TYPE_SCALAR: { 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: { 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 bIsValid; }
bool CAddonButtonMap::ResetPrimitive(ADDON::JoystickFeature& feature, const ADDON::DriverPrimitive& primitive) { bool bModified = false; switch (feature.Type()) { case JOYSTICK_FEATURE_TYPE_SCALAR: { if (primitive == feature.Primitive()) { CLog::Log(LOGDEBUG, "Removing \"%s\" from button map due to conflict", feature.Name().c_str()); feature.SetType(JOYSTICK_FEATURE_TYPE_UNKNOWN); bModified = true; } break; } case JOYSTICK_FEATURE_TYPE_ANALOG_STICK: { if (primitive == feature.Up()) { feature.SetUp(ADDON::DriverPrimitive()); bModified = true; } else if (primitive == feature.Down()) { feature.SetDown(ADDON::DriverPrimitive()); bModified = true; } else if (primitive == feature.Right()) { feature.SetRight(ADDON::DriverPrimitive()); bModified = true; } else if (primitive == feature.Left()) { feature.SetLeft(ADDON::DriverPrimitive()); bModified = true; } if (bModified) { 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) { CLog::Log(LOGDEBUG, "Removing \"%s\" from button map due to conflict", feature.Name().c_str()); feature.SetType(JOYSTICK_FEATURE_TYPE_UNKNOWN); } } break; } case JOYSTICK_FEATURE_TYPE_ACCELEROMETER: { if (primitive == feature.PositiveX() || primitive == CPeripheralAddonTranslator::Opposite(feature.PositiveX())) { feature.SetPositiveX(ADDON::DriverPrimitive()); bModified = true; } else if (primitive == feature.PositiveY() || primitive == CPeripheralAddonTranslator::Opposite(feature.PositiveY())) { feature.SetPositiveY(ADDON::DriverPrimitive()); bModified = true; } else if (primitive == feature.PositiveZ() || primitive == CPeripheralAddonTranslator::Opposite(feature.PositiveZ())) { feature.SetPositiveZ(ADDON::DriverPrimitive()); bModified = true; } if (bModified) { 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) { CLog::Log(LOGDEBUG, "Removing \"%s\" from button map due to conflict", feature.Name().c_str()); feature.SetType(JOYSTICK_FEATURE_TYPE_UNKNOWN); } } break; } default: break; } return bModified; }