aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/resource.language.en_gb/resources/strings.po14
-rwxr-xr-xsystem/settings/settings.xml7
-rw-r--r--xbmc/addons/BinaryAddonCache.cpp28
-rw-r--r--xbmc/addons/BinaryAddonCache.h2
-rw-r--r--xbmc/peripherals/Peripherals.cpp14
-rw-r--r--xbmc/peripherals/bus/virtual/PeripheralBusAddon.cpp64
-rw-r--r--xbmc/peripherals/bus/virtual/PeripheralBusAddon.h3
-rw-r--r--xbmc/settings/SettingConditions.cpp14
-rw-r--r--xbmc/settings/Settings.cpp2
-rw-r--r--xbmc/settings/Settings.h1
10 files changed, 119 insertions, 30 deletions
diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po
index 5c4b0b8f1d..0d850b4188 100644
--- a/addons/resource.language.en_gb/resources/strings.po
+++ b/addons/resource.language.en_gb/resources/strings.po
@@ -16513,7 +16513,19 @@ msgctxt "#35020"
msgid "Press all analog buttons now to detect them:[CR][CR]{0:s}"
msgstr ""
-#empty strings from id 35021 to 35048
+#empty strings from id 35022 to 35046
+
+#. Name of setting to configure peripheral add-ons
+#: system/settings/settings.xml
+msgctxt "#35047"
+msgid "Driver settings"
+msgstr ""
+
+#. Description of setting with label #35047 "Driver settings"
+#: system/settings/settings.xml
+msgctxt "#35048"
+msgid "View and configure peripheral add-ons."
+msgstr ""
#. Name of game add-ons category
#: xbmc/addons/Addon.cpp
diff --git a/system/settings/settings.xml b/system/settings/settings.xml
index 85f5d859c3..410e921e53 100755
--- a/system/settings/settings.xml
+++ b/system/settings/settings.xml
@@ -2676,6 +2676,13 @@
</dependencies>
<control type="button" format="action" />
</setting>
+ <setting id="input.peripherallibraries" type="action" label="35047" help="35048">
+ <level>1</level>
+ <dependencies>
+ <dependency type="enable" on="property" name="HasPeripheralLibraries" />
+ </dependencies>
+ <control type="button" format="action" />
+ </setting>
</group>
<group id="2" label="14094">
<setting id="input.enablemouse" type="boolean" label="21369" help="36377">
diff --git a/xbmc/addons/BinaryAddonCache.cpp b/xbmc/addons/BinaryAddonCache.cpp
index c926c9eff3..5563e8ba08 100644
--- a/xbmc/addons/BinaryAddonCache.cpp
+++ b/xbmc/addons/BinaryAddonCache.cpp
@@ -38,7 +38,8 @@ void CBinaryAddonCache::Init()
ADDON_INPUTSTREAM,
ADDON_PVRDLL,
ADDON_GAMEDLL,
- ADDON_VFS
+ ADDON_VFS,
+ ADDON_PERIPHERALDLL,
};
CAddonMgr::GetInstance().Events().Subscribe(this, &CBinaryAddonCache::OnEvent);
Update();
@@ -52,20 +53,35 @@ void CBinaryAddonCache::Deinit()
void CBinaryAddonCache::GetAddons(VECADDONS& addons, const TYPE& type)
{
VECADDONS myAddons;
+ GetInstalledAddons(myAddons, type);
+
+ for (auto &addon : myAddons)
{
- CSingleLock lock(m_critSection);
- auto it = m_addons.find(type);
- if (it != m_addons.end())
- myAddons = it->second;
+ if (!CAddonMgr::GetInstance().IsAddonDisabled(addon->ID()))
+ addons.emplace_back(std::move(addon));
}
+}
+
+void CBinaryAddonCache::GetDisabledAddons(VECADDONS& addons, const TYPE& type)
+{
+ VECADDONS myAddons;
+ GetInstalledAddons(myAddons, type);
for (auto &addon : myAddons)
{
- if (!CAddonMgr::GetInstance().IsAddonDisabled(addon->ID()))
+ if (CAddonMgr::GetInstance().IsAddonDisabled(addon->ID()))
addons.emplace_back(std::move(addon));
}
}
+void CBinaryAddonCache::GetInstalledAddons(VECADDONS& addons, const TYPE& type)
+{
+ CSingleLock lock(m_critSection);
+ auto it = m_addons.find(type);
+ if (it != m_addons.end())
+ addons = it->second;
+}
+
AddonPtr CBinaryAddonCache::GetAddonInstance(const std::string& strId, TYPE type)
{
AddonPtr addon;
diff --git a/xbmc/addons/BinaryAddonCache.h b/xbmc/addons/BinaryAddonCache.h
index 739e757a43..057318e479 100644
--- a/xbmc/addons/BinaryAddonCache.h
+++ b/xbmc/addons/BinaryAddonCache.h
@@ -36,6 +36,8 @@ public:
void Init();
void Deinit();
void GetAddons(VECADDONS& addons, const TYPE& type);
+ void GetDisabledAddons(VECADDONS& addons, const TYPE& type);
+ void GetInstalledAddons(VECADDONS& addons, const TYPE& type);
AddonPtr GetAddonInstance(const std::string& strId, TYPE type);
protected:
diff --git a/xbmc/peripherals/Peripherals.cpp b/xbmc/peripherals/Peripherals.cpp
index 310c526fa6..cd51ec48b0 100644
--- a/xbmc/peripherals/Peripherals.cpp
+++ b/xbmc/peripherals/Peripherals.cpp
@@ -24,6 +24,9 @@
#include "addons/PeripheralAddon.h"
#include "addons/AddonButtonMap.h"
+#include "addons/AddonManager.h"
+#include "addons/GUIDialogAddonSettings.h"
+#include "addons/GUIWindowAddonBrowser.h"
#include "bus/PeripheralBus.h"
#include "bus/PeripheralBusUSB.h"
#if defined(TARGET_ANDROID)
@@ -980,6 +983,17 @@ void CPeripherals::OnSettingAction(const CSetting *setting)
g_windowManager.ActivateWindow(WINDOW_DIALOG_GAME_CONTROLLERS);
else if (settingId == CSettings::SETTING_INPUT_TESTRUMBLE)
TestFeature(FEATURE_RUMBLE);
+ else if (settingId == CSettings::SETTING_INPUT_PERIPHERALLIBRARIES)
+ {
+ std::string strAddonId;
+ CGUIWindowAddonBrowser::SelectAddonID(ADDON::ADDON_PERIPHERALDLL, strAddonId, false, true, true, false, true);
+ if (!strAddonId.empty())
+ {
+ ADDON::AddonPtr addon;
+ if (ADDON::CAddonMgr::GetInstance().GetAddon(strAddonId, addon))
+ CGUIDialogAddonSettings::ShowAndGetInput(addon);
+ }
+ }
}
void CPeripherals::OnApplicationMessage(MESSAGING::ThreadMessage* pMsg)
diff --git a/xbmc/peripherals/bus/virtual/PeripheralBusAddon.cpp b/xbmc/peripherals/bus/virtual/PeripheralBusAddon.cpp
index 6cac561d5c..1d4b072bf5 100644
--- a/xbmc/peripherals/bus/virtual/PeripheralBusAddon.cpp
+++ b/xbmc/peripherals/bus/virtual/PeripheralBusAddon.cpp
@@ -21,12 +21,14 @@
#include "PeripheralBusAddon.h"
#include "addons/Addon.h"
#include "addons/AddonManager.h"
+#include "addons/BinaryAddonCache.h"
#include "messaging/helpers/DialogHelper.h"
#include "peripherals/Peripherals.h"
#include "peripherals/addons/PeripheralAddon.h"
#include "peripherals/devices/PeripheralJoystick.h"
#include "threads/SingleLock.h"
#include "utils/log.h"
+#include "ServiceBroker.h"
#include <algorithm>
#include <memory>
@@ -144,7 +146,7 @@ bool CPeripheralBusAddon::PerformDeviceScan(PeripheralScanResults &results)
CSingleLock lock(m_critSection);
addons = m_addons;
}
-
+
for (const auto& addon : addons)
addon->PerformDeviceScan(results);
@@ -214,7 +216,9 @@ void CPeripheralBusAddon::EnableButtonMapping()
if (!GetAddonWithButtonMap(dummy))
{
VECADDONS disabledAddons;
- if (CAddonMgr::GetInstance().GetDisabledAddons(disabledAddons, ADDON_PERIPHERALDLL))
+ CBinaryAddonCache& addonCache = CServiceBroker::GetBinaryAddonCache();
+ addonCache.GetDisabledAddons(disabledAddons, ADDON_PERIPHERALDLL);
+ if (!disabledAddons.empty())
PromptEnableAddons(disabledAddons);
}
}
@@ -426,10 +430,7 @@ bool CPeripheralBusAddon::SplitLocation(const std::string& strLocation, Peripher
void CPeripheralBusAddon::UpdateAddons(void)
{
- using namespace ADDON;
-
auto GetPeripheralAddonID = [](const PeripheralAddonPtr& addon) { return addon->ID(); };
- auto GetAddonID = [](const AddonPtr& addon) { return addon->ID(); };
std::set<std::string> currentIds;
std::set<std::string> newIds;
@@ -438,9 +439,8 @@ void CPeripheralBusAddon::UpdateAddons(void)
std::set<std::string> removed;
// Get new add-ons
- VECADDONS newAddons;
- CAddonMgr::GetInstance().GetAddons(newAddons, ADDON_PERIPHERALDLL);
- std::transform(newAddons.begin(), newAddons.end(), std::inserter(newIds, newIds.end()), GetAddonID);
+ PeripheralAddonVector newAddons = GetEnabledAddons();
+ std::transform(newAddons.begin(), newAddons.end(), std::inserter(newIds, newIds.end()), GetPeripheralAddonID);
CSingleLock lock(m_critSection);
@@ -457,26 +457,23 @@ void CPeripheralBusAddon::UpdateAddons(void)
{
CLog::Log(LOGDEBUG, "Add-on bus: Registering add-on %s", addonId.c_str());
- auto GetAddon = [addonId](const AddonPtr& addon) { return addon->ID() == addonId; };
+ auto GetAddon = [&addonId](const PeripheralAddonPtr& addon) { return addon->ID() == addonId; };
- VECADDONS::iterator it = std::find_if(newAddons.begin(), newAddons.end(), GetAddon);
+ PeripheralAddonVector::iterator it = std::find_if(newAddons.begin(), newAddons.end(), GetAddon);
if (it != newAddons.end())
{
- PeripheralAddonPtr newAddon = std::dynamic_pointer_cast<CPeripheralAddon>(*it);
- if (newAddon)
- {
- bool bCreated;
+ PeripheralAddonPtr& newAddon = *it;
- {
- CSingleExit exit(m_critSection);
- bCreated = (newAddon->CreateAddon() == ADDON_STATUS_OK);
- }
-
- if (bCreated)
- m_addons.push_back(newAddon);
- else
- m_failedAddons.push_back(newAddon);
+ bool bCreated;
+ {
+ CSingleExit exit(m_critSection);
+ bCreated = (newAddon->CreateAddon() == ADDON_STATUS_OK);
}
+
+ if (bCreated)
+ m_addons.emplace_back(std::move(newAddon));
+ else
+ m_failedAddons.emplace_back(std::move(newAddon));
}
}
@@ -538,3 +535,24 @@ void CPeripheralBusAddon::PromptEnableAddons(const ADDON::VECADDONS& disabledAdd
}
}
}
+
+PeripheralAddonVector CPeripheralBusAddon::GetEnabledAddons()
+{
+ using namespace ADDON;
+
+ PeripheralAddonVector result;
+
+ // Get enabled add-ons
+ VECADDONS tempAddons;
+ CBinaryAddonCache& addonCache = CServiceBroker::GetBinaryAddonCache();
+ addonCache.GetAddons(tempAddons, ADDON_PERIPHERALDLL);
+
+ // Downcast pointers
+ for (const auto& addon : tempAddons)
+ {
+ PeripheralAddonPtr peripheralAddon = std::static_pointer_cast<CPeripheralAddon>(addon);
+ result.emplace_back(std::move(peripheralAddon));
+ }
+
+ return result;
+}
diff --git a/xbmc/peripherals/bus/virtual/PeripheralBusAddon.h b/xbmc/peripherals/bus/virtual/PeripheralBusAddon.h
index 9d8740133e..deac46fef4 100644
--- a/xbmc/peripherals/bus/virtual/PeripheralBusAddon.h
+++ b/xbmc/peripherals/bus/virtual/PeripheralBusAddon.h
@@ -102,6 +102,9 @@ namespace PERIPHERALS
void PromptEnableAddons(const ADDON::VECADDONS& disabledAddons);
+ // Helper function
+ static PeripheralAddonVector GetEnabledAddons();
+
PeripheralAddonVector m_addons;
PeripheralAddonVector m_failedAddons;
CCriticalSection m_critSection;
diff --git a/xbmc/settings/SettingConditions.cpp b/xbmc/settings/SettingConditions.cpp
index b5022ccece..89922bb764 100644
--- a/xbmc/settings/SettingConditions.cpp
+++ b/xbmc/settings/SettingConditions.cpp
@@ -24,6 +24,7 @@
#include "GUIPassword.h"
#include "Util.h"
#include "addons/AddonManager.h"
+#include "addons/BinaryAddonCache.h"
#include "addons/Skin.h"
#if defined(TARGET_ANDROID)
#include "platform/android/activity/AndroidFeatures.h"
@@ -83,6 +84,18 @@ bool HasPeripherals(const std::string &condition, const std::string &value, cons
return CServiceBroker::GetPeripherals().GetNumberOfPeripherals() > 0;
}
+bool HasPeripheralLibraries(const std::string &condition, const std::string &value, const CSetting *setting, void *data)
+{
+ using namespace ADDON;
+
+ VECADDONS peripheralAddons;
+
+ CBinaryAddonCache& addonCache = CServiceBroker::GetBinaryAddonCache();
+ addonCache.GetInstalledAddons(peripheralAddons, ADDON_PERIPHERALDLL);
+
+ return !peripheralAddons.empty();
+}
+
bool HasRumbleFeature(const std::string &condition, const std::string &value, const CSetting *setting, void *data)
{
return CServiceBroker::GetPeripherals().SupportsFeature(PERIPHERALS::FEATURE_RUMBLE);
@@ -355,6 +368,7 @@ void CSettingConditions::Initialize()
m_complexConditions.insert(std::pair<std::string, SettingConditionCheck>("checkmasterlock", CheckMasterLock));
m_complexConditions.insert(std::pair<std::string, SettingConditionCheck>("checkpvrparentalpin", CheckPVRParentalPin));
m_complexConditions.insert(std::pair<std::string, SettingConditionCheck>("hasperipherals", HasPeripherals));
+ m_complexConditions.insert(std::pair<std::string, SettingConditionCheck>("hasperipherallibraries", HasPeripheralLibraries));
m_complexConditions.insert(std::pair<std::string, SettingConditionCheck>("hasrumblefeature", HasRumbleFeature));
m_complexConditions.insert(std::pair<std::string, SettingConditionCheck>("hasrumblecontroller", HasRumbleController));
m_complexConditions.insert(std::pair<std::string, SettingConditionCheck>("haspowerofffeature", HasPowerOffFeature));
diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp
index eaef376f2f..a7973a0302 100644
--- a/xbmc/settings/Settings.cpp
+++ b/xbmc/settings/Settings.cpp
@@ -373,6 +373,7 @@ const std::string CSettings::SETTING_AUDIOOUTPUT_TRUEHDPASSTHROUGH = "audiooutpu
const std::string CSettings::SETTING_AUDIOOUTPUT_DTSHDPASSTHROUGH = "audiooutput.dtshdpassthrough";
const std::string CSettings::SETTING_AUDIOOUTPUT_VOLUMESTEPS = "audiooutput.volumesteps";
const std::string CSettings::SETTING_INPUT_PERIPHERALS = "input.peripherals";
+const std::string CSettings::SETTING_INPUT_PERIPHERALLIBRARIES = "input.peripherallibraries";
const std::string CSettings::SETTING_INPUT_ENABLEMOUSE = "input.enablemouse";
const std::string CSettings::SETTING_INPUT_ASKNEWCONTROLLERS = "input.asknewcontrollers";
const std::string CSettings::SETTING_INPUT_CONTROLLERCONFIG = "input.controllerconfig";
@@ -1184,6 +1185,7 @@ void CSettings::InitializeISettingCallbacks()
settingSet.clear();
settingSet.insert(CSettings::SETTING_INPUT_PERIPHERALS);
+ settingSet.insert(CSettings::SETTING_INPUT_PERIPHERALLIBRARIES);
settingSet.insert(CSettings::SETTING_INPUT_CONTROLLERCONFIG);
settingSet.insert(CSettings::SETTING_INPUT_TESTRUMBLE);
settingSet.insert(CSettings::SETTING_LOCALE_LANGUAGE);
diff --git a/xbmc/settings/Settings.h b/xbmc/settings/Settings.h
index abd481626b..4893b24d8b 100644
--- a/xbmc/settings/Settings.h
+++ b/xbmc/settings/Settings.h
@@ -327,6 +327,7 @@ public:
static const std::string SETTING_AUDIOOUTPUT_DTSHDPASSTHROUGH;
static const std::string SETTING_AUDIOOUTPUT_VOLUMESTEPS;
static const std::string SETTING_INPUT_PERIPHERALS;
+ static const std::string SETTING_INPUT_PERIPHERALLIBRARIES;
static const std::string SETTING_INPUT_ENABLEMOUSE;
static const std::string SETTING_INPUT_ASKNEWCONTROLLERS;
static const std::string SETTING_INPUT_CONTROLLERCONFIG;