kodi
PeripheralBusAddon.h
1 /*
2  * Copyright (C) 2014-2024 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 {
30 {
31 public:
32  explicit CPeripheralBusAddon(CPeripherals& manager);
33  ~CPeripheralBusAddon(void) override;
34 
35  void UpdateAddons(void);
36 
40  bool GetAddonWithButtonMap(PeripheralAddonPtr& addon) const;
41 
45  bool GetAddonWithButtonMap(const CPeripheral* device, PeripheralAddonPtr& addon) const;
46 
58  bool SendRumbleEvent(const std::string& strLocation, unsigned int motorIndex, float magnitude);
59 
60  // Inherited from CPeripheralBus
61  bool InitializeProperties(CPeripheral& peripheral) override;
62  void Register(const PeripheralPtr& peripheral) override;
63  void GetFeatures(std::vector<PeripheralFeature>& features) const override;
64  bool HasFeature(const PeripheralFeature feature) const override;
65  PeripheralPtr GetPeripheral(const std::string& strLocation) const override;
66  PeripheralPtr GetByPath(const std::string& strPath) const override;
67  bool SupportsFeature(PeripheralFeature feature) const override;
68  unsigned int GetPeripheralsWithFeature(PeripheralVector& results,
69  const PeripheralFeature feature) const override;
70  unsigned int GetNumberOfPeripherals(void) const override;
71  unsigned int GetNumberOfPeripheralsWithId(const int iVendorId,
72  const int iProductId) const override;
73  void GetDirectory(const std::string& strPath, CFileItemList& items) const override;
74  void ProcessEvents(void) override;
75  void EnableButtonMapping() override;
76  void PowerOff(const std::string& strLocation) override;
77 
78  bool SplitLocation(const std::string& strLocation,
79  PeripheralAddonPtr& addon,
80  unsigned int& peripheralIndex) const;
81 
82 protected:
83  // Inherited from CPeripheralBus
84  bool PerformDeviceScan(PeripheralScanResults& results) override;
85  void UnregisterRemovedDevices(const PeripheralScanResults& results) override;
86 
87 private:
88  void OnEvent(const ADDON::AddonEvent& event);
89  void UnRegisterAddon(const std::string& addonId);
90 
91  void PromptEnableAddons(const std::vector<std::shared_ptr<ADDON::CAddonInfo>>& disabledAddons);
92 
93  PeripheralAddonVector m_addons;
94  PeripheralAddonVector m_failedAddons;
95 };
96 using PeripheralBusAddonPtr = std::shared_ptr<CPeripheralBusAddon>;
97 } // namespace PERIPHERALS
Definition: PeripheralTypes.h:356
Definition: RetroPlayerInput.h:15
Definition: PeripheralBusAddon.h:29
Represents a list of files.
Definition: FileItem.h:702
Definition: AddonEvents.h:18
Definition: PeripheralBus.h:36
Definition: Addon.cpp:39
Definition: Peripheral.h:71
Definition: GUIWindowAddonBrowser.cpp:163
Definition: Peripherals.h:56