Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
|
#include <Peripherals.h>
Public Member Functions | |
CPeripherals (CInputManager &inputManager, KODI::GAME::CControllerManager &controllerProfiles) | |
~CPeripherals () override | |
void | Initialise () |
Initialise the peripherals manager. | |
void | Clear () |
Clear all data known by the peripherals manager. | |
PeripheralPtr | GetPeripheralAtLocation (const std::string &strLocation, PeripheralBusType busType=PERIPHERAL_BUS_UNKNOWN) const |
Get the instance of the peripheral at the given location. | |
bool | HasPeripheralAtLocation (const std::string &strLocation, PeripheralBusType busType=PERIPHERAL_BUS_UNKNOWN) const |
Check whether a peripheral is present at the given location. | |
PeripheralBusPtr | GetBusWithDevice (const std::string &strLocation) const |
Get the bus that holds the device with the given location. | |
bool | SupportsFeature (PeripheralFeature feature) const |
Check if any busses support the given feature. | |
int | GetPeripheralsWithFeature (PeripheralVector &results, const PeripheralFeature feature, PeripheralBusType busType=PERIPHERAL_BUS_UNKNOWN) const |
Get all peripheral instances that have the given feature. | |
size_t | GetNumberOfPeripherals () const |
bool | HasPeripheralWithFeature (const PeripheralFeature feature, PeripheralBusType busType=PERIPHERAL_BUS_UNKNOWN) const |
Check whether there is at least one device present with the given feature. | |
void | OnDeviceAdded (const CPeripheralBus &bus, const CPeripheral &peripheral) |
Called when a device has been added to a bus. | |
void | OnDeviceDeleted (const CPeripheralBus &bus, const CPeripheral &peripheral) |
Called when a device has been deleted from a bus. | |
void | CreatePeripheral (CPeripheralBus &bus, const PeripheralScanResult &result) |
Creates a new instance of a peripheral. | |
void | GetSettingsFromMapping (CPeripheral &peripheral) const |
Add the settings that are defined in the mappings file to the peripheral (if there is anything defined). | |
void | TriggerDeviceScan (const PeripheralBusType type=PERIPHERAL_BUS_UNKNOWN) |
Trigger a device scan on all known busses. | |
PeripheralBusPtr | GetBusByType (const PeripheralBusType type) const |
Get the instance of a bus given it's type. | |
void | GetDirectory (const std::string &strPath, CFileItemList &items) const |
Get all fileitems for a path. | |
PeripheralPtr | GetByPath (const std::string &strPath) const |
Get the instance of a peripheral given it's path. | |
bool | OnAction (const CAction &action) |
Try to let one of the peripherals handle an action. | |
bool | IsMuted () |
Check whether there's a peripheral that reports to be muted. | |
bool | ToggleMute () |
Try to toggle the mute status via a peripheral. | |
bool | ToggleDeviceState (const CecStateChange mode=STATE_SWITCH_TOGGLE) |
Try to toggle the playing device state via a peripheral. | |
bool | Mute () |
Try to mute the audio via a peripheral. | |
bool | UnMute () |
Try to unmute the audio via a peripheral. | |
bool | GetNextKeypress (float frameTime, CKey &key) |
Try to get a keypress from a peripheral. | |
EventPollHandlePtr | RegisterEventPoller () |
Register with the event scanner to control scan timing. | |
EventLockHandlePtr | RegisterEventLock () |
Register with the event scanner to disable event processing. | |
void | OnUserNotification () |
void | TestFeature (PeripheralFeature feature) |
Request peripherals with the specified feature to perform a quick test. | |
void | PowerOffDevices () |
Request all devices with power-off support to power down. | |
bool | SupportsCEC () const |
void | ProcessEvents (void) override |
void | EnableButtonMapping () |
Initialize button mapping. | |
PeripheralAddonPtr | GetAddonWithButtonMap (const CPeripheral *device) |
Get an add-on that can provide button maps for a device. | |
void | ResetButtonMaps (const std::string &controllerId) |
Reset all button maps to the defaults for all devices and the given controller. | |
void | RegisterJoystickButtonMapper (KODI::JOYSTICK::IButtonMapper *mapper) |
Register a button mapper interface. | |
void | UnregisterJoystickButtonMapper (KODI::JOYSTICK::IButtonMapper *mapper) |
Unregister a button mapper interface. | |
void | OnSettingChanged (const std::shared_ptr< const CSetting > &setting) override |
The value of the given setting has changed. | |
void | OnSettingAction (const std::shared_ptr< const CSetting > &setting) override |
The given setting has been activated. | |
void | OnApplicationMessage (KODI::MESSAGING::ThreadMessage *pMsg) override |
This gets called whenever a message matching the registered message mask is processed. | |
int | GetMessageMask () override |
Should return the message mask that it wishes to receive messages for. | |
void | Announce (ANNOUNCEMENT::AnnouncementFlag flag, const std::string &sender, const std::string &message, const CVariant &data) override |
CInputManager & | GetInputManager () |
Access the input manager passed to the constructor. | |
KODI::GAME::CControllerManager & | GetControllerProfiles () |
Access controller profiles through the construction parameter. | |
CCriticalSection & | GetAddonInstallMutex () |
Get a mutex that allows for add-on install tasks to block on each other. | |
Public Member Functions inherited from ISettingCallback | |
virtual | ~ISettingCallback ()=default |
virtual bool | OnSettingChanging (const std::shared_ptr< const CSetting > &setting) |
The value of the given setting is being changed. | |
virtual bool | OnSettingUpdate (const std::shared_ptr< CSetting > &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) |
The given setting needs to be updated. | |
virtual void | OnSettingPropertyChanged (const std::shared_ptr< const CSetting > &setting, const char *propertyName) |
The given property of the given setting has changed. | |
Public Member Functions inherited from Observable | |
Observable ()=default | |
virtual | ~Observable ()=default |
Observable & | operator= (const Observable &observable) |
virtual void | RegisterObserver (Observer *obs) |
Register an observer. | |
virtual void | UnregisterObserver (Observer *obs) |
Unregister an observer. | |
virtual void | NotifyObservers (const ObservableMessage message=ObservableMessageNone) |
Send a message to all observers when m_bObservableChanged is true. | |
virtual void | SetChanged (bool bSetTo=true) |
Mark an observable changed. | |
virtual bool | IsObserving (const Observer &obs) const |
Check whether this observable is being observed by an observer. | |
Public Member Functions inherited from PERIPHERALS::IEventScannerCallback | |
virtual | ~IEventScannerCallback (void)=default |
Public Member Functions inherited from ANNOUNCEMENT::IAnnouncer | |
IAnnouncer ()=default | |
virtual | ~IAnnouncer ()=default |
Additional Inherited Members | |
Protected Member Functions inherited from Observable | |
void | SendMessage (const ObservableMessage message) |
Send a message to all observer when m_bObservableChanged is true. | |
Protected Attributes inherited from Observable | |
std::atomic< bool > | m_bObservableChanged {false} |
std::vector< Observer * > | m_observers |
CCriticalSection | m_obsCritSection |
|
explicit |
|
override |
|
overridevirtual |
Implements ANNOUNCEMENT::IAnnouncer.
void CPeripherals::Clear | ( | ) |
Clear all data known by the peripherals manager.
void CPeripherals::CreatePeripheral | ( | CPeripheralBus & | bus, |
const PeripheralScanResult & | result ) |
Creates a new instance of a peripheral.
bus | The bus on which this peripheral is present. |
result | The scan result from the device scanning code. |
void CPeripherals::EnableButtonMapping | ( | ) |
Initialize button mapping.
This command enables button mapping on all busses. Button maps allow connect events from the driver to the higher-level features used by controller profiles.
If user input is required, a blocking dialog may be shown.
|
inline |
Get a mutex that allows for add-on install tasks to block on each other.
PeripheralAddonPtr CPeripherals::GetAddonWithButtonMap | ( | const CPeripheral * | device | ) |
Get an add-on that can provide button maps for a device.
PeripheralBusPtr CPeripherals::GetBusByType | ( | const PeripheralBusType | type | ) | const |
Get the instance of a bus given it's type.
type | The bus type. |
PeripheralBusPtr CPeripherals::GetBusWithDevice | ( | const std::string & | strLocation | ) | const |
Get the bus that holds the device with the given location.
strLocation | The location. |
PeripheralPtr CPeripherals::GetByPath | ( | const std::string & | strPath | ) | const |
Get the instance of a peripheral given it's path.
strPath | The path to the peripheral. |
|
inline |
Access controller profiles through the construction parameter.
void CPeripherals::GetDirectory | ( | const std::string & | strPath, |
CFileItemList & | items ) const |
Get all fileitems for a path.
strPath | The path to the directory to get the items from. |
items | The item list. |
|
inline |
Access the input manager passed to the constructor.
|
overridevirtual |
Should return the message mask that it wishes to receive messages for.
The message mask is defined in "messaging/ApplicationMessenger.h" pick the next one available when creating a new
Implements KODI::MESSAGING::IMessageTarget.
size_t CPeripherals::GetNumberOfPeripherals | ( | ) | const |
PeripheralPtr CPeripherals::GetPeripheralAtLocation | ( | const std::string & | strLocation, |
PeripheralBusType | busType = PERIPHERAL_BUS_UNKNOWN ) const |
Get the instance of the peripheral at the given location.
strLocation | The location. |
busType | The bus to query. Default (PERIPHERAL_BUS_UNKNOWN) searches all busses. |
int CPeripherals::GetPeripheralsWithFeature | ( | PeripheralVector & | results, |
const PeripheralFeature | feature, | ||
PeripheralBusType | busType = PERIPHERAL_BUS_UNKNOWN ) const |
Get all peripheral instances that have the given feature.
results | The list of results. |
feature | The feature to search for. |
busType | The bus to query. Default (PERIPHERAL_BUS_UNKNOWN) searches all busses. |
void CPeripherals::GetSettingsFromMapping | ( | CPeripheral & | peripheral | ) | const |
Add the settings that are defined in the mappings file to the peripheral (if there is anything defined).
peripheral | The peripheral to get the settings for. |
bool CPeripherals::HasPeripheralAtLocation | ( | const std::string & | strLocation, |
PeripheralBusType | busType = PERIPHERAL_BUS_UNKNOWN ) const |
Check whether a peripheral is present at the given location.
strLocation | The location. |
busType | The bus to query. Default (PERIPHERAL_BUS_UNKNOWN) searches all busses. |
bool CPeripherals::HasPeripheralWithFeature | ( | const PeripheralFeature | feature, |
PeripheralBusType | busType = PERIPHERAL_BUS_UNKNOWN ) const |
Check whether there is at least one device present with the given feature.
feature | The feature to check for. |
busType | The bus to query. Default (PERIPHERAL_BUS_UNKNOWN) searches all busses. |
void CPeripherals::Initialise | ( | ) |
Initialise the peripherals manager.
bool CPeripherals::IsMuted | ( | ) |
Check whether there's a peripheral that reports to be muted.
|
inline |
Try to mute the audio via a peripheral.
Try to let one of the peripherals handle an action.
action | The change to handle. |
|
overridevirtual |
This gets called whenever a message matching the registered message mask is processed.
There are no ordering guarantees here so implementations should never rely on a certain ordering of messages.
Cleaning up any pointers stored in the message payload is not specified and is decided by the implementer of the message. In general prefer to delete any data in this method to keep the callsites cleaner and simpler but if data is to be passed back it's perfectly valid to handle it any way that fits the situation as long as it's documented along with the message.
To return a simple value the result parameter of
Implements KODI::MESSAGING::IMessageTarget.
void CPeripherals::OnDeviceAdded | ( | const CPeripheralBus & | bus, |
const CPeripheral & | peripheral ) |
Called when a device has been added to a bus.
bus | The bus the device was added to. |
peripheral | The peripheral that has been added. |
void CPeripherals::OnDeviceDeleted | ( | const CPeripheralBus & | bus, |
const CPeripheral & | peripheral ) |
Called when a device has been deleted from a bus.
bus | The bus from which the device removed. |
peripheral | The peripheral that has been removed. |
|
overridevirtual |
The given setting has been activated.
This callback is triggered whenever the given setting has been activated. This callback is only fired for CSettingAction settings.
setting | The setting which has been activated. |
Reimplemented from ISettingCallback.
|
overridevirtual |
The value of the given setting has changed.
This callback is triggered whenever the value of a setting has been successfully changed (i.e. none of the OnSettingChanging() handlers) has reverted the change.
setting | The setting whose value has been changed |
Reimplemented from ISettingCallback.
void CPeripherals::OnUserNotification | ( | ) |
void CPeripherals::PowerOffDevices | ( | ) |
Request all devices with power-off support to power down.
Implements PERIPHERALS::IEventScannerCallback.
EventLockHandlePtr CPeripherals::RegisterEventLock | ( | ) |
Register with the event scanner to disable event processing.
EventPollHandlePtr CPeripherals::RegisterEventPoller | ( | ) |
Register with the event scanner to control scan timing.
void CPeripherals::RegisterJoystickButtonMapper | ( | KODI::JOYSTICK::IButtonMapper * | mapper | ) |
Register a button mapper interface.
mapper | The button mapper |
Clients implementing the IButtonMapper interface call CPeripherals::RegisterJoystickButtonMapper to register themselves as eligible for button mapping commands.
When registering the mapper is forwarded to all peripherals. See CPeripheral::RegisterJoystickButtonMapper for what is done to the mapper after being given to the peripheral.
void CPeripherals::ResetButtonMaps | ( | const std::string & | controllerId | ) |
Reset all button maps to the defaults for all devices and the given controller.
controllerId | The controller profile to reset |
|
inline |
bool CPeripherals::SupportsFeature | ( | PeripheralFeature | feature | ) | const |
Check if any busses support the given feature.
feature | The feature to check for |
void CPeripherals::TestFeature | ( | PeripheralFeature | feature | ) |
Request peripherals with the specified feature to perform a quick test.
bool CPeripherals::ToggleDeviceState | ( | const CecStateChange | mode = STATE_SWITCH_TOGGLE | ) |
Try to toggle the playing device state via a peripheral.
mode | Whether to activate, put on standby or toggle the source. |
bool CPeripherals::ToggleMute | ( | ) |
Try to toggle the mute status via a peripheral.
void CPeripherals::TriggerDeviceScan | ( | const PeripheralBusType | type = PERIPHERAL_BUS_UNKNOWN | ) |
Trigger a device scan on all known busses.
|
inline |
void CPeripherals::UnregisterJoystickButtonMapper | ( | KODI::JOYSTICK::IButtonMapper * | mapper | ) |
Unregister a button mapper interface.
mapper | The button mapper |