summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_dll.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_dll.h')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_dll.h198
1 files changed, 198 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_dll.h
new file mode 100644
index 0000000..591afcc
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_dll.h
@@ -0,0 +1,198 @@
1/*
2 * Copyright (C) 2014-2016 Team Kodi
3 * http://kodi.tv
4 *
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this Program; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 */
20#ifndef __PERIPHERAL_DLL_H__
21#define __PERIPHERAL_DLL_H__
22
23#include "kodi_peripheral_types.h"
24
25#define PERIPHERAL_ADDON_JOYSTICKS // TODO
26
27#ifdef __cplusplus
28extern "C"
29{
30#endif
31
32 /// @name Peripheral operations
33 ///{
34 /*!
35 * @brief Get the PERIPHERAL_API_VERSION used to compile this peripheral add-on
36 * @return KODI_PERIPHERAL_API_VERSION from kodi_peripheral_types.h
37 * @remarks Valid implementation required
38 *
39 * Used to check if the implementation is compatible with the frontend.
40 */
41 const char* GetPeripheralAPIVersion(void);
42
43 /*!
44 * @brief Get the KODI_PERIPHERAL_MIN_API_VERSION used to compile this peripheral add-on
45 * @return KODI_PERIPHERAL_MIN_API_VERSION from kodi_peripheral_types.h
46 * @remarks Valid implementation required
47 *
48 * Used to check if the implementation is compatible with the frontend.
49 */
50 const char* GetMinimumPeripheralAPIVersion(void);
51
52 /*!
53 * @brief Get the list of features that this add-on provides
54 * @param pCapabilities The add-on's capabilities.
55 * @return PERIPHERAL_NO_ERROR if the properties were fetched successfully.
56 * @remarks Valid implementation required.
57 *
58 * Called by the frontend to query the add-on's capabilities and supported
59 * peripherals. All capabilities that the add-on supports should be set to true.
60 *
61 */
62 PERIPHERAL_ERROR GetAddonCapabilities(PERIPHERAL_CAPABILITIES *pCapabilities);
63
64 /*!
65 * @brief Perform a scan for joysticks
66 * @param peripheral_count Assigned to the number of peripherals allocated
67 * @param scan_results Assigned to allocated memory
68 * @return PERIPHERAL_NO_ERROR if successful; peripherals must be freed using
69 * FreeScanResults() in this case
70 *
71 * The frontend calls this when a hardware change is detected. If an add-on
72 * detects a hardware change, it can trigger this function using the
73 * TriggerScan() callback.
74 */
75 PERIPHERAL_ERROR PerformDeviceScan(unsigned int* peripheral_count, PERIPHERAL_INFO** scan_results);
76
77 /*!
78 * @brief Free the memory allocated in PerformDeviceScan()
79 *
80 * Must be called if PerformDeviceScan() returns PERIPHERAL_NO_ERROR.
81 *
82 * @param peripheral_count The number of events allocated for the events array
83 * @param scan_results The array of allocated peripherals
84 */
85 void FreeScanResults(unsigned int peripheral_count, PERIPHERAL_INFO* scan_results);
86
87 /*!
88 * @brief Get all events that have occurred since the last call to GetEvents()
89 * @return PERIPHERAL_NO_ERROR if successful; events must be freed using
90 * FreeEvents() in this case
91 */
92 PERIPHERAL_ERROR GetEvents(unsigned int* event_count, PERIPHERAL_EVENT** events);
93
94 /*!
95 * @brief Free the memory allocated in GetEvents()
96 *
97 * Must be called if GetEvents() returns PERIPHERAL_NO_ERROR.
98 *
99 * @param event_count The number of events allocated for the events array
100 * @param events The array of allocated events
101 */
102 void FreeEvents(unsigned int event_count, PERIPHERAL_EVENT* events);
103 ///}
104
105 /// @name Joystick operations
106 /*!
107 * @note #define PERIPHERAL_ADDON_JOYSTICKS before including kodi_peripheral_dll.h
108 * in the add-on if the add-on provides joysticks and add provides_joysticks="true"
109 * to the kodi.peripheral extension point node in addon.xml.
110 */
111 ///{
112#ifdef PERIPHERAL_ADDON_JOYSTICKS
113 /*!
114 * @brief Get extended info about an attached joystick
115 * @param index The joystick's driver index
116 * @param info The container for the allocated joystick info
117 * @return PERIPHERAL_NO_ERROR if successful; array must be freed using
118 * FreeJoystickInfo() in this case
119 */
120 PERIPHERAL_ERROR GetJoystickInfo(unsigned int index, JOYSTICK_INFO* info);
121
122 /*!
123 * @brief Free the memory allocated in GetJoystickInfo()
124 */
125 void FreeJoystickInfo(JOYSTICK_INFO* info);
126
127 /*!
128 * @brief Get the features that allow translating the joystick into the controller profile
129 * @param joystick The device's joystick properties; unknown values may be left at their default
130 * @param controller_id The controller profile being requested, e.g. game.controller.default
131 * @param feature_count The number of features allocated for the features array
132 * @param features The array of allocated features
133 * @return PERIPHERAL_NO_ERROR if successful; array must be freed using
134 * FreeButtonMap() in this case
135 */
136 PERIPHERAL_ERROR GetFeatures(const JOYSTICK_INFO* joystick, const char* controller_id,
137 unsigned int* feature_count, JOYSTICK_FEATURE** features);
138
139 /*!
140 * @brief Free the memory allocated in GetFeatures()
141 *
142 * Must be called if GetFeatures() returns PERIPHERAL_NO_ERROR.
143 *
144 * @param feature_count The number of features allocated for the features array
145 * @param features The array of allocated features
146 */
147 void FreeFeatures(unsigned int feature_count, JOYSTICK_FEATURE* features);
148
149 /*!
150 * @brief Add or update joystick features
151 * @param joystick The device's joystick properties; unknown values may be left at their default
152 * @param controller_id The game controller profile being updated
153 * @param feature_count The number of features int the features array
154 * @param features The array of features
155 * @return PERIPHERAL_NO_ERROR if successful
156 */
157 PERIPHERAL_ERROR MapFeatures(const JOYSTICK_INFO* joystick, const char* controller_id,
158 unsigned int feature_count, JOYSTICK_FEATURE* features);
159
160 /*!
161 * @brief Reset the button map for the given joystick and controller profile ID
162 * @param joystick The device's joystick properties
163 * @param controller_id The game controller profile being reset
164 */
165 void ResetButtonMap(const JOYSTICK_INFO* joystick, const char* controller_id);
166#endif
167 ///}
168
169 /*!
170 * Called by the frontend to assign the function pointers of this add-on to
171 * pClient. Note that get_addon() is defined here, so it will be available in
172 * all compiled peripheral add-ons.
173 */
174 void __declspec(dllexport) get_addon(struct PeripheralAddon* pClient)
175 {
176 pClient->GetPeripheralAPIVersion = GetPeripheralAPIVersion;
177 pClient->GetMinimumPeripheralAPIVersion = GetMinimumPeripheralAPIVersion;
178 pClient->GetAddonCapabilities = GetAddonCapabilities;
179 pClient->PerformDeviceScan = PerformDeviceScan;
180 pClient->FreeScanResults = FreeScanResults;
181 pClient->GetEvents = GetEvents;
182 pClient->FreeEvents = FreeEvents;
183
184#ifdef PERIPHERAL_ADDON_JOYSTICKS
185 pClient->GetJoystickInfo = GetJoystickInfo;
186 pClient->FreeJoystickInfo = FreeJoystickInfo;
187 pClient->GetFeatures = GetFeatures;
188 pClient->FreeFeatures = FreeFeatures;
189 pClient->MapFeatures = MapFeatures;
190 pClient->ResetButtonMap = ResetButtonMap;
191#endif
192 }
193
194#ifdef __cplusplus
195}
196#endif
197
198#endif // __PERIPHERAL_DLL_H__