Beispiel #1
0
PeripheralAddonPtr CPeripherals::GetAddon(const CPeripheral* device)
{
  PeripheralAddonPtr addon;

  PeripheralBusAddonPtr addonBus = std::static_pointer_cast<CPeripheralBusAddon>(GetBusByType(PERIPHERAL_BUS_ADDON));
  if (device && addonBus)
  {
    PeripheralBusType busType = device->GetBusType();

    if (busType == PERIPHERAL_BUS_ADDON)
    {
      // If device is from an add-on, use that add-on
      unsigned int index;
      addonBus->SplitLocation(device->Location(), addon, index);
    }
    else
    {
      // Otherwise, have the add-on bus find a suitable add-on
      addonBus->GetAddonWithButtonMap(device, addon);
    }
  }

  return addon;
}