xbmc
PeripheralBusAddon.h
1 /*
2  * Copyright (C) 2014-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "peripherals/PeripheralTypes.h"
12 #include "peripherals/bus/PeripheralBus.h"
13 
14 #include <memory>
15 #include <string>
16 #include <vector>
17 
18 namespace ADDON
19 {
20 struct AddonEvent;
21 class CAddonInfo;
22 } // namespace ADDON
23 
24 namespace PERIPHERALS
25 {
27 {
28 public:
29  explicit CPeripheralBusAddon(CPeripherals& manager);
30  ~CPeripheralBusAddon(void) override;
31 
32  void UpdateAddons(void);
33 
37  bool GetAddonWithButtonMap(PeripheralAddonPtr& addon) const;
38 
42  bool GetAddonWithButtonMap(const CPeripheral* device, PeripheralAddonPtr& addon) const;
43 
55  bool SendRumbleEvent(const std::string& strLocation, unsigned int motorIndex, float magnitude);
56 
57  // Inherited from CPeripheralBus
58  bool InitializeProperties(CPeripheral& peripheral) override;
59  void Register(const PeripheralPtr& peripheral) override;
60  void GetFeatures(std::vector<PeripheralFeature>& features) const override;
61  bool HasFeature(const PeripheralFeature feature) const override;
62  PeripheralPtr GetPeripheral(const std::string& strLocation) const override;
63  PeripheralPtr GetByPath(const std::string& strPath) const override;
64  bool SupportsFeature(PeripheralFeature feature) const override;
65  unsigned int GetPeripheralsWithFeature(PeripheralVector& results,
66  const PeripheralFeature feature) const override;
67  unsigned int GetNumberOfPeripherals(void) const override;
68  unsigned int GetNumberOfPeripheralsWithId(const int iVendorId,
69  const int iProductId) const override;
70  void GetDirectory(const std::string& strPath, CFileItemList& items) const override;
71  void ProcessEvents(void) override;
72  void EnableButtonMapping() override;
73  void PowerOff(const std::string& strLocation) override;
74 
75  bool SplitLocation(const std::string& strLocation,
76  PeripheralAddonPtr& addon,
77  unsigned int& peripheralIndex) const;
78 
79 protected:
80  // Inherited from CPeripheralBus
81  bool PerformDeviceScan(PeripheralScanResults& results) override;
82  void UnregisterRemovedDevices(const PeripheralScanResults& results) override;
83 
84 private:
85  void OnEvent(const ADDON::AddonEvent& event);
86  void UnRegisterAddon(const std::string& addonId);
87 
88  void PromptEnableAddons(const std::vector<std::shared_ptr<ADDON::CAddonInfo>>& disabledAddons);
89 
90  PeripheralAddonVector m_addons;
91  PeripheralAddonVector m_failedAddons;
92 };
93 using PeripheralBusAddonPtr = std::shared_ptr<CPeripheralBusAddon>;
94 } // namespace PERIPHERALS
Definition: PeripheralTypes.h:348
Definition: RetroPlayerInput.h:15
Definition: PeripheralBusAddon.h:26
Represents a list of files.
Definition: FileItem.h:713
Definition: AddonEvents.h:18
Definition: PeripheralBus.h:34
Definition: Addon.cpp:39
Definition: Peripheral.h:62
Definition: GUIWindowAddonBrowser.cpp:163
Definition: Peripherals.h:49