Kodi Development  20.0
for Binary and Script based Add-Ons

Detailed Description

Peripheral operations to handle control about.


Peripheral parts in interface:
Copy this to your project and extend with your parts or leave functions complete away where not used or supported.

Header parts:

PERIPHERAL_ERROR PerformDeviceScan(std::vector<std::shared_ptr<kodi::addon::Peripheral>>& scan_results) override;
PERIPHERAL_ERROR GetEvents(std::vector<kodi::addon::PeripheralEvent>& events) override;
bool SendEvent(const kodi::addon::PeripheralEvent& event) override;
Definition: PeripheralUtils.h:133
Definition: PeripheralUtils.h:369
PERIPHERAL_ERROR
Definition: peripheral.h:36
virtual bool SendEvent(const kodi::addon::PeripheralEvent &event)
Send an input event to the peripheral.
Definition: Peripheral.h:387
virtual PERIPHERAL_ERROR GetEvents(std::vector< kodi::addon::PeripheralEvent > &events)
Get all events that have occurred since the last call to GetEvents().
Definition: Peripheral.h:375
virtual void GetCapabilities(kodi::addon::PeripheralCapabilities &capabilities)
Get the list of features that this add-on provides.
Definition: Peripheral.h:339
virtual PERIPHERAL_ERROR PerformDeviceScan(std::vector< std::shared_ptr< kodi::addon::Peripheral >> &scan_results)
Perform a scan for joysticks.
Definition: Peripheral.h:357

Source parts:

void CMyInstance::GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities)
{
}
PERIPHERAL_ERROR CMyInstance::PerformDeviceScan(std::vector<std::shared_ptr<kodi::addon::Peripheral>>& scan_results)
{
}
PERIPHERAL_ERROR CMyInstance::GetEvents(std::vector<kodi::addon::PeripheralEvent>& events)
{
}
bool CMyInstance::SendEvent(const kodi::addon::PeripheralEvent& event)
{
return false;
}
@ PERIPHERAL_ERROR_NOT_IMPLEMENTED
-4 : The method that the frontend called is not implemented
Definition: peripheral.h:50

Modules

 Group header include
 
 Group source include
 

Function Documentation

◆ GetCapabilities()

virtual void GetCapabilities ( kodi::addon::PeripheralCapabilities capabilities)
inlinevirtual

Get the list of features that this add-on provides.

Called by the frontend to query the add-on's capabilities and supported peripherals. All capabilities that the add-on supports should be set to true.

Parameters
[out]capabilitiesThe add-on's capabilities
Remarks
Valid implementation required.

The following table contains values that can be set with class PeripheralCapabilities :

Name Type Set call Get call
Provides joysticks boolean SetProvidesJoysticks GetProvidesJoysticks
Provides joystick rumble boolean SetProvidesJoystickRumble GetProvidesJoystickRumble
Provides joystick power off boolean SetProvidesJoystickPowerOff GetProvidesJoystickPowerOff
Provides button maps boolean SetProvidesButtonmaps GetProvidesButtonmaps

Example:

void CMyPeripheralAddon::GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities)
{
capabilities.SetProvidesJoysticks(true);
capabilities.SetProvidesButtonmaps(true);
}
void SetProvidesButtonmaps(bool providesButtonmaps)
Set true if the add-on provides button maps.
Definition: PeripheralUtils.h:194
void SetProvidesJoysticks(bool providesJoysticks)
Set true if the add-on provides joysticks.
Definition: PeripheralUtils.h:167

◆ PerformDeviceScan()

virtual PERIPHERAL_ERROR PerformDeviceScan ( std::vector< std::shared_ptr< kodi::addon::Peripheral >> &  scan_results)
inlinevirtual

Perform a scan for joysticks.

The frontend calls this when a hardware change is detected. If an add-on detects a hardware change, it can trigger this function using the TriggerScan() callback.

Parameters
[in]scan_resultsAssigned to allocated memory
Returns
PERIPHERAL_NO_ERROR if successful

The following table contains values that can be set with class Peripheral :

Name Type Set call Get call
Peripheral type PERIPHERAL_TYPE SetType Type
Peripheral name const std::string& SetName Name
Peripheral vendor id uint16_t SetVendorID VendorID
Peripheral product id uint16_t SetProductID ProductID
Peripheral index unsigned int SetIndex Index

Further are following included:

◆ GetEvents()

virtual PERIPHERAL_ERROR GetEvents ( std::vector< kodi::addon::PeripheralEvent > &  events)
inlinevirtual

Get all events that have occurred since the last call to GetEvents().

Parameters
[out]eventsList of available events within addon
Returns
PERIPHERAL_NO_ERROR if successful

The following table contains values that can be set with class PeripheralEvent :

Name Type Set call Get call
Peripheral event type PERIPHERAL_EVENT_TYPE SetType Type
Peripheral index unsigned int SetPeripheralIndex PeripheralIndex
Peripheral event driver index unsigned int SetDriverIndex DriverIndex
Peripheral event button state JOYSTICK_STATE_BUTTON SetButtonState ButtonState
Peripheral event hat state JOYSTICK_STATE_HAT SetHatState HatState
Peripheral event axis state JOYSTICK_STATE_AXIS (float) SetAxisState AxisState
Peripheral event motor state JOYSTICK_STATE_MOTOR (float) SetMotorState MotorState

Further are several class constructors with values included.

◆ SendEvent()

virtual bool SendEvent ( const kodi::addon::PeripheralEvent event)
inlinevirtual

Send an input event to the peripheral.

Parameters
[in]eventThe input event
Returns
true if the event was handled, false otherwise