xbmc
PeripheralBusGCController.h
1 /*
2  * Copyright (C) 2020 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 "addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h"
12 #include "peripherals/PeripheralTypes.h"
13 #include "peripherals/bus/PeripheralBus.h"
14 #include "threads/CriticalSection.h"
15 
16 #include <memory>
17 #include <string>
18 #include <utility>
19 #include <vector>
20 
22 
23 namespace PERIPHERALS
24 {
26 {
27 public:
28  explicit CPeripheralBusGCController(CPeripherals& manager);
29  ~CPeripheralBusGCController() override;
30 
31  // specialisation of CPeripheralBus
32  bool InitializeProperties(CPeripheral& peripheral) override;
33  void Initialise(void) override;
34  void ProcessEvents() override;
35 
36  bool PerformDeviceScan(PeripheralScanResults& results) override;
37  PeripheralScanResults GetInputDevices();
38 
39  void callOnDeviceAdded(const std::string& strLocation);
40  void callOnDeviceRemoved(const std::string& strLocation);
41 
42  void SetScanResults(const PeripheralScanResults& resScanResults);
43 
44  const std::string& getDeviceLocationPrefix()
45  {
46  // Initialize the static variable
47  static std::string DeviceLocationPrefix("darwin/inputdevice/");
48  return DeviceLocationPrefix;
49  }
50 
51 
52 private:
53  void GetEvents(std::vector<kodi::addon::PeripheralEvent>& events);
54  std::unique_ptr<PeripheralBusGCControllerWrapper> m_peripheralGCController;
55  std::string GetDeviceLocation(int deviceId);
56  bool GetDeviceId(const std::string& deviceLocation, int& deviceId);
57 
58  PeripheralScanResults m_scanResults;
59  CCriticalSection m_critSectionStates;
60  CCriticalSection m_critSectionResults;
61 };
62 } // namespace PERIPHERALS
Definition: PeripheralTypes.h:348
Definition: PeripheralBusGCController.h:25
Definition: RetroPlayerInput.h:15
bool PerformDeviceScan(PeripheralScanResults &results) override
Scan for devices on this bus and add them to the results list. This will have to be implemented for e...
Definition: PeripheralBusGCController.mm:116
void ProcessEvents() override
Poll for events.
Definition: PeripheralBusGCController.mm:162
Definition: PeripheralBusGCController.mm:25
void Initialise(void) override
Initialise this bus and start a polling thread if this bus needs polling.
Definition: PeripheralBusGCController.mm:110
Definition: PeripheralBus.h:34
Definition: Peripheral.h:62
bool InitializeProperties(CPeripheral &peripheral) override
Initialize the properties of a peripheral with a known location.
Definition: PeripheralBusGCController.mm:46
Definition: Peripherals.h:49