aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/kodi.peripheral/addon.xml2
-rw-r--r--lib/addons/library.kodi.peripheral/libKODI_peripheral.cpp7
-rw-r--r--xbmc/addons/binary/interfaces/api1/Peripheral/AddonCallbacksPeripheral.cpp22
-rw-r--r--xbmc/addons/binary/interfaces/api1/Peripheral/AddonCallbacksPeripheral.h1
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_callbacks.h10
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h3
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_peripheral.h7
7 files changed, 50 insertions, 2 deletions
diff --git a/addons/kodi.peripheral/addon.xml b/addons/kodi.peripheral/addon.xml
index 45baee52db..fa1d0f7fbb 100644
--- a/addons/kodi.peripheral/addon.xml
+++ b/addons/kodi.peripheral/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<addon id="kodi.peripheral" version="1.0.19" provider-name="Team-Kodi">
+<addon id="kodi.peripheral" version="1.0.20" provider-name="Team-Kodi">
<backwards-compatibility abi="1.0.19"/>
<requires>
<import addon="xbmc.core" version="0.1.0"/>
diff --git a/lib/addons/library.kodi.peripheral/libKODI_peripheral.cpp b/lib/addons/library.kodi.peripheral/libKODI_peripheral.cpp
index 597b489043..bd7b293b1f 100644
--- a/lib/addons/library.kodi.peripheral/libKODI_peripheral.cpp
+++ b/lib/addons/library.kodi.peripheral/libKODI_peripheral.cpp
@@ -69,6 +69,13 @@ DLLEXPORT void PERIPHERAL_refresh_button_maps(AddonCB* frontend, CB_PeripheralLi
return cb->RefreshButtonMaps(frontend->addonData, deviceName ? deviceName : "", controllerId ? controllerId : "");
}
+DLLEXPORT unsigned int PERIPHERAL_feature_count(AddonCB* frontend, CB_PeripheralLib* cb, const char* controllerId, JOYSTICK_FEATURE_TYPE type)
+{
+ if (frontend == NULL || cb == NULL)
+ return 0;
+ return cb->FeatureCount(frontend->addonData, controllerId, type);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/xbmc/addons/binary/interfaces/api1/Peripheral/AddonCallbacksPeripheral.cpp b/xbmc/addons/binary/interfaces/api1/Peripheral/AddonCallbacksPeripheral.cpp
index bf30edc93c..cf10a2dfe0 100644
--- a/xbmc/addons/binary/interfaces/api1/Peripheral/AddonCallbacksPeripheral.cpp
+++ b/xbmc/addons/binary/interfaces/api1/Peripheral/AddonCallbacksPeripheral.cpp
@@ -19,8 +19,11 @@
*/
#include "AddonCallbacksPeripheral.h"
+#include "games/controllers/Controller.h"
+#include "games/controllers/ControllerLayout.h"
#include "peripherals/Peripherals.h"
#include "peripherals/addons/PeripheralAddon.h"
+#include "peripherals/addons/PeripheralAddonTranslator.h"
#include "utils/log.h"
using namespace ADDON;
@@ -41,6 +44,7 @@ CAddonCallbacksPeripheral::CAddonCallbacksPeripheral(ADDON::CAddon* addon)
/* write Kodi peripheral specific add-on function addresses to callback table */
m_callbacks->TriggerScan = TriggerScan;
m_callbacks->RefreshButtonMaps = RefreshButtonMaps;
+ m_callbacks->FeatureCount = FeatureCount;
}
CAddonCallbacksPeripheral::~CAddonCallbacksPeripheral()
@@ -75,6 +79,24 @@ void CAddonCallbacksPeripheral::RefreshButtonMaps(void* addonData, const char* d
peripheralAddon->RefreshButtonMaps(deviceName ? deviceName : "", controllerId ? controllerId : "");
}
+unsigned int CAddonCallbacksPeripheral::FeatureCount(void* addonData, const char* controllerId, JOYSTICK_FEATURE_TYPE type)
+{
+ using namespace ADDON;
+ using namespace GAME;
+
+ unsigned int count = 0;
+
+ AddonPtr addon;
+ if (CAddonMgr::GetInstance().GetAddon(controllerId, addon, ADDON_GAME_CONTROLLER))
+ {
+ ControllerPtr controller = std::static_pointer_cast<CController>(addon);
+ if (controller->LoadLayout())
+ count = controller->Layout().FeatureCount(CPeripheralAddonTranslator::TranslateFeatureType(type));
+ }
+
+ return count;
+}
+
} /* namespace Peripheral */
} /* namespace KodiAPI */
diff --git a/xbmc/addons/binary/interfaces/api1/Peripheral/AddonCallbacksPeripheral.h b/xbmc/addons/binary/interfaces/api1/Peripheral/AddonCallbacksPeripheral.h
index 15bd74c747..5dd06f20bf 100644
--- a/xbmc/addons/binary/interfaces/api1/Peripheral/AddonCallbacksPeripheral.h
+++ b/xbmc/addons/binary/interfaces/api1/Peripheral/AddonCallbacksPeripheral.h
@@ -47,6 +47,7 @@ public:
static void TriggerScan(void* addonData);
static void RefreshButtonMaps(void* addonData, const char* deviceName, const char* controllerId);
+ static unsigned int FeatureCount(void* addonData, const char* controllerId, JOYSTICK_FEATURE_TYPE type);
private:
static PERIPHERALS::CPeripheralAddon* GetPeripheralAddon(void* addonData, const char* strFunction);
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_callbacks.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_callbacks.h
index 720c62f437..2dfc571361 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_callbacks.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_callbacks.h
@@ -44,6 +44,16 @@ typedef struct CB_PeripheralLib
*/
void (*RefreshButtonMaps)(void* addonData, const char* deviceName, const char* controllerId);
+ /*!
+ * @brief Return the number of features belonging to the specified controller
+ *
+ * @param controllerId The controller ID to enumerate
+ * @param type[optional] Type to filter by, or JOYSTICK_FEATURE_TYPE_UNKNOWN for all features
+ *
+ * @return The number of features matching the request parameters
+ */
+ unsigned int (*FeatureCount)(void* addonData, const char* controllerId, JOYSTICK_FEATURE_TYPE type);
+
} CB_PeripheralLib;
#ifdef __cplusplus
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h
index 58a6beac72..048245904a 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h
@@ -1,3 +1,4 @@
+
/*
* Copyright (C) 2014-2016 Team Kodi
* http://kodi.tv
@@ -50,7 +51,7 @@
#endif
/* current Peripheral API version */
-#define PERIPHERAL_API_VERSION "1.0.19"
+#define PERIPHERAL_API_VERSION "1.0.20"
/* min. Peripheral API version */
#define PERIPHERAL_MIN_API_VERSION "1.0.19"
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_peripheral.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_peripheral.h
index 9f3f9862a8..a28e48dc52 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_peripheral.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_peripheral.h
@@ -105,6 +105,7 @@ public:
if (!PERIPHERAL_REGISTER_SYMBOL(m_libKODI_peripheral, PERIPHERAL_unregister_me)) return false;
if (!PERIPHERAL_REGISTER_SYMBOL(m_libKODI_peripheral, PERIPHERAL_trigger_scan)) return false;
if (!PERIPHERAL_REGISTER_SYMBOL(m_libKODI_peripheral, PERIPHERAL_refresh_button_maps)) return false;
+ if (!PERIPHERAL_REGISTER_SYMBOL(m_libKODI_peripheral, PERIPHERAL_feature_count)) return false;
m_callbacks = PERIPHERAL_register_me(m_handle);
return m_callbacks != NULL;
@@ -120,11 +121,17 @@ public:
return PERIPHERAL_refresh_button_maps(m_handle, m_callbacks, strDeviceName.c_str(), strControllerId.c_str());
}
+ unsigned int FeatureCount(const std::string& strControllerId, JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN)
+ {
+ return PERIPHERAL_feature_count(m_handle, m_callbacks, strControllerId.c_str(), type);
+ }
+
protected:
CB_PeripheralLib* (*PERIPHERAL_register_me)(void* handle);
void (*PERIPHERAL_unregister_me)(void* handle, CB_PeripheralLib* cb);
void (*PERIPHERAL_trigger_scan)(void* handle, CB_PeripheralLib* cb);
void (*PERIPHERAL_refresh_button_maps)(void* handle, CB_PeripheralLib* cb, const char* deviceName, const char* controllerId);
+ unsigned int (*PERIPHERAL_feature_count)(void* handle, CB_PeripheralLib* cb, const char* controllerId, JOYSTICK_FEATURE_TYPE type);
private:
void* m_handle;