Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
PERIPHERALS::CPeripheralBusUSB Class Reference

#include <PeripheralBusUSB.h>

Inheritance diagram for PERIPHERALS::CPeripheralBusUSB:
PERIPHERALS::CPeripheralBus PERIPHERALS::CPeripheralBus PERIPHERALS::CPeripheralBus PERIPHERALS::CPeripheralBus PERIPHERALS::CPeripheralBus CThread CThread CThread CThread CThread

Public Member Functions

 CPeripheralBusUSB (CPeripherals &manager)
 
 ~CPeripheralBusUSB () override
 
bool PerformDeviceScan (PeripheralScanResults &results) override
 
 CPeripheralBusUSB (CPeripherals &manager)
 
 ~CPeripheralBusUSB (void) override
 
void Clear (void) override
 Stop the polling thread and clear all known devices on this bus.
 
bool PerformDeviceScan (PeripheralScanResults &results) override
 
 CPeripheralBusUSB (CPeripherals &manager)
 
bool PerformDeviceScan (PeripheralScanResults &results)
 
 CPeripheralBusUSB (CPeripherals &manager)
 
bool PerformDeviceScan (PeripheralScanResults &results)
 
 CPeripheralBusUSB (CPeripherals &manager)
 
bool PerformDeviceScan (PeripheralScanResults &results)
 
- Public Member Functions inherited from PERIPHERALS::CPeripheralBus
 CPeripheralBus (const std::string &threadname, CPeripherals &manager, PeripheralBusType type)
 
 ~CPeripheralBus (void) override
 
PeripheralBusType Type (void) const
 
bool NeedsPolling (void) const
 
virtual bool InitializeProperties (CPeripheral &peripheral)
 Initialize the properties of a peripheral with a known location.
 
virtual PeripheralPtr GetPeripheral (const std::string &strLocation) const
 Get the instance of the peripheral at the given location.
 
virtual bool HasPeripheral (const std::string &strLocation) const
 Check whether a peripheral is present at the given location.
 
virtual bool SupportsFeature (PeripheralFeature feature) const
 Check if the bus supports the given feature.
 
virtual unsigned int GetPeripheralsWithFeature (PeripheralVector &results, const PeripheralFeature feature) const
 Get all peripheral instances that have the given feature.
 
virtual unsigned int GetNumberOfPeripherals () const
 
virtual unsigned int GetNumberOfPeripheralsWithId (const int iVendorId, const int iProductId) const
 
virtual void GetFeatures (std::vector< PeripheralFeature > &features) const
 Get all features that are supported by devices on this bus.
 
virtual bool HasFeature (const PeripheralFeature feature) const
 Check whether there is at least one device present with the given feature.
 
virtual void OnDeviceAdded (const std::string &strLocation)
 Callback method for when a device has been added. Will perform a device scan.
 
virtual void OnDeviceChanged (const std::string &strLocation)
 Callback method for when a device has been changed. Will perform a device scan.
 
virtual void OnDeviceRemoved (const std::string &strLocation)
 Callback method for when a device has been removed. Will perform a device scan.
 
virtual void Initialise (void)
 Initialise this bus and start a polling thread if this bus needs polling.
 
virtual void TriggerDeviceScan (void)
 Scan for devices.
 
virtual void GetDirectory (const std::string &strPath, CFileItemList &items) const
 Get all fileitems for a path.
 
virtual PeripheralPtr GetByPath (const std::string &strPath) const
 Get the instance of a peripheral given it's path.
 
virtual void Register (const PeripheralPtr &peripheral)
 Register a new peripheral on this bus.
 
virtual bool FindComPort (std::string &strLocation)
 
virtual void ProcessEvents (void)
 Poll for events.
 
virtual void EnableButtonMapping ()
 Initialize button mapping.
 
virtual void PowerOff (const std::string &strLocation)
 Power off the specified device.
 

Protected Member Functions

void Process (void) override
 
bool WaitForUpdate (void)
 
- Protected Member Functions inherited from PERIPHERALS::CPeripheralBus
virtual bool ScanForDevices (void)
 
virtual void UnregisterRemovedDevices (const PeripheralScanResults &results)
 
virtual void RegisterNewDevices (const PeripheralScanResults &results)
 
- Protected Member Functions inherited from CThread
 CThread (const char *ThreadName)
 
virtual void OnStartup ()
 
virtual void OnExit ()
 
WaitResponse AbortableWait (CEvent &event, std::chrono::milliseconds duration=std::chrono::milliseconds(-1))
 
 CThread (IRunnable *pRunnable, const char *ThreadName)
 
virtual ~CThread ()
 
void Create (bool bAutoDelete=false)
 
template<typename Rep , typename Period >
void Sleep (std::chrono::duration< Rep, Period > duration)
 
bool IsAutoDelete () const
 
virtual void StopThread (bool bWait=true)
 
bool IsRunning () const
 
bool IsCurrentThread () const
 
bool Join (std::chrono::milliseconds duration)
 
bool SetPriority (const ThreadPriority &priority)
 Set the threads priority. This uses the platforms native threading library to do so.
 
virtual void OnException ()
 

Static Protected Member Functions

static PeripheralType GetType (int iDeviceClass)
 
static void DeviceDetachCallback (void *refCon, io_service_t service, natural_t messageType, void *messageArgument)
 
static void DeviceAttachCallback (CPeripheralBusUSB *refCon, io_iterator_t iterator)
 
static PeripheralType GetType (int iDeviceClass)
 
static const PeripheralType GetType (int iDeviceClass)
 
- Static Protected Member Functions inherited from CThread
static const std::thread::id GetCurrentThreadId ()
 
static CThreadGetCurrentThread ()
 

Protected Attributes

PeripheralScanResults m_scan_results
 
IONotificationPortRef m_notify_port
 
io_iterator_t m_attach_iterator
 
struct udev * m_udev
 
struct udev_monitor * m_udevMon
 
struct usb_bus * m_busses
 
- Protected Attributes inherited from PERIPHERALS::CPeripheralBus
PeripheralVector m_peripherals
 
std::chrono::milliseconds m_iRescanTime
 
bool m_bNeedsPolling
 
CPeripheralsm_manager
 
const PeripheralBusType m_type
 
CCriticalSection m_critSection
 
CEvent m_triggerEvent
 
- Protected Attributes inherited from CThread
std::atomic< boolm_bStop
 

Additional Inherited Members

- Protected Types inherited from CThread
enum  WaitResponse { WAIT_INTERRUPTED = -1 , WAIT_SIGNALED = 0 , WAIT_TIMEDOUT = 1 }
 

Constructor & Destructor Documentation

◆ CPeripheralBusUSB() [1/5]

CPeripheralBusUSB::CPeripheralBusUSB ( CPeripherals & manager)
explicit

◆ ~CPeripheralBusUSB() [1/2]

CPeripheralBusUSB::~CPeripheralBusUSB ( void )
override

◆ CPeripheralBusUSB() [2/5]

PERIPHERALS::CPeripheralBusUSB::CPeripheralBusUSB ( CPeripherals & manager)
explicit

◆ ~CPeripheralBusUSB() [2/2]

PERIPHERALS::CPeripheralBusUSB::~CPeripheralBusUSB ( void )
override

◆ CPeripheralBusUSB() [3/5]

PERIPHERALS::CPeripheralBusUSB::CPeripheralBusUSB ( CPeripherals & manager)
explicit

◆ CPeripheralBusUSB() [4/5]

PERIPHERALS::CPeripheralBusUSB::CPeripheralBusUSB ( CPeripherals & manager)

◆ CPeripheralBusUSB() [5/5]

PERIPHERALS::CPeripheralBusUSB::CPeripheralBusUSB ( CPeripherals & manager)
explicit

Member Function Documentation

◆ Clear()

void CPeripheralBusUSB::Clear ( void )
overridevirtual

Stop the polling thread and clear all known devices on this bus.

Reimplemented from PERIPHERALS::CPeripheralBus.

◆ DeviceAttachCallback()

void CPeripheralBusUSB::DeviceAttachCallback ( CPeripheralBusUSB * refCon,
io_iterator_t iterator )
staticprotected

◆ DeviceDetachCallback()

void CPeripheralBusUSB::DeviceDetachCallback ( void * refCon,
io_service_t service,
natural_t messageType,
void * messageArgument )
staticprotected

◆ GetType() [1/3]

const PeripheralType CPeripheralBusUSB::GetType ( int iDeviceClass)
staticprotected

◆ GetType() [2/3]

static PeripheralType PERIPHERALS::CPeripheralBusUSB::GetType ( int iDeviceClass)
staticprotected

◆ GetType() [3/3]

static const PeripheralType PERIPHERALS::CPeripheralBusUSB::GetType ( int iDeviceClass)
staticprotected

◆ PerformDeviceScan() [1/5]

bool PERIPHERALS::CPeripheralBusUSB::PerformDeviceScan ( PeripheralScanResults & results)
virtual
See also
PeripheralBus::PerformDeviceScan()

Implements PERIPHERALS::CPeripheralBus.

◆ PerformDeviceScan() [2/5]

bool PERIPHERALS::CPeripheralBusUSB::PerformDeviceScan ( PeripheralScanResults & results)
virtual
See also
PeripheralBus::PerformDeviceScan()

Implements PERIPHERALS::CPeripheralBus.

◆ PerformDeviceScan() [3/5]

bool PERIPHERALS::CPeripheralBusUSB::PerformDeviceScan ( PeripheralScanResults & results)
virtual
See also
PeripheralBus::PerformDeviceScan()

Implements PERIPHERALS::CPeripheralBus.

◆ PerformDeviceScan() [4/5]

bool CPeripheralBusUSB::PerformDeviceScan ( PeripheralScanResults & results)
overridevirtual
See also
PeripheralBus::PerformDeviceScan()
Todo
just assume this is a HID device for now, since the only devices that we're currently interested in are HID devices

Implements PERIPHERALS::CPeripheralBus.

◆ PerformDeviceScan() [5/5]

bool PERIPHERALS::CPeripheralBusUSB::PerformDeviceScan ( PeripheralScanResults & results)
overridevirtual
See also
PeripheralBus::PerformDeviceScan()

Implements PERIPHERALS::CPeripheralBus.

◆ Process()

void CPeripheralBusUSB::Process ( void )
overrideprotectedvirtual

Reimplemented from PERIPHERALS::CPeripheralBus.

◆ WaitForUpdate()

bool CPeripheralBusUSB::WaitForUpdate ( void )
protected

Member Data Documentation

◆ m_attach_iterator

io_iterator_t PERIPHERALS::CPeripheralBusUSB::m_attach_iterator
protected

◆ m_busses

struct usb_bus* PERIPHERALS::CPeripheralBusUSB::m_busses
protected

◆ m_notify_port

IONotificationPortRef PERIPHERALS::CPeripheralBusUSB::m_notify_port
protected

◆ m_scan_results

PeripheralScanResults PERIPHERALS::CPeripheralBusUSB::m_scan_results
protected

◆ m_udev

struct udev* PERIPHERALS::CPeripheralBusUSB::m_udev
protected

◆ m_udevMon

struct udev_monitor* PERIPHERALS::CPeripheralBusUSB::m_udevMon
protected

The documentation for this class was generated from the following files: