diff options
Diffstat (limited to 'xbmc/addons')
158 files changed, 20262 insertions, 11847 deletions
diff --git a/xbmc/addons/AddonBindings.cmake b/xbmc/addons/AddonBindings.cmake index 7fb5aba..11cf190 100644 --- a/xbmc/addons/AddonBindings.cmake +++ b/xbmc/addons/AddonBindings.cmake | |||
| @@ -1,15 +1,12 @@ | |||
| 1 | # List contains only add-on related headers not present in | 1 | # List contains only add-on related headers not present in |
| 2 | # ./addons/kodi-addon-dev-kit/include/kodi | 2 | # ./addons/kodi-dev-kit/include/kodi |
| 3 | # | 3 | # |
| 4 | 4 | ||
| 5 | # Keep this in alphabetical order | 5 | # Keep this in alphabetical order |
| 6 | set(CORE_ADDON_BINDINGS_FILES | 6 | set(CORE_ADDON_BINDINGS_FILES |
| 7 | ${CORE_SOURCE_DIR}/xbmc/cores/AudioEngine/Utils/AEChannelData.h | ||
| 8 | ${CORE_SOURCE_DIR}/xbmc/input/actions/ActionIDs.h | ||
| 9 | ${CORE_SOURCE_DIR}/xbmc/input/XBMC_vkeys.h | ||
| 10 | ) | 7 | ) |
| 11 | 8 | ||
| 12 | set(CORE_ADDON_BINDINGS_DIRS | 9 | set(CORE_ADDON_BINDINGS_DIRS |
| 13 | ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi/ | 10 | ${CORE_SOURCE_DIR}/xbmc/addons/kodi-dev-kit/include/kodi/ |
| 14 | ${CORE_SOURCE_DIR}/xbmc/cores/VideoPlayer/Interface/Addon | 11 | ${CORE_SOURCE_DIR}/xbmc/cores/VideoPlayer/Interface/Addon |
| 15 | ) | 12 | ) |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDecoder.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDecoder.h deleted file mode 100644 index 25e39e2..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDecoder.h +++ /dev/null | |||
| @@ -1,363 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | #ifdef BUILD_KODI_ADDON | ||
| 13 | #include "../AEChannelData.h" | ||
| 14 | #else | ||
| 15 | #include "cores/AudioEngine/Utils/AEChannelData.h" | ||
| 16 | #endif | ||
| 17 | #include <stdint.h> | ||
| 18 | |||
| 19 | namespace kodi | ||
| 20 | { | ||
| 21 | namespace addon | ||
| 22 | { | ||
| 23 | class CInstanceAudioDecoder; | ||
| 24 | } /* namespace addon */ | ||
| 25 | } /* namespace kodi */ | ||
| 26 | |||
| 27 | extern "C" | ||
| 28 | { | ||
| 29 | |||
| 30 | typedef struct AddonProps_AudioDecoder | ||
| 31 | { | ||
| 32 | int dummy; | ||
| 33 | } AddonProps_AudioDecoder; | ||
| 34 | |||
| 35 | typedef struct AddonToKodiFuncTable_AudioDecoder | ||
| 36 | { | ||
| 37 | void* kodiInstance; | ||
| 38 | } AddonToKodiFuncTable_AudioDecoder; | ||
| 39 | |||
| 40 | struct AddonInstance_AudioDecoder; | ||
| 41 | typedef struct KodiToAddonFuncTable_AudioDecoder | ||
| 42 | { | ||
| 43 | kodi::addon::CInstanceAudioDecoder* addonInstance; | ||
| 44 | bool (__cdecl* init)(const AddonInstance_AudioDecoder* instance, | ||
| 45 | const char* file, unsigned int filecache, | ||
| 46 | int* channels, int* samplerate, | ||
| 47 | int* bitspersample, int64_t* totaltime, | ||
| 48 | int* bitrate, AEDataFormat* format, | ||
| 49 | const AEChannel** info); | ||
| 50 | int (__cdecl* read_pcm)(const AddonInstance_AudioDecoder* instance, uint8_t* buffer, int size, int* actualsize); | ||
| 51 | int64_t (__cdecl* seek)(const AddonInstance_AudioDecoder* instance, int64_t time); | ||
| 52 | bool (__cdecl* read_tag)(const AddonInstance_AudioDecoder* instance, | ||
| 53 | const char* file, char* title, | ||
| 54 | char* artist, int* length); | ||
| 55 | int (__cdecl* track_count)(const AddonInstance_AudioDecoder* instance, const char* file); | ||
| 56 | } KodiToAddonFuncTable_AudioDecoder; | ||
| 57 | |||
| 58 | typedef struct AddonInstance_AudioDecoder | ||
| 59 | { | ||
| 60 | AddonProps_AudioDecoder props; | ||
| 61 | AddonToKodiFuncTable_AudioDecoder toKodi; | ||
| 62 | KodiToAddonFuncTable_AudioDecoder toAddon; | ||
| 63 | } AddonInstance_AudioDecoder; | ||
| 64 | |||
| 65 | } /* extern "C" */ | ||
| 66 | |||
| 67 | namespace kodi | ||
| 68 | { | ||
| 69 | namespace addon | ||
| 70 | { | ||
| 71 | |||
| 72 | //============================================================================== | ||
| 73 | /// | ||
| 74 | /// \addtogroup cpp_kodi_addon_audiodecoder | ||
| 75 | /// @brief \cpp_class{ kodi::addon::CInstanceAudioDecoder } | ||
| 76 | /// **Audio decoder add-on instance** | ||
| 77 | /// | ||
| 78 | /// For audio decoders as binary add-ons. This class implements a way to handle | ||
| 79 | /// special types of audio files. | ||
| 80 | /// | ||
| 81 | /// The add-on handles loading of the source file and outputting the audio stream | ||
| 82 | /// for consumption by the player. | ||
| 83 | /// | ||
| 84 | /// The addon.xml defines the capabilities of this add-on. | ||
| 85 | /// | ||
| 86 | /// @note The option to have multiple instances is possible with audio-decoder | ||
| 87 | /// add-ons. This is useful, since some playback engines are riddled by global | ||
| 88 | /// variables, making decoding of multiple streams using the same instance | ||
| 89 | /// impossible. | ||
| 90 | /// | ||
| 91 | /// | ||
| 92 | /// ---------------------------------------------------------------------------- | ||
| 93 | /// | ||
| 94 | /// **Here's an example on addon.xml:** | ||
| 95 | /// ~~~~~~~~~~~~~{.xml} | ||
| 96 | /// <extension | ||
| 97 | /// point="kodi.audiodecoder" | ||
| 98 | /// name="2sf" | ||
| 99 | /// extension=".2sf|.mini2sf" | ||
| 100 | /// tags="true" | ||
| 101 | /// library_@PLATFORM@="@LIBRARY_FILENAME@"/> | ||
| 102 | /// ~~~~~~~~~~~~~ | ||
| 103 | /// | ||
| 104 | /// Description to audio decoder related addon.xml values: | ||
| 105 | /// | Name | Description | ||
| 106 | /// |:------------------------------|---------------------------------------- | ||
| 107 | /// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"kodi.audiodecoder"</b>. | ||
| 108 | /// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build. | ||
| 109 | /// | <b>`name`</b> | The name of the decoder used in Kodi for display. | ||
| 110 | /// | <b>`extension`</b> | The file extensions / styles supported by this addon. | ||
| 111 | /// | <b>`tags`</b> | Boolean to point out that addon can bring own information to replayed file, if <b>`false`</b> only the file name is used as info.<br>If <b>`true`</b>, \ref CInstanceAudioDecoder::ReadTag is used and must be implemented. | ||
| 112 | /// | ||
| 113 | /// -------------------------------------------------------------------------- | ||
| 114 | /// | ||
| 115 | /// **Here is a code example how this addon is used:** | ||
| 116 | /// | ||
| 117 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 118 | /// #include <kodi/addon-instance/AudioDecoder.h> | ||
| 119 | /// | ||
| 120 | /// class CMyAudioDecoder : public ::kodi::addon::CInstanceAudioDecoder | ||
| 121 | /// { | ||
| 122 | /// public: | ||
| 123 | /// CMyAudioDecoder(KODI_HANDLE instance); | ||
| 124 | /// | ||
| 125 | /// bool Init(const std::string& filename, unsigned int filecache, | ||
| 126 | /// int& channels, int& samplerate, | ||
| 127 | /// int& bitspersample, int64_t& totaltime, | ||
| 128 | /// int& bitrate, AEDataFormat& format, | ||
| 129 | /// std::vector<AEChannel>& channellist) override; | ||
| 130 | /// int ReadPCM(uint8_t* buffer, int size, int& actualsize) override; | ||
| 131 | /// }; | ||
| 132 | /// | ||
| 133 | /// CMyAudioDecoder::CMyAudioDecoder(KODI_HANDLE instance) | ||
| 134 | /// : CInstanceAudioDecoder(instance) | ||
| 135 | /// { | ||
| 136 | /// ... | ||
| 137 | /// } | ||
| 138 | /// | ||
| 139 | /// bool CMyAudioDecoder::Init(const std::string& filename, unsigned int filecache, | ||
| 140 | /// int& channels, int& samplerate, | ||
| 141 | /// int& bitspersample, int64_t& totaltime, | ||
| 142 | /// int& bitrate, AEDataFormat& format, | ||
| 143 | /// std::vector<AEChannel>& channellist) | ||
| 144 | /// { | ||
| 145 | /// ... | ||
| 146 | /// return true; | ||
| 147 | /// } | ||
| 148 | /// | ||
| 149 | /// int CMyAudioDecoder::ReadPCM(uint8_t* buffer, int size, int& actualsize) | ||
| 150 | /// { | ||
| 151 | /// ... | ||
| 152 | /// return 0; | ||
| 153 | /// } | ||
| 154 | /// | ||
| 155 | /// | ||
| 156 | /// /*----------------------------------------------------------------------*/ | ||
| 157 | /// | ||
| 158 | /// class CMyAddon : public ::kodi::addon::CAddonBase | ||
| 159 | /// { | ||
| 160 | /// public: | ||
| 161 | /// CMyAddon() { } | ||
| 162 | /// ADDON_STATUS CreateInstance(int instanceType, | ||
| 163 | /// std::string instanceID, | ||
| 164 | /// KODI_HANDLE instance, | ||
| 165 | /// KODI_HANDLE& addonInstance) override; | ||
| 166 | /// }; | ||
| 167 | /// | ||
| 168 | /// /* If you use only one instance in your add-on, can be instanceType and | ||
| 169 | /// * instanceID ignored */ | ||
| 170 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 171 | /// std::string instanceID, | ||
| 172 | /// KODI_HANDLE instance, | ||
| 173 | /// KODI_HANDLE& addonInstance) | ||
| 174 | /// { | ||
| 175 | /// if (instanceType == ADDON_INSTANCE_AUDIODECODER) | ||
| 176 | /// { | ||
| 177 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my audio decoder"); | ||
| 178 | /// addonInstance = new CMyAudioDecoder(instance); | ||
| 179 | /// return ADDON_STATUS_OK; | ||
| 180 | /// } | ||
| 181 | /// else if (...) | ||
| 182 | /// { | ||
| 183 | /// ... | ||
| 184 | /// } | ||
| 185 | /// return ADDON_STATUS_UNKNOWN; | ||
| 186 | /// } | ||
| 187 | /// | ||
| 188 | /// ADDONCREATOR(CMyAddon) | ||
| 189 | /// ~~~~~~~~~~~~~ | ||
| 190 | /// | ||
| 191 | /// The destruction of the example class `CMyAudioDecoder` is called from | ||
| 192 | /// Kodi's header. Manually deleting the add-on instance is not required. | ||
| 193 | /// | ||
| 194 | class ATTRIBUTE_HIDDEN CInstanceAudioDecoder : public IAddonInstance | ||
| 195 | { | ||
| 196 | public: | ||
| 197 | //========================================================================== | ||
| 198 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 199 | /// @brief Class constructor | ||
| 200 | /// | ||
| 201 | /// @param[in] instance The addon instance class handler given by Kodi | ||
| 202 | /// at \ref kodi::addon::CAddonBase::CreateInstance(...) | ||
| 203 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to | ||
| 204 | /// allow compatibility to older Kodi versions. | ||
| 205 | /// @note Recommended to set. | ||
| 206 | /// | ||
| 207 | explicit CInstanceAudioDecoder(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 208 | : IAddonInstance(ADDON_INSTANCE_AUDIODECODER, | ||
| 209 | !kodiVersion.empty() ? kodiVersion | ||
| 210 | : GetKodiTypeVersion(ADDON_INSTANCE_AUDIODECODER)) | ||
| 211 | { | ||
| 212 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 213 | throw std::logic_error("kodi::addon::CInstanceAudioDecoder: Creation of multiple together with single instance way is not allowed!"); | ||
| 214 | |||
| 215 | SetAddonStruct(instance); | ||
| 216 | } | ||
| 217 | //-------------------------------------------------------------------------- | ||
| 218 | |||
| 219 | //========================================================================== | ||
| 220 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 221 | /// @brief Initialize a decoder | ||
| 222 | /// | ||
| 223 | /// @param[in] filename The file to read | ||
| 224 | /// @param[in] filecache The file cache size | ||
| 225 | /// @param[out] channels Number of channels in output stream | ||
| 226 | /// @param[out] samplerate Samplerate of output stream | ||
| 227 | /// @param[out] bitspersample Bits per sample in output stream | ||
| 228 | /// @param[out] totaltime Total time for stream | ||
| 229 | /// @param[out] bitrate Average bitrate of input stream | ||
| 230 | /// @param[out] format Data format for output stream | ||
| 231 | /// @param[out] channellist Channel mapping for output stream | ||
| 232 | /// @return true if successfully done, otherwise | ||
| 233 | /// false | ||
| 234 | /// | ||
| 235 | virtual bool Init(const std::string& filename, unsigned int filecache, | ||
| 236 | int& channels, int& samplerate, | ||
| 237 | int& bitspersample, int64_t& totaltime, | ||
| 238 | int& bitrate, AEDataFormat& format, | ||
| 239 | std::vector<AEChannel>& channellist) = 0; | ||
| 240 | //-------------------------------------------------------------------------- | ||
| 241 | |||
| 242 | //========================================================================== | ||
| 243 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 244 | /// @brief Produce some noise | ||
| 245 | /// | ||
| 246 | /// @param[in] buffer Output buffer | ||
| 247 | /// @param[in] size Size of output buffer | ||
| 248 | /// @param[out] actualsize Actual number of bytes written to output buffer | ||
| 249 | /// @return Return with following possible values: | ||
| 250 | /// | Value | Description | | ||
| 251 | /// |:-----:|:-----------------------------| | ||
| 252 | /// | 0 | on success | ||
| 253 | /// | -1 | on end of stream | ||
| 254 | /// | 1 | on failure | ||
| 255 | /// | ||
| 256 | virtual int ReadPCM(uint8_t* buffer, int size, int& actualsize) = 0; | ||
| 257 | //-------------------------------------------------------------------------- | ||
| 258 | |||
| 259 | //========================================================================== | ||
| 260 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 261 | /// @brief Seek in output stream | ||
| 262 | /// | ||
| 263 | /// @param[in] time Time position to seek to in milliseconds | ||
| 264 | /// @return Time position seek ended up on | ||
| 265 | /// | ||
| 266 | virtual int64_t Seek(int64_t time) { return time; } | ||
| 267 | //-------------------------------------------------------------------------- | ||
| 268 | |||
| 269 | //========================================================================== | ||
| 270 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 271 | /// @brief Read tag of a file | ||
| 272 | /// | ||
| 273 | /// @param[in] file File to read tag for | ||
| 274 | /// @param[out] title Title of file | ||
| 275 | /// @param[out] artist Artist of file | ||
| 276 | /// @param[out] length Length of file | ||
| 277 | /// @return True on success, false on failure | ||
| 278 | /// | ||
| 279 | virtual bool ReadTag(const std::string& file, std::string& title, std::string& artist, int& length) { return false; } | ||
| 280 | //-------------------------------------------------------------------------- | ||
| 281 | |||
| 282 | //========================================================================== | ||
| 283 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 284 | /// @brief Get number of tracks in a file | ||
| 285 | /// | ||
| 286 | /// @param[in] file File to read tag for | ||
| 287 | /// @return Number of tracks in file | ||
| 288 | /// | ||
| 289 | virtual int TrackCount(const std::string& file) { return 1; } | ||
| 290 | //-------------------------------------------------------------------------- | ||
| 291 | |||
| 292 | private: | ||
| 293 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 294 | { | ||
| 295 | if (instance == nullptr) | ||
| 296 | throw std::logic_error("kodi::addon::CInstanceAudioDecoder: Creation with empty addon structure not allowed, table must be given from Kodi!"); | ||
| 297 | |||
| 298 | m_instanceData = static_cast<AddonInstance_AudioDecoder*>(instance); | ||
| 299 | |||
| 300 | m_instanceData->toAddon.addonInstance = this; | ||
| 301 | m_instanceData->toAddon.init = ADDON_Init; | ||
| 302 | m_instanceData->toAddon.read_pcm = ADDON_ReadPCM; | ||
| 303 | m_instanceData->toAddon.seek = ADDON_Seek; | ||
| 304 | m_instanceData->toAddon.read_tag = ADDON_ReadTag; | ||
| 305 | m_instanceData->toAddon.track_count = ADDON_TrackCount; | ||
| 306 | } | ||
| 307 | |||
| 308 | inline static bool ADDON_Init(const AddonInstance_AudioDecoder* instance, const char* file, unsigned int filecache, | ||
| 309 | int* channels, int* samplerate, | ||
| 310 | int* bitspersample, int64_t* totaltime, | ||
| 311 | int* bitrate, AEDataFormat* format, | ||
| 312 | const AEChannel** info) | ||
| 313 | { | ||
| 314 | instance->toAddon.addonInstance->m_channelList.clear(); | ||
| 315 | bool ret = instance->toAddon.addonInstance->Init(file, filecache, *channels, | ||
| 316 | *samplerate, *bitspersample, | ||
| 317 | *totaltime, *bitrate, *format, | ||
| 318 | instance->toAddon.addonInstance->m_channelList); | ||
| 319 | if (!instance->toAddon.addonInstance->m_channelList.empty()) | ||
| 320 | { | ||
| 321 | if (instance->toAddon.addonInstance->m_channelList.back() != AE_CH_NULL) | ||
| 322 | instance->toAddon.addonInstance->m_channelList.push_back(AE_CH_NULL); | ||
| 323 | *info = instance->toAddon.addonInstance->m_channelList.data(); | ||
| 324 | } | ||
| 325 | else | ||
| 326 | *info = nullptr; | ||
| 327 | return ret; | ||
| 328 | } | ||
| 329 | |||
| 330 | inline static int ADDON_ReadPCM(const AddonInstance_AudioDecoder* instance, uint8_t* buffer, int size, int* actualsize) | ||
| 331 | { | ||
| 332 | return instance->toAddon.addonInstance->ReadPCM(buffer, size, *actualsize); | ||
| 333 | } | ||
| 334 | |||
| 335 | inline static int64_t ADDON_Seek(const AddonInstance_AudioDecoder* instance, int64_t time) | ||
| 336 | { | ||
| 337 | return instance->toAddon.addonInstance->Seek(time); | ||
| 338 | } | ||
| 339 | |||
| 340 | inline static bool ADDON_ReadTag(const AddonInstance_AudioDecoder* instance, const char* file, char* title, char* artist, int* length) | ||
| 341 | { | ||
| 342 | std::string intTitle; | ||
| 343 | std::string intArtist; | ||
| 344 | bool ret = instance->toAddon.addonInstance->ReadTag(file, intTitle, intArtist, *length); | ||
| 345 | if (ret) | ||
| 346 | { | ||
| 347 | strncpy(title, intTitle.c_str(), ADDON_STANDARD_STRING_LENGTH_SMALL-1); | ||
| 348 | strncpy(artist, intArtist.c_str(), ADDON_STANDARD_STRING_LENGTH_SMALL-1); | ||
| 349 | } | ||
| 350 | return ret; | ||
| 351 | } | ||
| 352 | |||
| 353 | inline static int ADDON_TrackCount(const AddonInstance_AudioDecoder* instance, const char* file) | ||
| 354 | { | ||
| 355 | return instance->toAddon.addonInstance->TrackCount(file); | ||
| 356 | } | ||
| 357 | |||
| 358 | std::vector<AEChannel> m_channelList; | ||
| 359 | AddonInstance_AudioDecoder* m_instanceData; | ||
| 360 | }; | ||
| 361 | |||
| 362 | } /* namespace addon */ | ||
| 363 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioEncoder.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioEncoder.h deleted file mode 100644 index 36257e1..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioEncoder.h +++ /dev/null | |||
| @@ -1,218 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | |||
| 13 | namespace kodi { namespace addon { class CInstanceAudioEncoder; }} | ||
| 14 | |||
| 15 | extern "C" | ||
| 16 | { | ||
| 17 | |||
| 18 | typedef struct AddonProps_AudioEncoder | ||
| 19 | { | ||
| 20 | int dummy; | ||
| 21 | } AddonProps_AudioEncoder; | ||
| 22 | |||
| 23 | typedef struct AddonToKodiFuncTable_AudioEncoder | ||
| 24 | { | ||
| 25 | void* kodiInstance; | ||
| 26 | int (*write) (void* kodiInstance, const uint8_t* data, int len); | ||
| 27 | int64_t (*seek)(void* kodiInstance, int64_t pos, int whence); | ||
| 28 | } AddonToKodiFuncTable_AudioEncoder; | ||
| 29 | |||
| 30 | struct AddonInstance_AudioEncoder; | ||
| 31 | typedef struct KodiToAddonFuncTable_AudioEncoder | ||
| 32 | { | ||
| 33 | kodi::addon::CInstanceAudioEncoder* addonInstance; | ||
| 34 | bool (__cdecl* start) (const AddonInstance_AudioEncoder* instance, int in_channels, int in_rate, int in_bits, | ||
| 35 | const char* title, const char* artist, | ||
| 36 | const char* albumartist, const char* album, | ||
| 37 | const char* year, const char* track, | ||
| 38 | const char* genre, const char* comment, | ||
| 39 | int track_length); | ||
| 40 | int (__cdecl* encode) (const AddonInstance_AudioEncoder* instance, int num_bytes_read, const uint8_t* pbt_stream); | ||
| 41 | bool (__cdecl* finish) (const AddonInstance_AudioEncoder* instance); | ||
| 42 | } KodiToAddonFuncTable_AudioEncoder; | ||
| 43 | |||
| 44 | typedef struct AddonInstance_AudioEncoder | ||
| 45 | { | ||
| 46 | AddonProps_AudioEncoder props; | ||
| 47 | AddonToKodiFuncTable_AudioEncoder toKodi; | ||
| 48 | KodiToAddonFuncTable_AudioEncoder toAddon; | ||
| 49 | } AddonInstance_AudioEncoder; | ||
| 50 | |||
| 51 | } /* extern "C" */ | ||
| 52 | |||
| 53 | namespace kodi | ||
| 54 | { | ||
| 55 | namespace addon | ||
| 56 | { | ||
| 57 | |||
| 58 | class ATTRIBUTE_HIDDEN CInstanceAudioEncoder : public IAddonInstance | ||
| 59 | { | ||
| 60 | public: | ||
| 61 | //========================================================================== | ||
| 62 | /// @brief Class constructor | ||
| 63 | /// | ||
| 64 | /// @param[in] instance The from Kodi given instance given be | ||
| 65 | /// add-on CreateInstance call with instance | ||
| 66 | /// id ADDON_INSTANCE_AUDIOENCODER. | ||
| 67 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to | ||
| 68 | /// allow compatibility to older Kodi versions. | ||
| 69 | /// @note Recommended to set. | ||
| 70 | /// | ||
| 71 | explicit CInstanceAudioEncoder(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 72 | : IAddonInstance(ADDON_INSTANCE_AUDIOENCODER, | ||
| 73 | !kodiVersion.empty() ? kodiVersion | ||
| 74 | : GetKodiTypeVersion(ADDON_INSTANCE_AUDIOENCODER)) | ||
| 75 | { | ||
| 76 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 77 | throw std::logic_error("kodi::addon::CInstanceAudioEncoder: Creation of multiple together with single instance way is not allowed!"); | ||
| 78 | |||
| 79 | SetAddonStruct(instance); | ||
| 80 | } | ||
| 81 | //-------------------------------------------------------------------------- | ||
| 82 | |||
| 83 | //========================================================================== | ||
| 84 | /// \brief Start encoder (**required**) | ||
| 85 | /// | ||
| 86 | /// \param[in] inChannels Number of channels | ||
| 87 | /// \param[in] inRate Sample rate of input data | ||
| 88 | /// \param[in] inBits Bits per sample in input data | ||
| 89 | /// \param[in] title The title of the song | ||
| 90 | /// \param[in] artist The artist of the song | ||
| 91 | /// \param[in] albumartist The albumartist of the song | ||
| 92 | /// \param[in] year The year of the song | ||
| 93 | /// \param[in] track The track number of the song | ||
| 94 | /// \param[in] genre The genre of the song | ||
| 95 | /// \param[in] comment A comment to attach to the song | ||
| 96 | /// \param[in] trackLength Total track length in seconds | ||
| 97 | /// \return True on success, false on failure. | ||
| 98 | /// | ||
| 99 | virtual bool Start(int inChannels, | ||
| 100 | int inRate, | ||
| 101 | int inBits, | ||
| 102 | const std::string& title, | ||
| 103 | const std::string& artist, | ||
| 104 | const std::string& albumartist, | ||
| 105 | const std::string& album, | ||
| 106 | const std::string& year, | ||
| 107 | const std::string& track, | ||
| 108 | const std::string& genre, | ||
| 109 | const std::string& comment, | ||
| 110 | int trackLength) = 0; | ||
| 111 | //-------------------------------------------------------------------------- | ||
| 112 | |||
| 113 | //========================================================================== | ||
| 114 | /// \brief Encode a chunk of audio (**required**) | ||
| 115 | /// | ||
| 116 | /// \param[in] numBytesRead Number of bytes in input buffer | ||
| 117 | /// \param[in] pbtStream the input buffer | ||
| 118 | /// \return Number of bytes consumed | ||
| 119 | /// | ||
| 120 | virtual int Encode(int numBytesRead, const uint8_t* pbtStream) = 0; | ||
| 121 | //-------------------------------------------------------------------------- | ||
| 122 | |||
| 123 | //========================================================================== | ||
| 124 | /// \brief Finalize encoding (**optional**) | ||
| 125 | /// | ||
| 126 | /// \return True on success, false on failure. | ||
| 127 | /// | ||
| 128 | virtual bool Finish() { return true; } | ||
| 129 | //-------------------------------------------------------------------------- | ||
| 130 | |||
| 131 | //========================================================================== | ||
| 132 | /// \brief Write block of data | ||
| 133 | /// | ||
| 134 | /// \param[in] data Pointer to the array of elements to be | ||
| 135 | /// written | ||
| 136 | /// \param[in] length Size in bytes to be written. | ||
| 137 | /// \return The total number of bytes | ||
| 138 | /// successfully written is returned. | ||
| 139 | int Write(const uint8_t* data, int length) | ||
| 140 | { | ||
| 141 | return m_instanceData->toKodi.write(m_instanceData->toKodi.kodiInstance, data, length); | ||
| 142 | } | ||
| 143 | //-------------------------------------------------------------------------- | ||
| 144 | |||
| 145 | //========================================================================== | ||
| 146 | /// \brief Set the file's current position. | ||
| 147 | /// | ||
| 148 | /// The whence argument is optional and defaults to SEEK_SET (0) | ||
| 149 | /// | ||
| 150 | /// \param[in] position the position that you want to seek to | ||
| 151 | /// \param[in] whence [optional] offset relative to | ||
| 152 | /// You can set the value of whence to one | ||
| 153 | /// of three things: | ||
| 154 | /// | Value | int | Description | | ||
| 155 | /// |:--------:|:---:|:---------------------------------------------------| | ||
| 156 | /// | SEEK_SET | 0 | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence. | ||
| 157 | /// | SEEK_CUR | 1 | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes." | ||
| 158 | /// | SEEK_END | 2 | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion. | ||
| 159 | /// | ||
| 160 | /// \return Returns the resulting offset location as | ||
| 161 | /// measured in bytes from the beginning of | ||
| 162 | /// the file. On error, the value -1 is | ||
| 163 | /// returned. | ||
| 164 | int64_t Seek(int64_t position, int whence = SEEK_SET) | ||
| 165 | { | ||
| 166 | return m_instanceData->toKodi.seek(m_instanceData->toKodi.kodiInstance, position, whence); | ||
| 167 | } | ||
| 168 | //-------------------------------------------------------------------------- | ||
| 169 | |||
| 170 | private: | ||
| 171 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 172 | { | ||
| 173 | if (instance == nullptr) | ||
| 174 | throw std::logic_error("kodi::addon::CInstanceAudioEncoder: Creation with empty addon structure not allowed, table must be given from Kodi!"); | ||
| 175 | |||
| 176 | m_instanceData = static_cast<AddonInstance_AudioEncoder*>(instance); | ||
| 177 | m_instanceData->toAddon.addonInstance = this; | ||
| 178 | m_instanceData->toAddon.start = ADDON_Start; | ||
| 179 | m_instanceData->toAddon.encode = ADDON_Encode; | ||
| 180 | m_instanceData->toAddon.finish = ADDON_Finish; | ||
| 181 | } | ||
| 182 | |||
| 183 | inline static bool ADDON_Start(const AddonInstance_AudioEncoder* instance, int inChannels, int inRate, int inBits, | ||
| 184 | const char* title, const char* artist, | ||
| 185 | const char* albumartist, const char* album, | ||
| 186 | const char* year, const char* track, | ||
| 187 | const char* genre, const char* comment, | ||
| 188 | int trackLength) | ||
| 189 | { | ||
| 190 | return instance->toAddon.addonInstance->Start(inChannels, | ||
| 191 | inRate, | ||
| 192 | inBits, | ||
| 193 | title, | ||
| 194 | artist, | ||
| 195 | albumartist, | ||
| 196 | album, | ||
| 197 | year, | ||
| 198 | track, | ||
| 199 | genre, | ||
| 200 | comment, | ||
| 201 | trackLength); | ||
| 202 | } | ||
| 203 | |||
| 204 | inline static int ADDON_Encode(const AddonInstance_AudioEncoder* instance, int numBytesRead, const uint8_t* pbtStream) | ||
| 205 | { | ||
| 206 | return instance->toAddon.addonInstance->Encode(numBytesRead, pbtStream); | ||
| 207 | } | ||
| 208 | |||
| 209 | inline static bool ADDON_Finish(const AddonInstance_AudioEncoder* instance) | ||
| 210 | { | ||
| 211 | return instance->toAddon.addonInstance->Finish(); | ||
| 212 | } | ||
| 213 | |||
| 214 | AddonInstance_AudioEncoder* m_instanceData; | ||
| 215 | }; | ||
| 216 | |||
| 217 | } /* namespace addon */ | ||
| 218 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Game.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Game.h deleted file mode 100644 index a53f1e7..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Game.h +++ /dev/null | |||
| @@ -1,2360 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | |||
| 13 | #ifdef BUILD_KODI_ADDON | ||
| 14 | #include "XBMC_vkeys.h" | ||
| 15 | #else | ||
| 16 | #include "input/XBMC_vkeys.h" | ||
| 17 | #endif | ||
| 18 | |||
| 19 | //============================================================================== | ||
| 20 | /// @addtogroup cpp_kodi_addon_game | ||
| 21 | /// | ||
| 22 | /// To use on Libretro and for stand-alone games or emulators that does not use | ||
| 23 | /// the Libretro API. | ||
| 24 | /// | ||
| 25 | /// Possible examples could be, Nvidia GameStream via Limelight or WINE capture | ||
| 26 | /// could possible through the Game API. | ||
| 27 | /// | ||
| 28 | |||
| 29 | namespace kodi | ||
| 30 | { | ||
| 31 | namespace addon | ||
| 32 | { | ||
| 33 | class CInstanceGame; | ||
| 34 | } | ||
| 35 | } // namespace kodi | ||
| 36 | |||
| 37 | extern "C" | ||
| 38 | { | ||
| 39 | |||
| 40 | //============================================================================== | ||
| 41 | /// \defgroup cpp_kodi_addon_game_Defs Definitions, structures and enumerators | ||
| 42 | /// \ingroup cpp_kodi_addon_game | ||
| 43 | /// @brief **Game add-on instance definition values** | ||
| 44 | //------------------------------------------------------------------------------ | ||
| 45 | |||
| 46 | //============================================================================== | ||
| 47 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 48 | /// @brief **Port ID used when topology is unknown** | ||
| 49 | #define DEFAULT_PORT_ID "1" | ||
| 50 | //------------------------------------------------------------------------------ | ||
| 51 | |||
| 52 | //============================================================================== | ||
| 53 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 54 | /// @brief **Game add-on error codes** | ||
| 55 | /// | ||
| 56 | /// Used as return values on most Game related functions. | ||
| 57 | /// | ||
| 58 | typedef enum GAME_ERROR | ||
| 59 | { | ||
| 60 | /// @brief no error occurred | ||
| 61 | GAME_ERROR_NO_ERROR, | ||
| 62 | |||
| 63 | /// @brief an unknown error occurred | ||
| 64 | GAME_ERROR_UNKNOWN, | ||
| 65 | |||
| 66 | /// @brief the method that the frontend called is not implemented | ||
| 67 | GAME_ERROR_NOT_IMPLEMENTED, | ||
| 68 | |||
| 69 | /// @brief the command was rejected by the game client | ||
| 70 | GAME_ERROR_REJECTED, | ||
| 71 | |||
| 72 | /// @brief the parameters of the method that was called are invalid for this operation | ||
| 73 | GAME_ERROR_INVALID_PARAMETERS, | ||
| 74 | |||
| 75 | /// @brief the command failed | ||
| 76 | GAME_ERROR_FAILED, | ||
| 77 | |||
| 78 | /// @brief no game is loaded | ||
| 79 | GAME_ERROR_NOT_LOADED, | ||
| 80 | |||
| 81 | /// @brief game requires restricted resources | ||
| 82 | GAME_ERROR_RESTRICTED, | ||
| 83 | } GAME_ERROR; | ||
| 84 | //------------------------------------------------------------------------------ | ||
| 85 | |||
| 86 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 87 | /// \defgroup cpp_kodi_addon_game_Defs_AudioStream 1. Audio stream | ||
| 88 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 89 | /// @brief **The for Audio stream used data system** | ||
| 90 | /// | ||
| 91 | /// Used to give Addon currently used audio stream configuration on Kodi and | ||
| 92 | /// arrays to give related data to Kodi on callbacks. | ||
| 93 | /// | ||
| 94 | //@{ | ||
| 95 | |||
| 96 | //============================================================================== | ||
| 97 | /// @brief **Stream Format** | ||
| 98 | /// | ||
| 99 | /// From Kodi requested specified audio sample format. | ||
| 100 | /// | ||
| 101 | typedef enum GAME_PCM_FORMAT | ||
| 102 | { | ||
| 103 | GAME_PCM_FORMAT_UNKNOWN, | ||
| 104 | |||
| 105 | /// @brief S16NE sample format | ||
| 106 | GAME_PCM_FORMAT_S16NE, | ||
| 107 | } GAME_PCM_FORMAT; | ||
| 108 | //------------------------------------------------------------------------------ | ||
| 109 | |||
| 110 | //============================================================================== | ||
| 111 | /// @brief **Audio channel** | ||
| 112 | /// | ||
| 113 | /// Channel identification flags. | ||
| 114 | /// | ||
| 115 | typedef enum GAME_AUDIO_CHANNEL | ||
| 116 | { | ||
| 117 | /// @brief Channel list terminator | ||
| 118 | GAME_CH_NULL, | ||
| 119 | |||
| 120 | /// @brief Channel front left | ||
| 121 | GAME_CH_FL, | ||
| 122 | |||
| 123 | /// @brief Channel front right | ||
| 124 | GAME_CH_FR, | ||
| 125 | |||
| 126 | /// @brief Channel front center | ||
| 127 | GAME_CH_FC, | ||
| 128 | |||
| 129 | /// @brief Channel Low Frequency Effects / Subwoofer | ||
| 130 | GAME_CH_LFE, | ||
| 131 | |||
| 132 | /// @brief Channel back left | ||
| 133 | GAME_CH_BL, | ||
| 134 | |||
| 135 | /// @brief Channel back right | ||
| 136 | GAME_CH_BR, | ||
| 137 | |||
| 138 | /// @brief Channel front left over center | ||
| 139 | GAME_CH_FLOC, | ||
| 140 | |||
| 141 | /// @brief Channel front right over center | ||
| 142 | GAME_CH_FROC, | ||
| 143 | |||
| 144 | /// @brief Channel back center | ||
| 145 | GAME_CH_BC, | ||
| 146 | |||
| 147 | /// @brief Channel surround/side left | ||
| 148 | GAME_CH_SL, | ||
| 149 | |||
| 150 | /// @brief Channel surround/side right | ||
| 151 | GAME_CH_SR, | ||
| 152 | |||
| 153 | /// @brief Channel top front left | ||
| 154 | GAME_CH_TFL, | ||
| 155 | |||
| 156 | /// @brief Channel top front right | ||
| 157 | GAME_CH_TFR, | ||
| 158 | |||
| 159 | /// @brief Channel top front center | ||
| 160 | GAME_CH_TFC, | ||
| 161 | |||
| 162 | /// @brief Channel top center | ||
| 163 | GAME_CH_TC, | ||
| 164 | |||
| 165 | /// @brief Channel top back left | ||
| 166 | GAME_CH_TBL, | ||
| 167 | |||
| 168 | /// @brief Channel top back right | ||
| 169 | GAME_CH_TBR, | ||
| 170 | |||
| 171 | /// @brief Channel top back center | ||
| 172 | GAME_CH_TBC, | ||
| 173 | |||
| 174 | /// @brief Channel bacl left over center | ||
| 175 | GAME_CH_BLOC, | ||
| 176 | |||
| 177 | /// @brief Channel back right over center | ||
| 178 | GAME_CH_BROC, | ||
| 179 | } GAME_AUDIO_CHANNEL; | ||
| 180 | //------------------------------------------------------------------------------ | ||
| 181 | |||
| 182 | //============================================================================== | ||
| 183 | /// @brief **Game audio stream properties** | ||
| 184 | /// | ||
| 185 | /// Used by Kodi to pass the currently required audio stream settings to the addon | ||
| 186 | /// | ||
| 187 | typedef struct game_stream_audio_properties | ||
| 188 | { | ||
| 189 | GAME_PCM_FORMAT format; | ||
| 190 | const GAME_AUDIO_CHANNEL* channel_map; | ||
| 191 | } ATTRIBUTE_PACKED game_stream_audio_properties; | ||
| 192 | //------------------------------------------------------------------------------ | ||
| 193 | |||
| 194 | //============================================================================== | ||
| 195 | /// @brief **Audio stream packet** | ||
| 196 | /// | ||
| 197 | /// This packet contains audio stream data passed to Kodi. | ||
| 198 | /// | ||
| 199 | typedef struct game_stream_audio_packet | ||
| 200 | { | ||
| 201 | /// @brief Pointer for audio stream data given to Kodi | ||
| 202 | const uint8_t *data; | ||
| 203 | |||
| 204 | /// @brief Size of data array | ||
| 205 | size_t size; | ||
| 206 | } ATTRIBUTE_PACKED game_stream_audio_packet; | ||
| 207 | //------------------------------------------------------------------------------ | ||
| 208 | |||
| 209 | //@} | ||
| 210 | |||
| 211 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 212 | /// \defgroup cpp_kodi_addon_game_Defs_VideoStream 2. Video stream | ||
| 213 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 214 | /// @brief **The for Video stream used data system** | ||
| 215 | /// | ||
| 216 | /// Used to give Addon currently used video stream configuration on Kodi and | ||
| 217 | /// arrays to give related data to Kodi on callbacks. | ||
| 218 | /// | ||
| 219 | //@{ | ||
| 220 | |||
| 221 | //============================================================================== | ||
| 222 | /// @brief **Pixel format** | ||
| 223 | /// | ||
| 224 | /// From Kodi requested specified video RGB color model format. | ||
| 225 | /// | ||
| 226 | typedef enum GAME_PIXEL_FORMAT | ||
| 227 | { | ||
| 228 | GAME_PIXEL_FORMAT_UNKNOWN, | ||
| 229 | |||
| 230 | /// @brief 0RGB8888 Format | ||
| 231 | GAME_PIXEL_FORMAT_0RGB8888, | ||
| 232 | |||
| 233 | /// @brief RGB565 Format | ||
| 234 | GAME_PIXEL_FORMAT_RGB565, | ||
| 235 | |||
| 236 | /// @brief 0RGB1555 Format | ||
| 237 | GAME_PIXEL_FORMAT_0RGB1555, | ||
| 238 | } GAME_PIXEL_FORMAT; | ||
| 239 | //------------------------------------------------------------------------------ | ||
| 240 | |||
| 241 | //============================================================================== | ||
| 242 | /// @brief **Video rotation position** | ||
| 243 | /// | ||
| 244 | /// To define position how video becomes shown. | ||
| 245 | /// | ||
| 246 | typedef enum GAME_VIDEO_ROTATION | ||
| 247 | { | ||
| 248 | /// @brief 0° and Without rotation | ||
| 249 | GAME_VIDEO_ROTATION_0, | ||
| 250 | |||
| 251 | /// @brief rotate 90° counterclockwise | ||
| 252 | GAME_VIDEO_ROTATION_90_CCW, | ||
| 253 | |||
| 254 | /// @brief rotate 180° counterclockwise | ||
| 255 | GAME_VIDEO_ROTATION_180_CCW, | ||
| 256 | |||
| 257 | /// @brief rotate 270° counterclockwise | ||
| 258 | GAME_VIDEO_ROTATION_270_CCW, | ||
| 259 | } GAME_VIDEO_ROTATION; | ||
| 260 | //------------------------------------------------------------------------------ | ||
| 261 | |||
| 262 | //============================================================================== | ||
| 263 | /// @brief **Game video stream properties** | ||
| 264 | /// | ||
| 265 | /// Used by Kodi to pass the currently required video stream settings to the addon | ||
| 266 | /// | ||
| 267 | typedef struct game_stream_video_properties | ||
| 268 | { | ||
| 269 | /// @brief The to used pixel format | ||
| 270 | GAME_PIXEL_FORMAT format; | ||
| 271 | |||
| 272 | /// @brief The nominal used width | ||
| 273 | unsigned int nominal_width; | ||
| 274 | |||
| 275 | /// @brief The nominal used height | ||
| 276 | unsigned int nominal_height; | ||
| 277 | |||
| 278 | /// @brief The maximal used width | ||
| 279 | unsigned int max_width; | ||
| 280 | |||
| 281 | /// @brief The maximal used height | ||
| 282 | unsigned int max_height; | ||
| 283 | |||
| 284 | /// @brief On video stream used aspect ration | ||
| 285 | /// | ||
| 286 | /// @note If aspect_ratio is <= 0.0, an aspect ratio of nominal_width / nominal_height is assumed | ||
| 287 | float aspect_ratio; | ||
| 288 | } ATTRIBUTE_PACKED game_stream_video_properties; | ||
| 289 | //------------------------------------------------------------------------------ | ||
| 290 | |||
| 291 | //============================================================================== | ||
| 292 | /// @brief **Video stream packet** | ||
| 293 | /// | ||
| 294 | /// This packet contains video stream data passed to Kodi. | ||
| 295 | /// | ||
| 296 | typedef struct game_stream_video_packet | ||
| 297 | { | ||
| 298 | /// @brief Video height | ||
| 299 | unsigned int width; | ||
| 300 | |||
| 301 | /// @brief Video width | ||
| 302 | unsigned int height; | ||
| 303 | |||
| 304 | /// @brief Width @ref GAME_VIDEO_ROTATION defined rotation angle. | ||
| 305 | GAME_VIDEO_ROTATION rotation; | ||
| 306 | |||
| 307 | /// @brief Pointer for video stream data given to Kodi | ||
| 308 | const uint8_t *data; | ||
| 309 | |||
| 310 | /// @brief Size of data array | ||
| 311 | size_t size; | ||
| 312 | } ATTRIBUTE_PACKED game_stream_video_packet; | ||
| 313 | //------------------------------------------------------------------------------ | ||
| 314 | |||
| 315 | //@} | ||
| 316 | |||
| 317 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 318 | /// \defgroup cpp_kodi_addon_game_Defs_HardwareFramebuffer 3. Hardware framebuffer stream | ||
| 319 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 320 | /// @brief **Hardware framebuffer stream data** | ||
| 321 | /// | ||
| 322 | //@{ | ||
| 323 | |||
| 324 | //============================================================================== | ||
| 325 | /// @brief **Hardware framebuffer type** | ||
| 326 | /// | ||
| 327 | typedef enum GAME_HW_CONTEXT_TYPE | ||
| 328 | { | ||
| 329 | /// @brief None context | ||
| 330 | GAME_HW_CONTEXT_NONE, | ||
| 331 | |||
| 332 | /// @brief OpenGL 2.x. Driver can choose to use latest compatibility context | ||
| 333 | GAME_HW_CONTEXT_OPENGL, | ||
| 334 | |||
| 335 | /// @brief OpenGL ES 2.0 | ||
| 336 | GAME_HW_CONTEXT_OPENGLES2, | ||
| 337 | |||
| 338 | /// @brief Modern desktop core GL context. Use major/minor fields to set GL version | ||
| 339 | GAME_HW_CONTEXT_OPENGL_CORE, | ||
| 340 | |||
| 341 | /// @brief OpenGL ES 3.0 | ||
| 342 | GAME_HW_CONTEXT_OPENGLES3, | ||
| 343 | |||
| 344 | /// @brief OpenGL ES 3.1+. Set major/minor fields. | ||
| 345 | GAME_HW_CONTEXT_OPENGLES_VERSION, | ||
| 346 | |||
| 347 | /// @brief Vulkan | ||
| 348 | GAME_HW_CONTEXT_VULKAN | ||
| 349 | } GAME_HW_CONTEXT_TYPE; | ||
| 350 | //------------------------------------------------------------------------------ | ||
| 351 | |||
| 352 | //============================================================================== | ||
| 353 | /// @brief **Hardware framebuffer properties** | ||
| 354 | /// | ||
| 355 | typedef struct game_stream_hw_framebuffer_properties | ||
| 356 | { | ||
| 357 | /// @brief The API to use. | ||
| 358 | /// | ||
| 359 | GAME_HW_CONTEXT_TYPE context_type; | ||
| 360 | |||
| 361 | /// @brief Set if render buffers should have depth component attached. | ||
| 362 | /// | ||
| 363 | /// @todo: Obsolete | ||
| 364 | /// | ||
| 365 | bool depth; | ||
| 366 | |||
| 367 | /// @brief Set if stencil buffers should be attached. | ||
| 368 | /// | ||
| 369 | /// If depth and stencil are true, a packed 24/8 buffer will be added. | ||
| 370 | /// Only attaching stencil is invalid and will be ignored. | ||
| 371 | /// | ||
| 372 | /// @todo: Obsolete. | ||
| 373 | /// | ||
| 374 | bool stencil; | ||
| 375 | |||
| 376 | /// @brief Use conventional bottom-left origin convention. | ||
| 377 | /// | ||
| 378 | /// If false, standard top-left origin semantics are used. | ||
| 379 | /// | ||
| 380 | /// @todo: Move to GL specific interface | ||
| 381 | /// | ||
| 382 | bool bottom_left_origin; | ||
| 383 | |||
| 384 | /// @brief Major version number for core GL context or GLES 3.1+. | ||
| 385 | unsigned int version_major; | ||
| 386 | |||
| 387 | /// @brief Minor version number for core GL context or GLES 3.1+. | ||
| 388 | unsigned int version_minor; | ||
| 389 | |||
| 390 | /// @brief If this is true, the frontend will go very far to avoid resetting context | ||
| 391 | /// in scenarios like toggling fullscreen, etc. | ||
| 392 | /// | ||
| 393 | /// @todo: Obsolete? Maybe frontend should just always assume this... | ||
| 394 | /// | ||
| 395 | /// The reset callback might still be called in extreme situations such as if | ||
| 396 | /// the context is lost beyond recovery. | ||
| 397 | /// | ||
| 398 | /// For optimal stability, set this to false, and allow context to be reset at | ||
| 399 | /// any time. | ||
| 400 | /// | ||
| 401 | bool cache_context; | ||
| 402 | |||
| 403 | /// @brief Creates a debug context. | ||
| 404 | bool debug_context; | ||
| 405 | } ATTRIBUTE_PACKED game_stream_hw_framebuffer_properties; | ||
| 406 | //------------------------------------------------------------------------------ | ||
| 407 | |||
| 408 | //============================================================================== | ||
| 409 | /// @brief **Hardware framebuffer buffer** | ||
| 410 | /// | ||
| 411 | typedef struct game_stream_hw_framebuffer_buffer | ||
| 412 | { | ||
| 413 | /// @brief | ||
| 414 | uintptr_t framebuffer; | ||
| 415 | } ATTRIBUTE_PACKED game_stream_hw_framebuffer_buffer; | ||
| 416 | //------------------------------------------------------------------------------ | ||
| 417 | |||
| 418 | //============================================================================== | ||
| 419 | /// @brief **Hardware framebuffer packet** | ||
| 420 | /// | ||
| 421 | typedef struct game_stream_hw_framebuffer_packet | ||
| 422 | { | ||
| 423 | /// @brief | ||
| 424 | uintptr_t framebuffer; | ||
| 425 | } ATTRIBUTE_PACKED game_stream_hw_framebuffer_packet; | ||
| 426 | //------------------------------------------------------------------------------ | ||
| 427 | |||
| 428 | //============================================================================== | ||
| 429 | /// @brief **Hardware framebuffer process function address** | ||
| 430 | /// | ||
| 431 | typedef void (*game_proc_address_t)(void); | ||
| 432 | //------------------------------------------------------------------------------ | ||
| 433 | |||
| 434 | //@} | ||
| 435 | |||
| 436 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 437 | /// \defgroup cpp_kodi_addon_game_Defs_SoftwareFramebuffer 4. Software framebuffer stream | ||
| 438 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 439 | /// @brief **Software framebuffer stream data** | ||
| 440 | /// | ||
| 441 | //@{ | ||
| 442 | |||
| 443 | //============================================================================== | ||
| 444 | /// @brief **Game video stream properties** | ||
| 445 | /// | ||
| 446 | /// Used by Kodi to pass the currently required video stream settings to the addon | ||
| 447 | /// | ||
| 448 | typedef game_stream_video_properties game_stream_sw_framebuffer_properties; | ||
| 449 | //------------------------------------------------------------------------------ | ||
| 450 | |||
| 451 | //============================================================================== | ||
| 452 | /// @brief **Hardware framebuffer type** | ||
| 453 | /// | ||
| 454 | typedef struct game_stream_sw_framebuffer_buffer | ||
| 455 | { | ||
| 456 | GAME_PIXEL_FORMAT format; | ||
| 457 | uint8_t *data; | ||
| 458 | size_t size; | ||
| 459 | } ATTRIBUTE_PACKED game_stream_sw_framebuffer_buffer; | ||
| 460 | //------------------------------------------------------------------------------ | ||
| 461 | |||
| 462 | //============================================================================== | ||
| 463 | /// @brief **Video stream packet** | ||
| 464 | /// | ||
| 465 | /// This packet contains video stream data passed to Kodi. | ||
| 466 | /// | ||
| 467 | typedef game_stream_video_packet game_stream_sw_framebuffer_packet; | ||
| 468 | //------------------------------------------------------------------------------ | ||
| 469 | |||
| 470 | //@} | ||
| 471 | |||
| 472 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 473 | /// \defgroup cpp_kodi_addon_game_Defs_StreamTypes 5. Stream types | ||
| 474 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 475 | /// @brief **Stream types data** | ||
| 476 | /// | ||
| 477 | //@{ | ||
| 478 | |||
| 479 | //============================================================================== | ||
| 480 | /// @brief **Game stream types** | ||
| 481 | /// | ||
| 482 | typedef enum GAME_STREAM_TYPE | ||
| 483 | { | ||
| 484 | /// @brief Unknown | ||
| 485 | GAME_STREAM_UNKNOWN, | ||
| 486 | |||
| 487 | /// @brief Audio stream | ||
| 488 | GAME_STREAM_AUDIO, | ||
| 489 | |||
| 490 | /// @brief Video stream | ||
| 491 | GAME_STREAM_VIDEO, | ||
| 492 | |||
| 493 | /// @brief Hardware framebuffer | ||
| 494 | GAME_STREAM_HW_FRAMEBUFFER, | ||
| 495 | |||
| 496 | /// @brief Software framebuffer | ||
| 497 | GAME_STREAM_SW_FRAMEBUFFER, | ||
| 498 | } GAME_STREAM_TYPE; | ||
| 499 | //------------------------------------------------------------------------------ | ||
| 500 | |||
| 501 | //============================================================================== | ||
| 502 | /// @brief **Immutable stream metadata** | ||
| 503 | /// | ||
| 504 | /// This metadata is provided when the stream is opened. If any stream | ||
| 505 | /// properties change, a new stream must be opened. | ||
| 506 | /// | ||
| 507 | typedef struct game_stream_properties | ||
| 508 | { | ||
| 509 | /// @brief | ||
| 510 | GAME_STREAM_TYPE type; | ||
| 511 | union | ||
| 512 | { | ||
| 513 | /// @brief | ||
| 514 | game_stream_audio_properties audio; | ||
| 515 | |||
| 516 | /// @brief | ||
| 517 | game_stream_video_properties video; | ||
| 518 | |||
| 519 | /// @brief | ||
| 520 | game_stream_hw_framebuffer_properties hw_framebuffer; | ||
| 521 | |||
| 522 | /// @brief | ||
| 523 | game_stream_sw_framebuffer_properties sw_framebuffer; | ||
| 524 | }; | ||
| 525 | } ATTRIBUTE_PACKED game_stream_properties; | ||
| 526 | //------------------------------------------------------------------------------ | ||
| 527 | |||
| 528 | //============================================================================== | ||
| 529 | /// @brief **Stream buffers for hardware rendering and zero-copy support** | ||
| 530 | /// | ||
| 531 | typedef struct game_stream_buffer | ||
| 532 | { | ||
| 533 | /// @brief | ||
| 534 | GAME_STREAM_TYPE type; | ||
| 535 | union | ||
| 536 | { | ||
| 537 | /// @brief | ||
| 538 | game_stream_hw_framebuffer_buffer hw_framebuffer; | ||
| 539 | |||
| 540 | /// @brief | ||
| 541 | game_stream_sw_framebuffer_buffer sw_framebuffer; | ||
| 542 | }; | ||
| 543 | } ATTRIBUTE_PACKED game_stream_buffer; | ||
| 544 | //------------------------------------------------------------------------------ | ||
| 545 | |||
| 546 | //============================================================================== | ||
| 547 | /// @brief **Stream packet and ephemeral metadata** | ||
| 548 | /// | ||
| 549 | /// This packet contains stream data and accompanying metadata. The metadata | ||
| 550 | /// is ephemeral, meaning it only applies to the current packet and can change | ||
| 551 | /// from packet to packet in the same stream. | ||
| 552 | /// | ||
| 553 | typedef struct game_stream_packet | ||
| 554 | { | ||
| 555 | /// @brief | ||
| 556 | GAME_STREAM_TYPE type; | ||
| 557 | union | ||
| 558 | { | ||
| 559 | /// @brief | ||
| 560 | game_stream_audio_packet audio; | ||
| 561 | |||
| 562 | /// @brief | ||
| 563 | game_stream_video_packet video; | ||
| 564 | |||
| 565 | /// @brief | ||
| 566 | game_stream_hw_framebuffer_packet hw_framebuffer; | ||
| 567 | |||
| 568 | /// @brief | ||
| 569 | game_stream_sw_framebuffer_packet sw_framebuffer; | ||
| 570 | }; | ||
| 571 | } ATTRIBUTE_PACKED game_stream_packet; | ||
| 572 | //------------------------------------------------------------------------------ | ||
| 573 | |||
| 574 | //@} | ||
| 575 | |||
| 576 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 577 | /// \defgroup cpp_kodi_addon_game_Defs_GameTypes 6. Game types | ||
| 578 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 579 | /// @brief **Game types data** | ||
| 580 | /// | ||
| 581 | //@{ | ||
| 582 | |||
| 583 | //============================================================================== | ||
| 584 | /// @brief **Game reguin definition** | ||
| 585 | /// | ||
| 586 | /// Returned from game_get_region() | ||
| 587 | typedef enum GAME_REGION | ||
| 588 | { | ||
| 589 | /// @brief Game region unknown | ||
| 590 | GAME_REGION_UNKNOWN, | ||
| 591 | |||
| 592 | /// @brief Game region NTSC | ||
| 593 | GAME_REGION_NTSC, | ||
| 594 | |||
| 595 | /// @brief Game region PAL | ||
| 596 | GAME_REGION_PAL, | ||
| 597 | } GAME_REGION; | ||
| 598 | //------------------------------------------------------------------------------ | ||
| 599 | |||
| 600 | //============================================================================== | ||
| 601 | /// @brief **Special game types passed into game_load_game_special().** | ||
| 602 | /// | ||
| 603 | /// @remark Only used when multiple ROMs are required. | ||
| 604 | /// | ||
| 605 | typedef enum SPECIAL_GAME_TYPE | ||
| 606 | { | ||
| 607 | /// @brief Game Type BSX | ||
| 608 | SPECIAL_GAME_TYPE_BSX, | ||
| 609 | |||
| 610 | /// @brief Game Type BSX slotted | ||
| 611 | SPECIAL_GAME_TYPE_BSX_SLOTTED, | ||
| 612 | |||
| 613 | /// @brief Game Type sufami turbo | ||
| 614 | SPECIAL_GAME_TYPE_SUFAMI_TURBO, | ||
| 615 | |||
| 616 | /// @brief Game Type super game boy | ||
| 617 | SPECIAL_GAME_TYPE_SUPER_GAME_BOY, | ||
| 618 | } SPECIAL_GAME_TYPE; | ||
| 619 | //------------------------------------------------------------------------------ | ||
| 620 | |||
| 621 | //============================================================================== | ||
| 622 | /// @brief **Game Memory** | ||
| 623 | /// | ||
| 624 | typedef enum GAME_MEMORY | ||
| 625 | { | ||
| 626 | /// @brief Passed to game_get_memory_data/size(). If the memory type doesn't apply | ||
| 627 | /// to the implementation NULL/0 can be returned. | ||
| 628 | GAME_MEMORY_MASK = 0xff, | ||
| 629 | |||
| 630 | /// @brief Regular save ram. | ||
| 631 | /// | ||
| 632 | /// This ram is usually found on a game cartridge, backed | ||
| 633 | /// up by a battery. If save game data is too complex for a single memory | ||
| 634 | /// buffer, the SYSTEM_DIRECTORY environment callback can be used. | ||
| 635 | GAME_MEMORY_SAVE_RAM = 0, | ||
| 636 | |||
| 637 | /// @brief Some games have a built-in clock to keep track of time. | ||
| 638 | /// | ||
| 639 | /// This memory is usually just a couple of bytes to keep track of time. | ||
| 640 | GAME_MEMORY_RTC = 1, | ||
| 641 | |||
| 642 | /// @brief System ram lets a frontend peek into a game systems main RAM | ||
| 643 | GAME_MEMORY_SYSTEM_RAM = 2, | ||
| 644 | |||
| 645 | /// @brief Video ram lets a frontend peek into a game systems video RAM (VRAM) | ||
| 646 | GAME_MEMORY_VIDEO_RAM = 3, | ||
| 647 | |||
| 648 | /// @brief Special memory type | ||
| 649 | GAME_MEMORY_SNES_BSX_RAM = ((1 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 650 | |||
| 651 | /// @brief Special memory type | ||
| 652 | GAME_MEMORY_SNES_BSX_PRAM = ((2 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 653 | |||
| 654 | /// @brief Special memory type | ||
| 655 | GAME_MEMORY_SNES_SUFAMI_TURBO_A_RAM = ((3 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 656 | |||
| 657 | /// @brief Special memory type | ||
| 658 | GAME_MEMORY_SNES_SUFAMI_TURBO_B_RAM = ((4 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 659 | |||
| 660 | /// @brief Special memory type | ||
| 661 | GAME_MEMORY_SNES_GAME_BOY_RAM = ((5 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 662 | |||
| 663 | /// @brief Special memory type | ||
| 664 | GAME_MEMORY_SNES_GAME_BOY_RTC = ((6 << 8) | GAME_MEMORY_RTC), | ||
| 665 | } GAME_MEMORY; | ||
| 666 | //------------------------------------------------------------------------------ | ||
| 667 | |||
| 668 | //============================================================================== | ||
| 669 | /// @brief **ID values for SIMD CPU features** | ||
| 670 | typedef enum GAME_SIMD | ||
| 671 | { | ||
| 672 | /// @brief SIMD CPU SSE | ||
| 673 | GAME_SIMD_SSE = (1 << 0), | ||
| 674 | |||
| 675 | /// @brief SIMD CPU SSE2 | ||
| 676 | GAME_SIMD_SSE2 = (1 << 1), | ||
| 677 | |||
| 678 | /// @brief SIMD CPU VMX | ||
| 679 | GAME_SIMD_VMX = (1 << 2), | ||
| 680 | |||
| 681 | /// @brief SIMD CPU VMX128 | ||
| 682 | GAME_SIMD_VMX128 = (1 << 3), | ||
| 683 | |||
| 684 | /// @brief SIMD CPU AVX | ||
| 685 | GAME_SIMD_AVX = (1 << 4), | ||
| 686 | |||
| 687 | /// @brief SIMD CPU NEON | ||
| 688 | GAME_SIMD_NEON = (1 << 5), | ||
| 689 | |||
| 690 | /// @brief SIMD CPU SSE3 | ||
| 691 | GAME_SIMD_SSE3 = (1 << 6), | ||
| 692 | |||
| 693 | /// @brief SIMD CPU SSSE3 | ||
| 694 | GAME_SIMD_SSSE3 = (1 << 7), | ||
| 695 | |||
| 696 | /// @brief SIMD CPU MMX | ||
| 697 | GAME_SIMD_MMX = (1 << 8), | ||
| 698 | |||
| 699 | /// @brief SIMD CPU MMXEXT | ||
| 700 | GAME_SIMD_MMXEXT = (1 << 9), | ||
| 701 | |||
| 702 | /// @brief SIMD CPU SSE4 | ||
| 703 | GAME_SIMD_SSE4 = (1 << 10), | ||
| 704 | |||
| 705 | /// @brief SIMD CPU SSE42 | ||
| 706 | GAME_SIMD_SSE42 = (1 << 11), | ||
| 707 | |||
| 708 | /// @brief SIMD CPU AVX2 | ||
| 709 | GAME_SIMD_AVX2 = (1 << 12), | ||
| 710 | |||
| 711 | /// @brief SIMD CPU VFPU | ||
| 712 | GAME_SIMD_VFPU = (1 << 13), | ||
| 713 | } GAME_SIMD; | ||
| 714 | //------------------------------------------------------------------------------ | ||
| 715 | |||
| 716 | //@} | ||
| 717 | |||
| 718 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 719 | /// \defgroup cpp_kodi_addon_game_Defs_InputTypes 7. Input types | ||
| 720 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 721 | /// @brief **Input types** | ||
| 722 | /// | ||
| 723 | //@{ | ||
| 724 | |||
| 725 | //============================================================================== | ||
| 726 | /// @brief | ||
| 727 | typedef enum GAME_INPUT_EVENT_SOURCE | ||
| 728 | { | ||
| 729 | /// @brief | ||
| 730 | GAME_INPUT_EVENT_DIGITAL_BUTTON, | ||
| 731 | |||
| 732 | /// @brief | ||
| 733 | GAME_INPUT_EVENT_ANALOG_BUTTON, | ||
| 734 | |||
| 735 | /// @brief | ||
| 736 | GAME_INPUT_EVENT_AXIS, | ||
| 737 | |||
| 738 | /// @brief | ||
| 739 | GAME_INPUT_EVENT_ANALOG_STICK, | ||
| 740 | |||
| 741 | /// @brief | ||
| 742 | GAME_INPUT_EVENT_ACCELEROMETER, | ||
| 743 | |||
| 744 | /// @brief | ||
| 745 | GAME_INPUT_EVENT_KEY, | ||
| 746 | |||
| 747 | /// @brief | ||
| 748 | GAME_INPUT_EVENT_RELATIVE_POINTER, | ||
| 749 | |||
| 750 | /// @brief | ||
| 751 | GAME_INPUT_EVENT_ABSOLUTE_POINTER, | ||
| 752 | |||
| 753 | /// @brief | ||
| 754 | GAME_INPUT_EVENT_MOTOR, | ||
| 755 | } GAME_INPUT_EVENT_SOURCE; | ||
| 756 | //------------------------------------------------------------------------------ | ||
| 757 | |||
| 758 | //============================================================================== | ||
| 759 | /// @brief | ||
| 760 | typedef enum GAME_KEY_MOD | ||
| 761 | { | ||
| 762 | /// @brief | ||
| 763 | GAME_KEY_MOD_NONE = 0x0000, | ||
| 764 | |||
| 765 | /// @brief | ||
| 766 | GAME_KEY_MOD_SHIFT = 0x0001, | ||
| 767 | |||
| 768 | /// @brief | ||
| 769 | GAME_KEY_MOD_CTRL = 0x0002, | ||
| 770 | |||
| 771 | /// @brief | ||
| 772 | GAME_KEY_MOD_ALT = 0x0004, | ||
| 773 | |||
| 774 | /// @brief | ||
| 775 | GAME_KEY_MOD_META = 0x0008, | ||
| 776 | |||
| 777 | /// @brief | ||
| 778 | GAME_KEY_MOD_SUPER = 0x0010, | ||
| 779 | |||
| 780 | /// @brief | ||
| 781 | GAME_KEY_MOD_NUMLOCK = 0x0100, | ||
| 782 | |||
| 783 | /// @brief | ||
| 784 | GAME_KEY_MOD_CAPSLOCK = 0x0200, | ||
| 785 | |||
| 786 | /// @brief | ||
| 787 | GAME_KEY_MOD_SCROLLOCK = 0x0400, | ||
| 788 | } GAME_KEY_MOD; | ||
| 789 | //------------------------------------------------------------------------------ | ||
| 790 | |||
| 791 | //============================================================================== | ||
| 792 | /// @brief Type of port on the virtual game console | ||
| 793 | typedef enum GAME_PORT_TYPE | ||
| 794 | { | ||
| 795 | /// @brief Game port unknown | ||
| 796 | GAME_PORT_UNKNOWN, | ||
| 797 | |||
| 798 | /// @brief Game port Keyboard | ||
| 799 | GAME_PORT_KEYBOARD, | ||
| 800 | |||
| 801 | /// @brief Game port mouse | ||
| 802 | GAME_PORT_MOUSE, | ||
| 803 | |||
| 804 | /// @brief Game port controller | ||
| 805 | GAME_PORT_CONTROLLER, | ||
| 806 | } GAME_PORT_TYPE; | ||
| 807 | //------------------------------------------------------------------------------ | ||
| 808 | |||
| 809 | /*! \cond PRIVATE */ | ||
| 810 | /*! | ||
| 811 | * @brief "C" Game add-on controller layout. | ||
| 812 | * | ||
| 813 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 814 | * | ||
| 815 | * See @ref AddonGameControllerLayout for description of values. | ||
| 816 | */ | ||
| 817 | typedef struct game_controller_layout | ||
| 818 | { | ||
| 819 | char* controller_id; | ||
| 820 | bool provides_input; // False for multitaps | ||
| 821 | char** digital_buttons; | ||
| 822 | unsigned int digital_button_count; | ||
| 823 | char** analog_buttons; | ||
| 824 | unsigned int analog_button_count; | ||
| 825 | char** analog_sticks; | ||
| 826 | unsigned int analog_stick_count; | ||
| 827 | char** accelerometers; | ||
| 828 | unsigned int accelerometer_count; | ||
| 829 | char** keys; | ||
| 830 | unsigned int key_count; | ||
| 831 | char** rel_pointers; | ||
| 832 | unsigned int rel_pointer_count; | ||
| 833 | char** abs_pointers; | ||
| 834 | unsigned int abs_pointer_count; | ||
| 835 | char** motors; | ||
| 836 | unsigned int motor_count; | ||
| 837 | } ATTRIBUTE_PACKED game_controller_layout; | ||
| 838 | /*! \endcond */ | ||
| 839 | |||
| 840 | //============================================================================== | ||
| 841 | /// @brief | ||
| 842 | struct AddonGameControllerLayout | ||
| 843 | { | ||
| 844 | /*! \cond PRIVATE */ | ||
| 845 | explicit AddonGameControllerLayout() = default; | ||
| 846 | AddonGameControllerLayout(const game_controller_layout& layout) | ||
| 847 | { | ||
| 848 | controller_id = layout.controller_id; | ||
| 849 | provides_input = layout.provides_input; | ||
| 850 | for (unsigned int i = 0; i < layout.digital_button_count; ++i) | ||
| 851 | digital_buttons.push_back(layout.digital_buttons[i]); | ||
| 852 | for (unsigned int i = 0; i < layout.analog_button_count; ++i) | ||
| 853 | analog_buttons.push_back(layout.analog_buttons[i]); | ||
| 854 | for (unsigned int i = 0; i < layout.analog_stick_count; ++i) | ||
| 855 | analog_sticks.push_back(layout.analog_sticks[i]); | ||
| 856 | for (unsigned int i = 0; i < layout.accelerometer_count; ++i) | ||
| 857 | accelerometers.push_back(layout.accelerometers[i]); | ||
| 858 | for (unsigned int i = 0; i < layout.key_count; ++i) | ||
| 859 | keys.push_back(layout.keys[i]); | ||
| 860 | for (unsigned int i = 0; i < layout.rel_pointer_count; ++i) | ||
| 861 | rel_pointers.push_back(layout.rel_pointers[i]); | ||
| 862 | for (unsigned int i = 0; i < layout.abs_pointer_count; ++i) | ||
| 863 | abs_pointers.push_back(layout.abs_pointers[i]); | ||
| 864 | for (unsigned int i = 0; i < layout.motor_count; ++i) | ||
| 865 | motors.push_back(layout.motors[i]); | ||
| 866 | } | ||
| 867 | /*! \endcond */ | ||
| 868 | |||
| 869 | /// @brief | ||
| 870 | std::string controller_id; | ||
| 871 | |||
| 872 | /// @brief False for multitaps | ||
| 873 | bool provides_input; | ||
| 874 | |||
| 875 | /// @brief | ||
| 876 | std::vector<std::string> digital_buttons; | ||
| 877 | |||
| 878 | /// @brief | ||
| 879 | std::vector<std::string> analog_buttons; | ||
| 880 | |||
| 881 | /// @brief | ||
| 882 | std::vector<std::string> analog_sticks; | ||
| 883 | |||
| 884 | /// @brief | ||
| 885 | std::vector<std::string> accelerometers; | ||
| 886 | |||
| 887 | /// @brief | ||
| 888 | std::vector<std::string> keys; | ||
| 889 | |||
| 890 | /// @brief | ||
| 891 | std::vector<std::string> rel_pointers; | ||
| 892 | |||
| 893 | /// @brief | ||
| 894 | std::vector<std::string> abs_pointers; | ||
| 895 | |||
| 896 | /// @brief | ||
| 897 | std::vector<std::string> motors; | ||
| 898 | }; | ||
| 899 | //------------------------------------------------------------------------------ | ||
| 900 | |||
| 901 | struct game_input_port; | ||
| 902 | |||
| 903 | //============================================================================== | ||
| 904 | /// @brief Device that can provide input | ||
| 905 | typedef struct game_input_device | ||
| 906 | { | ||
| 907 | /// @brief ID used in the Kodi controller API | ||
| 908 | const char* controller_id; | ||
| 909 | |||
| 910 | /// @brief | ||
| 911 | const char* port_address; | ||
| 912 | |||
| 913 | /// @brief | ||
| 914 | game_input_port* available_ports; | ||
| 915 | |||
| 916 | /// @brief | ||
| 917 | unsigned int port_count; | ||
| 918 | } ATTRIBUTE_PACKED game_input_device; | ||
| 919 | //------------------------------------------------------------------------------ | ||
| 920 | |||
| 921 | //============================================================================== | ||
| 922 | /// @brief Port that can provide input | ||
| 923 | /// | ||
| 924 | /// Ports can accept multiple devices and devices can have multiple ports, so | ||
| 925 | /// the topology of possible configurations is a tree structure of alternating | ||
| 926 | /// port and device nodes. | ||
| 927 | /// | ||
| 928 | typedef struct game_input_port | ||
| 929 | { | ||
| 930 | /// @brief | ||
| 931 | GAME_PORT_TYPE type; | ||
| 932 | |||
| 933 | /// @brief Required for GAME_PORT_CONTROLLER type | ||
| 934 | const char* port_id; | ||
| 935 | |||
| 936 | /// @brief | ||
| 937 | game_input_device* accepted_devices; | ||
| 938 | |||
| 939 | /// @brief | ||
| 940 | unsigned int device_count; | ||
| 941 | } ATTRIBUTE_PACKED game_input_port; | ||
| 942 | //------------------------------------------------------------------------------ | ||
| 943 | |||
| 944 | //============================================================================== | ||
| 945 | /// @brief The input topology is the possible ways to connect input devices | ||
| 946 | /// | ||
| 947 | /// This represents the logical topology, which is the possible connections that | ||
| 948 | /// the game client's logic can handle. It is strictly a subset of the physical | ||
| 949 | /// topology. Loops are not allowed. | ||
| 950 | /// | ||
| 951 | typedef struct game_input_topology | ||
| 952 | { | ||
| 953 | /// @brief The list of ports on the virtual game console | ||
| 954 | game_input_port *ports; | ||
| 955 | |||
| 956 | /// @brief The number of ports | ||
| 957 | unsigned int port_count; | ||
| 958 | |||
| 959 | /// @brief A limit on the number of input-providing devices, or -1 for no limit | ||
| 960 | int player_limit; | ||
| 961 | } ATTRIBUTE_PACKED game_input_topology; | ||
| 962 | //------------------------------------------------------------------------------ | ||
| 963 | |||
| 964 | //============================================================================== | ||
| 965 | /// @brief | ||
| 966 | typedef struct game_digital_button_event | ||
| 967 | { | ||
| 968 | /// @brief | ||
| 969 | bool pressed; | ||
| 970 | } ATTRIBUTE_PACKED game_digital_button_event; | ||
| 971 | //------------------------------------------------------------------------------ | ||
| 972 | |||
| 973 | //============================================================================== | ||
| 974 | /// @brief | ||
| 975 | typedef struct game_analog_button_event | ||
| 976 | { | ||
| 977 | /// @brief | ||
| 978 | float magnitude; | ||
| 979 | } ATTRIBUTE_PACKED game_analog_button_event; | ||
| 980 | //------------------------------------------------------------------------------ | ||
| 981 | |||
| 982 | //============================================================================== | ||
| 983 | /// @brief | ||
| 984 | typedef struct game_axis_event | ||
| 985 | { | ||
| 986 | /// @brief | ||
| 987 | float position; | ||
| 988 | } ATTRIBUTE_PACKED game_axis_event; | ||
| 989 | //------------------------------------------------------------------------------ | ||
| 990 | |||
| 991 | //============================================================================== | ||
| 992 | /// @brief | ||
| 993 | typedef struct game_analog_stick_event | ||
| 994 | { | ||
| 995 | /// @brief | ||
| 996 | float x; | ||
| 997 | |||
| 998 | /// @brief | ||
| 999 | float y; | ||
| 1000 | } ATTRIBUTE_PACKED game_analog_stick_event; | ||
| 1001 | //------------------------------------------------------------------------------ | ||
| 1002 | |||
| 1003 | //============================================================================== | ||
| 1004 | /// @brief | ||
| 1005 | typedef struct game_accelerometer_event | ||
| 1006 | { | ||
| 1007 | /// @brief | ||
| 1008 | float x; | ||
| 1009 | |||
| 1010 | /// @brief | ||
| 1011 | float y; | ||
| 1012 | |||
| 1013 | /// @brief | ||
| 1014 | float z; | ||
| 1015 | } ATTRIBUTE_PACKED game_accelerometer_event; | ||
| 1016 | //------------------------------------------------------------------------------ | ||
| 1017 | |||
| 1018 | //============================================================================== | ||
| 1019 | /// @brief | ||
| 1020 | typedef struct game_key_event | ||
| 1021 | { | ||
| 1022 | /// @brief | ||
| 1023 | bool pressed; | ||
| 1024 | |||
| 1025 | /// @brief If the keypress generates a printing character | ||
| 1026 | /// | ||
| 1027 | /// The unicode value contains the character generated. If the key is a | ||
| 1028 | /// non-printing character, e.g. a function or arrow key, the unicode value | ||
| 1029 | /// is zero. | ||
| 1030 | uint32_t unicode; | ||
| 1031 | |||
| 1032 | /// @brief | ||
| 1033 | GAME_KEY_MOD modifiers; | ||
| 1034 | } ATTRIBUTE_PACKED game_key_event; | ||
| 1035 | //------------------------------------------------------------------------------ | ||
| 1036 | |||
| 1037 | //============================================================================== | ||
| 1038 | /// @brief | ||
| 1039 | typedef struct game_rel_pointer_event | ||
| 1040 | { | ||
| 1041 | /// @brief | ||
| 1042 | int x; | ||
| 1043 | |||
| 1044 | /// @brief | ||
| 1045 | int y; | ||
| 1046 | } ATTRIBUTE_PACKED game_rel_pointer_event; | ||
| 1047 | //------------------------------------------------------------------------------ | ||
| 1048 | |||
| 1049 | //============================================================================== | ||
| 1050 | /// @brief | ||
| 1051 | typedef struct game_abs_pointer_event | ||
| 1052 | { | ||
| 1053 | /// @brief | ||
| 1054 | bool pressed; | ||
| 1055 | |||
| 1056 | /// @brief | ||
| 1057 | float x; | ||
| 1058 | |||
| 1059 | /// @brief | ||
| 1060 | float y; | ||
| 1061 | } ATTRIBUTE_PACKED game_abs_pointer_event; | ||
| 1062 | //------------------------------------------------------------------------------ | ||
| 1063 | |||
| 1064 | //============================================================================== | ||
| 1065 | /// @brief | ||
| 1066 | typedef struct game_motor_event | ||
| 1067 | { | ||
| 1068 | /// @brief | ||
| 1069 | float magnitude; | ||
| 1070 | } ATTRIBUTE_PACKED game_motor_event; | ||
| 1071 | //------------------------------------------------------------------------------ | ||
| 1072 | |||
| 1073 | //============================================================================== | ||
| 1074 | /// @brief | ||
| 1075 | typedef struct game_input_event | ||
| 1076 | { | ||
| 1077 | /// @brief | ||
| 1078 | GAME_INPUT_EVENT_SOURCE type; | ||
| 1079 | |||
| 1080 | /// @brief | ||
| 1081 | const char* controller_id; | ||
| 1082 | |||
| 1083 | /// @brief | ||
| 1084 | GAME_PORT_TYPE port_type; | ||
| 1085 | |||
| 1086 | /// @brief | ||
| 1087 | const char* port_address; | ||
| 1088 | |||
| 1089 | /// @brief | ||
| 1090 | const char* feature_name; | ||
| 1091 | union { | ||
| 1092 | /// @brief | ||
| 1093 | struct game_digital_button_event digital_button; | ||
| 1094 | |||
| 1095 | /// @brief | ||
| 1096 | struct game_analog_button_event analog_button; | ||
| 1097 | |||
| 1098 | /// @brief | ||
| 1099 | struct game_axis_event axis; | ||
| 1100 | |||
| 1101 | /// @brief | ||
| 1102 | struct game_analog_stick_event analog_stick; | ||
| 1103 | |||
| 1104 | /// @brief | ||
| 1105 | struct game_accelerometer_event accelerometer; | ||
| 1106 | |||
| 1107 | /// @brief | ||
| 1108 | struct game_key_event key; | ||
| 1109 | |||
| 1110 | /// @brief | ||
| 1111 | struct game_rel_pointer_event rel_pointer; | ||
| 1112 | |||
| 1113 | /// @brief | ||
| 1114 | struct game_abs_pointer_event abs_pointer; | ||
| 1115 | |||
| 1116 | /// @brief | ||
| 1117 | struct game_motor_event motor; | ||
| 1118 | }; | ||
| 1119 | } ATTRIBUTE_PACKED game_input_event; | ||
| 1120 | //------------------------------------------------------------------------------ | ||
| 1121 | |||
| 1122 | //@} | ||
| 1123 | |||
| 1124 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 1125 | /// \defgroup cpp_kodi_addon_game_Defs_EnvironmentTypes 8. Environment types | ||
| 1126 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 1127 | /// @brief **Environment types** | ||
| 1128 | /// | ||
| 1129 | //@{ | ||
| 1130 | |||
| 1131 | //============================================================================== | ||
| 1132 | /// @brief Game system timing | ||
| 1133 | /// | ||
| 1134 | struct game_system_timing | ||
| 1135 | { | ||
| 1136 | /// @brief FPS of video content. | ||
| 1137 | double fps; | ||
| 1138 | |||
| 1139 | /// @brief Sampling rate of audio. | ||
| 1140 | double sample_rate; | ||
| 1141 | }; | ||
| 1142 | //------------------------------------------------------------------------------ | ||
| 1143 | |||
| 1144 | //@} | ||
| 1145 | |||
| 1146 | |||
| 1147 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 1148 | |||
| 1149 | /*! | ||
| 1150 | * @brief Game properties | ||
| 1151 | * | ||
| 1152 | * Not to be used outside this header. | ||
| 1153 | */ | ||
| 1154 | typedef struct AddonProps_Game | ||
| 1155 | { | ||
| 1156 | /*! | ||
| 1157 | * The path of the game client being loaded. | ||
| 1158 | */ | ||
| 1159 | const char* game_client_dll_path; | ||
| 1160 | |||
| 1161 | /*! | ||
| 1162 | * Paths to proxy DLLs used to load the game client. | ||
| 1163 | */ | ||
| 1164 | const char** proxy_dll_paths; | ||
| 1165 | |||
| 1166 | /*! | ||
| 1167 | * Number of proxy DLL paths provided. | ||
| 1168 | */ | ||
| 1169 | unsigned int proxy_dll_count; | ||
| 1170 | |||
| 1171 | /*! | ||
| 1172 | * The "system" directories of the frontend. These directories can be used to | ||
| 1173 | * store system-specific ROMs such as BIOSes, configuration data, etc. | ||
| 1174 | */ | ||
| 1175 | const char** resource_directories; | ||
| 1176 | |||
| 1177 | /*! | ||
| 1178 | * Number of resource directories provided | ||
| 1179 | */ | ||
| 1180 | unsigned int resource_directory_count; | ||
| 1181 | |||
| 1182 | /*! | ||
| 1183 | * The writable directory of the frontend. This directory can be used to store | ||
| 1184 | * SRAM, memory cards, high scores, etc, if the game client cannot use the | ||
| 1185 | * regular memory interface, GetMemoryData(). | ||
| 1186 | */ | ||
| 1187 | const char* profile_directory; | ||
| 1188 | |||
| 1189 | /*! | ||
| 1190 | * The value of the <supports_vfs> property from addon.xml | ||
| 1191 | */ | ||
| 1192 | bool supports_vfs; | ||
| 1193 | |||
| 1194 | /*! | ||
| 1195 | * The extensions in the <extensions> property from addon.xml | ||
| 1196 | */ | ||
| 1197 | const char** extensions; | ||
| 1198 | |||
| 1199 | /*! | ||
| 1200 | * Number of extensions provided | ||
| 1201 | */ | ||
| 1202 | unsigned int extension_count; | ||
| 1203 | } AddonProps_Game; | ||
| 1204 | |||
| 1205 | typedef AddonProps_Game game_client_properties; | ||
| 1206 | |||
| 1207 | /*! Structure to transfer the methods from kodi_game_dll.h to Kodi */ | ||
| 1208 | |||
| 1209 | struct AddonInstance_Game; | ||
| 1210 | |||
| 1211 | /*! | ||
| 1212 | * @brief Game callbacks | ||
| 1213 | * | ||
| 1214 | * Not to be used outside this header. | ||
| 1215 | */ | ||
| 1216 | typedef struct AddonToKodiFuncTable_Game | ||
| 1217 | { | ||
| 1218 | KODI_HANDLE kodiInstance; | ||
| 1219 | |||
| 1220 | void (*CloseGame)(void* kodiInstance); | ||
| 1221 | void* (*OpenStream)(void*, const game_stream_properties*); | ||
| 1222 | bool (*GetStreamBuffer)(void*, void*, unsigned int, unsigned int, game_stream_buffer*); | ||
| 1223 | void (*AddStreamData)(void*, void*, const game_stream_packet*); | ||
| 1224 | void (*ReleaseStreamBuffer)(void*, void*, game_stream_buffer*); | ||
| 1225 | void (*CloseStream)(void*, void*); | ||
| 1226 | game_proc_address_t (*HwGetProcAddress)(void* kodiInstance, const char* symbol); | ||
| 1227 | bool (*InputEvent)(void* kodiInstance, const game_input_event* event); | ||
| 1228 | } AddonToKodiFuncTable_Game; | ||
| 1229 | |||
| 1230 | /*! | ||
| 1231 | * @brief Game function hooks | ||
| 1232 | * | ||
| 1233 | * Not to be used outside this header. | ||
| 1234 | */ | ||
| 1235 | typedef struct KodiToAddonFuncTable_Game | ||
| 1236 | { | ||
| 1237 | kodi::addon::CInstanceGame* addonInstance; | ||
| 1238 | |||
| 1239 | GAME_ERROR(__cdecl* LoadGame)(const AddonInstance_Game*, const char*); | ||
| 1240 | GAME_ERROR(__cdecl* LoadGameSpecial) | ||
| 1241 | (const AddonInstance_Game*, SPECIAL_GAME_TYPE, const char**, size_t); | ||
| 1242 | GAME_ERROR(__cdecl* LoadStandalone)(const AddonInstance_Game*); | ||
| 1243 | GAME_ERROR(__cdecl* UnloadGame)(const AddonInstance_Game*); | ||
| 1244 | GAME_ERROR(__cdecl* GetGameTiming)(const AddonInstance_Game*, game_system_timing*); | ||
| 1245 | GAME_REGION(__cdecl* GetRegion)(const AddonInstance_Game*); | ||
| 1246 | bool(__cdecl* RequiresGameLoop)(const AddonInstance_Game*); | ||
| 1247 | GAME_ERROR(__cdecl* RunFrame)(const AddonInstance_Game*); | ||
| 1248 | GAME_ERROR(__cdecl* Reset)(const AddonInstance_Game*); | ||
| 1249 | GAME_ERROR(__cdecl* HwContextReset)(const AddonInstance_Game*); | ||
| 1250 | GAME_ERROR(__cdecl* HwContextDestroy)(const AddonInstance_Game*); | ||
| 1251 | bool(__cdecl* HasFeature)(const AddonInstance_Game*, const char*, const char*); | ||
| 1252 | game_input_topology*(__cdecl* GetTopology)(const AddonInstance_Game*); | ||
| 1253 | void(__cdecl* FreeTopology)(const AddonInstance_Game*, game_input_topology*); | ||
| 1254 | void(__cdecl* SetControllerLayouts)(const AddonInstance_Game*, | ||
| 1255 | const game_controller_layout*, | ||
| 1256 | unsigned int); | ||
| 1257 | bool(__cdecl* EnableKeyboard)(const AddonInstance_Game*, bool, const char*); | ||
| 1258 | bool(__cdecl* EnableMouse)(const AddonInstance_Game*, bool, const char*); | ||
| 1259 | bool(__cdecl* ConnectController)(const AddonInstance_Game*, bool, const char*, const char*); | ||
| 1260 | bool(__cdecl* InputEvent)(const AddonInstance_Game*, const game_input_event*); | ||
| 1261 | size_t(__cdecl* SerializeSize)(const AddonInstance_Game*); | ||
| 1262 | GAME_ERROR(__cdecl* Serialize)(const AddonInstance_Game*, uint8_t*, size_t); | ||
| 1263 | GAME_ERROR(__cdecl* Deserialize)(const AddonInstance_Game*, const uint8_t*, size_t); | ||
| 1264 | GAME_ERROR(__cdecl* CheatReset)(const AddonInstance_Game*); | ||
| 1265 | GAME_ERROR(__cdecl* GetMemory)(const AddonInstance_Game*, GAME_MEMORY, uint8_t**, size_t*); | ||
| 1266 | GAME_ERROR(__cdecl* SetCheat)(const AddonInstance_Game*, unsigned int, bool, const char*); | ||
| 1267 | } KodiToAddonFuncTable_Game; | ||
| 1268 | |||
| 1269 | /*! | ||
| 1270 | * @brief Game instance | ||
| 1271 | * | ||
| 1272 | * Not to be used outside this header. | ||
| 1273 | */ | ||
| 1274 | typedef struct AddonInstance_Game | ||
| 1275 | { | ||
| 1276 | AddonProps_Game props; | ||
| 1277 | AddonToKodiFuncTable_Game toKodi; | ||
| 1278 | KodiToAddonFuncTable_Game toAddon; | ||
| 1279 | } AddonInstance_Game; | ||
| 1280 | |||
| 1281 | } /* extern "C" */ | ||
| 1282 | |||
| 1283 | namespace kodi | ||
| 1284 | { | ||
| 1285 | namespace addon | ||
| 1286 | { | ||
| 1287 | |||
| 1288 | //============================================================================== | ||
| 1289 | /// | ||
| 1290 | /// \addtogroup cpp_kodi_addon_game | ||
| 1291 | /// @brief \cpp_class{ kodi::addon::CInstanceGame } | ||
| 1292 | /// **Game add-on instance** | ||
| 1293 | /// | ||
| 1294 | /// This class is created at addon by Kodi. | ||
| 1295 | /// | ||
| 1296 | //------------------------------------------------------------------------------ | ||
| 1297 | class ATTRIBUTE_HIDDEN CInstanceGame : public IAddonInstance | ||
| 1298 | { | ||
| 1299 | public: | ||
| 1300 | //============================================================================ | ||
| 1301 | /// | ||
| 1302 | /// @defgroup cpp_kodi_addon_game_Base 1. Basic functions | ||
| 1303 | /// @ingroup cpp_kodi_addon_game | ||
| 1304 | /// @brief **Functions to manage the addon and get basic information about it** | ||
| 1305 | /// | ||
| 1306 | /// | ||
| 1307 | //@{ | ||
| 1308 | |||
| 1309 | //============================================================================ | ||
| 1310 | /// | ||
| 1311 | /// @brief Game class constructor | ||
| 1312 | /// | ||
| 1313 | /// Used by an add-on that only supports only Game and only in one instance. | ||
| 1314 | /// | ||
| 1315 | /// This class is created at addon by Kodi. | ||
| 1316 | /// | ||
| 1317 | /// | ||
| 1318 | /// -------------------------------------------------------------------------- | ||
| 1319 | /// | ||
| 1320 | /// | ||
| 1321 | /// **Here's example about the use of this:** | ||
| 1322 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1323 | /// #include <kodi/addon-instance/Game.h> | ||
| 1324 | /// ... | ||
| 1325 | /// | ||
| 1326 | /// class ATTRIBUTE_HIDDEN CGameExample | ||
| 1327 | /// : public kodi::addon::CAddonBase, | ||
| 1328 | /// public kodi::addon::CInstanceGame | ||
| 1329 | /// { | ||
| 1330 | /// public: | ||
| 1331 | /// CGameExample() | ||
| 1332 | /// { | ||
| 1333 | /// } | ||
| 1334 | /// | ||
| 1335 | /// virtual ~CGameExample(); | ||
| 1336 | /// { | ||
| 1337 | /// } | ||
| 1338 | /// | ||
| 1339 | /// ... | ||
| 1340 | /// }; | ||
| 1341 | /// | ||
| 1342 | /// ADDONCREATOR(CGameExample) | ||
| 1343 | /// ~~~~~~~~~~~~~ | ||
| 1344 | /// | ||
| 1345 | CInstanceGame() : IAddonInstance(ADDON_INSTANCE_GAME, GetKodiTypeVersion(ADDON_INSTANCE_GAME)) | ||
| 1346 | { | ||
| 1347 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 1348 | throw std::logic_error("kodi::addon::CInstanceGame: Creation of more as one in single " | ||
| 1349 | "instance way is not allowed!"); | ||
| 1350 | |||
| 1351 | SetAddonStruct(CAddonBase::m_interface->firstKodiInstance); | ||
| 1352 | CAddonBase::m_interface->globalSingleInstance = this; | ||
| 1353 | } | ||
| 1354 | //---------------------------------------------------------------------------- | ||
| 1355 | |||
| 1356 | //============================================================================ | ||
| 1357 | /// | ||
| 1358 | /// @brief Destructor | ||
| 1359 | /// | ||
| 1360 | ~CInstanceGame() override = default; | ||
| 1361 | //---------------------------------------------------------------------------- | ||
| 1362 | |||
| 1363 | //============================================================================ | ||
| 1364 | /// | ||
| 1365 | /// @brief **Callback to Kodi Function**<br>The path of the game client being loaded. | ||
| 1366 | /// | ||
| 1367 | /// @return the used game client Dll path | ||
| 1368 | /// | ||
| 1369 | /// @remarks Only called from addon itself | ||
| 1370 | /// | ||
| 1371 | std::string GameClientDllPath() const | ||
| 1372 | { | ||
| 1373 | return m_instanceData->props.game_client_dll_path; | ||
| 1374 | } | ||
| 1375 | //---------------------------------------------------------------------------- | ||
| 1376 | |||
| 1377 | //============================================================================ | ||
| 1378 | /// | ||
| 1379 | /// @brief **Callback to Kodi Function**<br>Paths to proxy DLLs used to load the game client. | ||
| 1380 | /// | ||
| 1381 | /// @param[out] paths vector list to store available dll paths | ||
| 1382 | /// @return true if success and dll paths present | ||
| 1383 | /// | ||
| 1384 | /// @remarks Only called from addon itself | ||
| 1385 | /// | ||
| 1386 | bool ProxyDllPaths(std::vector<std::string>& paths) | ||
| 1387 | { | ||
| 1388 | for (unsigned int i = 0; i < m_instanceData->props.proxy_dll_count; ++i) | ||
| 1389 | { | ||
| 1390 | if (m_instanceData->props.proxy_dll_paths[i] != nullptr) | ||
| 1391 | paths.push_back(m_instanceData->props.proxy_dll_paths[i]); | ||
| 1392 | } | ||
| 1393 | return !paths.empty(); | ||
| 1394 | } | ||
| 1395 | //---------------------------------------------------------------------------- | ||
| 1396 | |||
| 1397 | //============================================================================ | ||
| 1398 | /// | ||
| 1399 | /// @brief **Callback to Kodi Function**<br>The "system" directories of the frontend | ||
| 1400 | /// | ||
| 1401 | /// These directories can be used to store system-specific ROMs such as | ||
| 1402 | /// BIOSes, configuration data, etc. | ||
| 1403 | /// | ||
| 1404 | /// @return the used resource directory | ||
| 1405 | /// | ||
| 1406 | /// @remarks Only called from addon itself | ||
| 1407 | /// | ||
| 1408 | bool ResourceDirectories(std::vector<std::string>& dirs) | ||
| 1409 | { | ||
| 1410 | for (unsigned int i = 0; i < m_instanceData->props.resource_directory_count; ++i) | ||
| 1411 | { | ||
| 1412 | if (m_instanceData->props.resource_directories[i] != nullptr) | ||
| 1413 | dirs.push_back(m_instanceData->props.resource_directories[i]); | ||
| 1414 | } | ||
| 1415 | return !dirs.empty(); | ||
| 1416 | } | ||
| 1417 | //---------------------------------------------------------------------------- | ||
| 1418 | |||
| 1419 | //============================================================================ | ||
| 1420 | /// | ||
| 1421 | /// @brief **Callback to Kodi Function**<br>The writable directory of the frontend | ||
| 1422 | /// | ||
| 1423 | /// This directory can be used to store SRAM, memory cards, high scores, | ||
| 1424 | /// etc, if the game client cannot use the regular memory interface, | ||
| 1425 | /// GetMemoryData(). | ||
| 1426 | /// | ||
| 1427 | /// @return the used profile directory | ||
| 1428 | /// | ||
| 1429 | /// @remarks Only called from addon itself | ||
| 1430 | /// | ||
| 1431 | std::string ProfileDirectory() const | ||
| 1432 | { | ||
| 1433 | return m_instanceData->props.profile_directory; | ||
| 1434 | } | ||
| 1435 | //---------------------------------------------------------------------------- | ||
| 1436 | |||
| 1437 | //============================================================================ | ||
| 1438 | /// | ||
| 1439 | /// @brief **Callback to Kodi Function**<br>The value of the <supports_vfs> property from addon.xml | ||
| 1440 | /// | ||
| 1441 | /// @return true if VFS is supported | ||
| 1442 | /// | ||
| 1443 | /// @remarks Only called from addon itself | ||
| 1444 | /// | ||
| 1445 | bool SupportsVFS() const | ||
| 1446 | { | ||
| 1447 | return m_instanceData->props.supports_vfs; | ||
| 1448 | } | ||
| 1449 | //---------------------------------------------------------------------------- | ||
| 1450 | |||
| 1451 | //============================================================================ | ||
| 1452 | /// | ||
| 1453 | /// @brief **Callback to Kodi Function**<br>The extensions in the <extensions> property from addon.xml | ||
| 1454 | /// | ||
| 1455 | /// @param[out] extensions vector list to store available extension | ||
| 1456 | /// @return true if success and extensions present | ||
| 1457 | /// | ||
| 1458 | /// @remarks Only called from addon itself | ||
| 1459 | /// | ||
| 1460 | bool Extensions(std::vector<std::string>& extensions) | ||
| 1461 | { | ||
| 1462 | for (unsigned int i = 0; i < m_instanceData->props.extension_count; ++i) | ||
| 1463 | { | ||
| 1464 | if (m_instanceData->props.extensions[i] != nullptr) | ||
| 1465 | extensions.push_back(m_instanceData->props.extensions[i]); | ||
| 1466 | } | ||
| 1467 | return !extensions.empty(); | ||
| 1468 | } | ||
| 1469 | //---------------------------------------------------------------------------- | ||
| 1470 | |||
| 1471 | //@} | ||
| 1472 | |||
| 1473 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 1474 | |||
| 1475 | //============================================================================ | ||
| 1476 | /// | ||
| 1477 | /// @defgroup cpp_kodi_addon_game_Operation 2. Game operations | ||
| 1478 | /// @ingroup cpp_kodi_addon_game | ||
| 1479 | /// @brief **Game operations** | ||
| 1480 | /// | ||
| 1481 | /// These are mandatory functions for using this addon to get the available | ||
| 1482 | /// channels. | ||
| 1483 | /// | ||
| 1484 | //@{ | ||
| 1485 | |||
| 1486 | //============================================================================ | ||
| 1487 | /// | ||
| 1488 | /// @brief Load a game | ||
| 1489 | /// | ||
| 1490 | /// @param[in] url The URL to load | ||
| 1491 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was loaded | ||
| 1492 | /// | ||
| 1493 | virtual GAME_ERROR LoadGame(const std::string& url) | ||
| 1494 | { | ||
| 1495 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1496 | } | ||
| 1497 | //---------------------------------------------------------------------------- | ||
| 1498 | |||
| 1499 | //============================================================================ | ||
| 1500 | /// | ||
| 1501 | /// @brief Load a game that requires multiple files | ||
| 1502 | /// | ||
| 1503 | /// @param[in] type The game type | ||
| 1504 | /// @param[in] urls An array of urls | ||
| 1505 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was loaded | ||
| 1506 | /// | ||
| 1507 | virtual GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const std::vector<std::string>& urls) | ||
| 1508 | { | ||
| 1509 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1510 | } | ||
| 1511 | //---------------------------------------------------------------------------- | ||
| 1512 | |||
| 1513 | //============================================================================ | ||
| 1514 | /// | ||
| 1515 | /// @brief Begin playing without a game file | ||
| 1516 | /// | ||
| 1517 | /// If the add-on supports standalone mode, it must add the <supports_standalone> | ||
| 1518 | /// tag to the extension point in addon.xml: | ||
| 1519 | /// | ||
| 1520 | /// <supports_no_game>false</supports_no_game> | ||
| 1521 | /// | ||
| 1522 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game add-on was loaded | ||
| 1523 | /// | ||
| 1524 | virtual GAME_ERROR LoadStandalone() | ||
| 1525 | { | ||
| 1526 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1527 | } | ||
| 1528 | //---------------------------------------------------------------------------- | ||
| 1529 | |||
| 1530 | //============================================================================ | ||
| 1531 | /// | ||
| 1532 | /// @brief Unload the current game | ||
| 1533 | /// | ||
| 1534 | /// Unloads a currently loaded game | ||
| 1535 | /// | ||
| 1536 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was unloaded | ||
| 1537 | /// | ||
| 1538 | virtual GAME_ERROR UnloadGame() | ||
| 1539 | { | ||
| 1540 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1541 | } | ||
| 1542 | //---------------------------------------------------------------------------- | ||
| 1543 | |||
| 1544 | //============================================================================ | ||
| 1545 | /// | ||
| 1546 | /// @brief Get timing information about the loaded game | ||
| 1547 | /// | ||
| 1548 | /// @param[out] timing_info The info structure to fill | ||
| 1549 | /// | ||
| 1550 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if info was filled | ||
| 1551 | /// | ||
| 1552 | virtual GAME_ERROR GetGameTiming(game_system_timing& timing_info) | ||
| 1553 | { | ||
| 1554 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1555 | } | ||
| 1556 | //---------------------------------------------------------------------------- | ||
| 1557 | |||
| 1558 | //============================================================================ | ||
| 1559 | /// | ||
| 1560 | /// @brief Get region of the loaded game | ||
| 1561 | /// | ||
| 1562 | /// @return the region, or @ref GAME_REGION_UNKNOWN if unknown or no game is loaded | ||
| 1563 | /// | ||
| 1564 | virtual GAME_REGION GetRegion() | ||
| 1565 | { | ||
| 1566 | return GAME_REGION_UNKNOWN; | ||
| 1567 | } | ||
| 1568 | //---------------------------------------------------------------------------- | ||
| 1569 | |||
| 1570 | //============================================================================ | ||
| 1571 | /// | ||
| 1572 | /// @brief Return true if the client requires the frontend to provide a game loop | ||
| 1573 | /// | ||
| 1574 | /// The game loop is a thread that calls RunFrame() in a loop at a rate | ||
| 1575 | /// determined by the playback speed and the client's FPS. | ||
| 1576 | /// | ||
| 1577 | /// @return true if the frontend should provide a game loop, false otherwise | ||
| 1578 | /// | ||
| 1579 | virtual bool RequiresGameLoop() | ||
| 1580 | { | ||
| 1581 | return false; | ||
| 1582 | } | ||
| 1583 | //---------------------------------------------------------------------------- | ||
| 1584 | |||
| 1585 | //============================================================================ | ||
| 1586 | /// | ||
| 1587 | /// @brief Run a single frame for add-ons that use a game loop | ||
| 1588 | /// | ||
| 1589 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if there was no error | ||
| 1590 | /// | ||
| 1591 | virtual GAME_ERROR RunFrame() | ||
| 1592 | { | ||
| 1593 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1594 | } | ||
| 1595 | //---------------------------------------------------------------------------- | ||
| 1596 | |||
| 1597 | //============================================================================ | ||
| 1598 | /// | ||
| 1599 | /// @brief Reset the current game | ||
| 1600 | /// | ||
| 1601 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was reset | ||
| 1602 | /// | ||
| 1603 | virtual GAME_ERROR Reset() | ||
| 1604 | { | ||
| 1605 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1606 | } | ||
| 1607 | //---------------------------------------------------------------------------- | ||
| 1608 | |||
| 1609 | //========================================================================== | ||
| 1610 | /// | ||
| 1611 | /// @brief **Callback to Kodi Function**<br>Requests the frontend to stop the current game | ||
| 1612 | /// | ||
| 1613 | /// @remarks Only called from addon itself | ||
| 1614 | /// | ||
| 1615 | void CloseGame(void) { m_instanceData->toKodi.CloseGame(m_instanceData->toKodi.kodiInstance); } | ||
| 1616 | //---------------------------------------------------------------------------- | ||
| 1617 | |||
| 1618 | //============================================================================ | ||
| 1619 | /// | ||
| 1620 | /// @defgroup cpp_kodi_addon_game_Operation_CStream Class: CStream | ||
| 1621 | /// @ingroup cpp_kodi_addon_game_Operation | ||
| 1622 | /// @brief \cpp_class{ kodi::addon::CInstanceGame::CStream } | ||
| 1623 | /// **Game stream handler** | ||
| 1624 | /// | ||
| 1625 | /// This class will be integrated into the addon, which can then open it if | ||
| 1626 | /// necessary for the processing of an audio or video stream. | ||
| 1627 | /// | ||
| 1628 | /// | ||
| 1629 | /// @note Callback to Kodi class | ||
| 1630 | //@{ | ||
| 1631 | class CStream | ||
| 1632 | { | ||
| 1633 | public: | ||
| 1634 | CStream() = default; | ||
| 1635 | |||
| 1636 | CStream(const game_stream_properties& properties) | ||
| 1637 | { | ||
| 1638 | Open(properties); | ||
| 1639 | } | ||
| 1640 | |||
| 1641 | ~CStream() | ||
| 1642 | { | ||
| 1643 | Close(); | ||
| 1644 | } | ||
| 1645 | |||
| 1646 | //========================================================================== | ||
| 1647 | /// | ||
| 1648 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 1649 | /// @brief Create a stream for gameplay data | ||
| 1650 | /// | ||
| 1651 | /// @param[in] properties The stream properties | ||
| 1652 | /// @return A stream handle, or `nullptr` on failure | ||
| 1653 | /// | ||
| 1654 | /// @remarks Only called from addon itself | ||
| 1655 | /// | ||
| 1656 | bool Open(const game_stream_properties& properties) | ||
| 1657 | { | ||
| 1658 | if (!CAddonBase::m_interface->globalSingleInstance) | ||
| 1659 | return false; | ||
| 1660 | |||
| 1661 | if (m_handle) | ||
| 1662 | { | ||
| 1663 | kodi::Log(ADDON_LOG_INFO, "kodi::addon::CInstanceGame::CStream already becomes reopened"); | ||
| 1664 | Close(); | ||
| 1665 | } | ||
| 1666 | |||
| 1667 | AddonToKodiFuncTable_Game& cb = | ||
| 1668 | static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 1669 | ->m_instanceData->toKodi; | ||
| 1670 | m_handle = cb.OpenStream(cb.kodiInstance, &properties); | ||
| 1671 | return m_handle != nullptr; | ||
| 1672 | } | ||
| 1673 | //-------------------------------------------------------------------------- | ||
| 1674 | |||
| 1675 | //========================================================================== | ||
| 1676 | /// | ||
| 1677 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 1678 | /// @brief Free the specified stream | ||
| 1679 | /// | ||
| 1680 | /// @remarks Only called from addon itself | ||
| 1681 | /// | ||
| 1682 | void Close() | ||
| 1683 | { | ||
| 1684 | if (!m_handle || !CAddonBase::m_interface->globalSingleInstance) | ||
| 1685 | return; | ||
| 1686 | |||
| 1687 | AddonToKodiFuncTable_Game& cb = | ||
| 1688 | static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 1689 | ->m_instanceData->toKodi; | ||
| 1690 | cb.CloseStream(cb.kodiInstance, m_handle); | ||
| 1691 | m_handle = nullptr; | ||
| 1692 | } | ||
| 1693 | //-------------------------------------------------------------------------- | ||
| 1694 | |||
| 1695 | //========================================================================== | ||
| 1696 | /// | ||
| 1697 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 1698 | /// @brief Get a buffer for zero-copy stream data | ||
| 1699 | /// | ||
| 1700 | /// @param[in] width The framebuffer width, or 0 for no width specified | ||
| 1701 | /// @param[in] height The framebuffer height, or 0 for no height specified | ||
| 1702 | /// @param[out] buffer The buffer, or unmodified if false is returned | ||
| 1703 | /// @return True if buffer was set, false otherwise | ||
| 1704 | /// | ||
| 1705 | /// @note If this returns true, buffer must be freed using \ref ReleaseBuffer(). | ||
| 1706 | /// | ||
| 1707 | /// @remarks Only called from addon itself | ||
| 1708 | /// | ||
| 1709 | bool GetBuffer(unsigned int width, unsigned int height, game_stream_buffer& buffer) | ||
| 1710 | { | ||
| 1711 | if (!m_handle || !CAddonBase::m_interface->globalSingleInstance) | ||
| 1712 | return false; | ||
| 1713 | |||
| 1714 | AddonToKodiFuncTable_Game& cb = | ||
| 1715 | static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 1716 | ->m_instanceData->toKodi; | ||
| 1717 | return cb.GetStreamBuffer(cb.kodiInstance, m_handle, width, height, &buffer); | ||
| 1718 | } | ||
| 1719 | //-------------------------------------------------------------------------- | ||
| 1720 | |||
| 1721 | //========================================================================== | ||
| 1722 | /// | ||
| 1723 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 1724 | /// @brief Add a data packet to a stream | ||
| 1725 | /// | ||
| 1726 | /// @param[in] packet The data packet | ||
| 1727 | /// | ||
| 1728 | /// @remarks Only called from addon itself | ||
| 1729 | /// | ||
| 1730 | void AddData(const game_stream_packet& packet) | ||
| 1731 | { | ||
| 1732 | if (!m_handle || !CAddonBase::m_interface->globalSingleInstance) | ||
| 1733 | return; | ||
| 1734 | |||
| 1735 | AddonToKodiFuncTable_Game& cb = | ||
| 1736 | static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 1737 | ->m_instanceData->toKodi; | ||
| 1738 | cb.AddStreamData(cb.kodiInstance, m_handle, &packet); | ||
| 1739 | } | ||
| 1740 | //-------------------------------------------------------------------------- | ||
| 1741 | |||
| 1742 | //========================================================================== | ||
| 1743 | /// | ||
| 1744 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 1745 | /// @brief Free an allocated buffer | ||
| 1746 | /// | ||
| 1747 | /// @param[in] buffer The buffer returned from GetStreamBuffer() | ||
| 1748 | /// | ||
| 1749 | /// @remarks Only called from addon itself | ||
| 1750 | /// | ||
| 1751 | void ReleaseBuffer(game_stream_buffer& buffer) | ||
| 1752 | { | ||
| 1753 | if (!m_handle || !CAddonBase::m_interface->globalSingleInstance) | ||
| 1754 | return; | ||
| 1755 | |||
| 1756 | AddonToKodiFuncTable_Game& cb = | ||
| 1757 | static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 1758 | ->m_instanceData->toKodi; | ||
| 1759 | cb.ReleaseStreamBuffer(cb.kodiInstance, m_handle, &buffer); | ||
| 1760 | } | ||
| 1761 | //-------------------------------------------------------------------------- | ||
| 1762 | |||
| 1763 | //========================================================================== | ||
| 1764 | /// | ||
| 1765 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 1766 | /// @brief To check stream open was OK, e.g. after use of constructor | ||
| 1767 | /// | ||
| 1768 | /// @return true if stream was successfully opened | ||
| 1769 | /// | ||
| 1770 | /// @remarks Only called from addon itself | ||
| 1771 | /// | ||
| 1772 | bool IsOpen() const { return m_handle != nullptr; } | ||
| 1773 | //-------------------------------------------------------------------------- | ||
| 1774 | |||
| 1775 | private: | ||
| 1776 | void* m_handle = nullptr; | ||
| 1777 | }; | ||
| 1778 | //@} | ||
| 1779 | |||
| 1780 | //@} | ||
| 1781 | |||
| 1782 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 1783 | |||
| 1784 | //============================================================================ | ||
| 1785 | /// | ||
| 1786 | /// @defgroup cpp_kodi_addon_game_HardwareRendering 3. Hardware rendering operations | ||
| 1787 | /// @ingroup cpp_kodi_addon_game | ||
| 1788 | /// @brief **Hardware rendering operations** | ||
| 1789 | /// | ||
| 1790 | //@{ | ||
| 1791 | |||
| 1792 | //============================================================================ | ||
| 1793 | /// | ||
| 1794 | /// @brief Invalidates the current HW context and reinitializes GPU resources | ||
| 1795 | /// | ||
| 1796 | /// Any GL state is lost, and must not be deinitialized explicitly. | ||
| 1797 | /// | ||
| 1798 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the HW context was reset | ||
| 1799 | /// | ||
| 1800 | virtual GAME_ERROR HwContextReset() | ||
| 1801 | { | ||
| 1802 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1803 | } | ||
| 1804 | //---------------------------------------------------------------------------- | ||
| 1805 | |||
| 1806 | //============================================================================ | ||
| 1807 | /// | ||
| 1808 | /// @brief Called before the context is destroyed | ||
| 1809 | /// | ||
| 1810 | /// Resources can be deinitialized at this step. | ||
| 1811 | /// | ||
| 1812 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the HW context was destroyed | ||
| 1813 | /// | ||
| 1814 | virtual GAME_ERROR HwContextDestroy() | ||
| 1815 | { | ||
| 1816 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1817 | } | ||
| 1818 | |||
| 1819 | //============================================================================ | ||
| 1820 | /// | ||
| 1821 | /// @brief **Callback to Kodi Function**<br>Get a symbol from the hardware context | ||
| 1822 | /// | ||
| 1823 | /// @param[in] sym The symbol's name | ||
| 1824 | /// | ||
| 1825 | /// @return A function pointer for the specified symbol | ||
| 1826 | /// | ||
| 1827 | /// @remarks Only called from addon itself | ||
| 1828 | /// | ||
| 1829 | game_proc_address_t HwGetProcAddress(const char* sym) | ||
| 1830 | { | ||
| 1831 | return m_instanceData->toKodi.HwGetProcAddress(m_instanceData->toKodi.kodiInstance, sym); | ||
| 1832 | } | ||
| 1833 | //---------------------------------------------------------------------------- | ||
| 1834 | |||
| 1835 | //@} | ||
| 1836 | |||
| 1837 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 1838 | |||
| 1839 | //============================================================================ | ||
| 1840 | /// | ||
| 1841 | /// @defgroup cpp_kodi_addon_game_InputOperations 4. Input operations | ||
| 1842 | /// @ingroup cpp_kodi_addon_game | ||
| 1843 | /// @brief **Input operations** | ||
| 1844 | /// | ||
| 1845 | //@{ | ||
| 1846 | |||
| 1847 | //============================================================================ | ||
| 1848 | /// | ||
| 1849 | /// @brief Check if input is accepted for a feature on the controller | ||
| 1850 | /// | ||
| 1851 | /// If only a subset of the controller profile is used, this can return false | ||
| 1852 | /// for unsupported features to not absorb their input. | ||
| 1853 | /// | ||
| 1854 | /// If the entire controller profile is used, this should always return true. | ||
| 1855 | /// | ||
| 1856 | /// @param[in] controller_id The ID of the controller profile | ||
| 1857 | /// @param[in] feature_name The name of a feature in that profile | ||
| 1858 | /// @return true if input is accepted for the feature, false otherwise | ||
| 1859 | /// | ||
| 1860 | virtual bool HasFeature(const std::string& controller_id, const std::string& feature_name) | ||
| 1861 | { | ||
| 1862 | return false; | ||
| 1863 | } | ||
| 1864 | //---------------------------------------------------------------------------- | ||
| 1865 | |||
| 1866 | //============================================================================ | ||
| 1867 | /// | ||
| 1868 | /// @brief Get the input topology that specifies which controllers can be connected | ||
| 1869 | /// | ||
| 1870 | /// @return The input topology, or null to use the default | ||
| 1871 | /// | ||
| 1872 | /// If this returns non-null, topology must be freed using FreeTopology(). | ||
| 1873 | /// | ||
| 1874 | /// If this returns null, the topology will default to a single port that can | ||
| 1875 | /// accept all controllers imported by addon.xml. The port ID is set to | ||
| 1876 | /// the @ref DEFAULT_PORT_ID constant. | ||
| 1877 | /// | ||
| 1878 | virtual game_input_topology* GetTopology() | ||
| 1879 | { | ||
| 1880 | return nullptr; | ||
| 1881 | } | ||
| 1882 | //---------------------------------------------------------------------------- | ||
| 1883 | |||
| 1884 | //============================================================================ | ||
| 1885 | /// | ||
| 1886 | /// @brief Free the topology's resources | ||
| 1887 | /// | ||
| 1888 | /// @param[in] topology The topology returned by GetTopology() | ||
| 1889 | /// | ||
| 1890 | virtual void FreeTopology(game_input_topology* topology) | ||
| 1891 | { | ||
| 1892 | } | ||
| 1893 | //---------------------------------------------------------------------------- | ||
| 1894 | |||
| 1895 | //============================================================================ | ||
| 1896 | /// | ||
| 1897 | /// @brief Set the layouts for known controllers | ||
| 1898 | /// | ||
| 1899 | /// @param[in] controllers The controller layouts | ||
| 1900 | /// | ||
| 1901 | /// After loading the input topology, the frontend will call this with | ||
| 1902 | /// controller layouts for all controllers discovered in the topology. | ||
| 1903 | /// | ||
| 1904 | virtual void SetControllerLayouts(const std::vector<AddonGameControllerLayout>& controllers) | ||
| 1905 | { | ||
| 1906 | } | ||
| 1907 | //---------------------------------------------------------------------------- | ||
| 1908 | |||
| 1909 | //============================================================================ | ||
| 1910 | /// | ||
| 1911 | /// @brief Enable/disable keyboard input using the specified controller | ||
| 1912 | /// | ||
| 1913 | /// @param[in] enable True to enable input, false otherwise | ||
| 1914 | /// @param[in] controller_id The controller ID if enabling, or unused if disabling | ||
| 1915 | /// | ||
| 1916 | /// @return True if keyboard input was enabled, false otherwise | ||
| 1917 | /// | ||
| 1918 | virtual bool EnableKeyboard(bool enable, const std::string& controller_id) | ||
| 1919 | { | ||
| 1920 | return false; | ||
| 1921 | } | ||
| 1922 | //---------------------------------------------------------------------------- | ||
| 1923 | |||
| 1924 | //============================================================================ | ||
| 1925 | /// | ||
| 1926 | /// @brief Enable/disable mouse input using the specified controller | ||
| 1927 | /// | ||
| 1928 | /// @param[in] enable True to enable input, false otherwise | ||
| 1929 | /// @param[in] controller_id The controller ID if enabling, or unused if disabling | ||
| 1930 | /// | ||
| 1931 | /// @return True if mouse input was enabled, false otherwise | ||
| 1932 | /// | ||
| 1933 | virtual bool EnableMouse(bool enable, const std::string& controller_id) | ||
| 1934 | { | ||
| 1935 | return false; | ||
| 1936 | } | ||
| 1937 | //-------------------------------------------------------------------------- | ||
| 1938 | |||
| 1939 | //========================================================================== | ||
| 1940 | /// | ||
| 1941 | /// @brief Connect/disconnect a controller to a port on the virtual game console | ||
| 1942 | /// | ||
| 1943 | /// @param[in] connect True to connect a controller, false to disconnect | ||
| 1944 | /// @param[in] port_address The address of the port | ||
| 1945 | /// @param[in] controller_id The controller ID if connecting, or unused if disconnecting | ||
| 1946 | /// @return True if the \p controller was (dis-)connected to the port, false otherwise | ||
| 1947 | /// | ||
| 1948 | /// The address is a string that allows traversal of the controller topology. | ||
| 1949 | /// It is formed by alternating port IDs and controller IDs separated by "/". | ||
| 1950 | /// | ||
| 1951 | /// For example, assume that the topology represented in XML for Snes9x is: | ||
| 1952 | /// | ||
| 1953 | /// ~~~~~~~~~~~~~{.xml} | ||
| 1954 | /// <logicaltopology> | ||
| 1955 | /// <port type="controller" id="1"> | ||
| 1956 | /// <accepts controller="game.controller.snes"/> | ||
| 1957 | /// <accepts controller="game.controller.snes.multitap"> | ||
| 1958 | /// <port type="controller" id="1"> | ||
| 1959 | /// <accepts controller="game.controller.snes"/> | ||
| 1960 | /// </port> | ||
| 1961 | /// <port type="controller" id="2"> | ||
| 1962 | /// <accepts controller="game.controller.snes"/> | ||
| 1963 | /// </port> | ||
| 1964 | /// ... | ||
| 1965 | /// </accepts> | ||
| 1966 | /// </port> | ||
| 1967 | /// </logicaltopology> | ||
| 1968 | /// ~~~~~~~~~~~~~ | ||
| 1969 | /// | ||
| 1970 | /// To connect a multitap to the console's first port, the multitap's controller | ||
| 1971 | /// info is set using the port address: | ||
| 1972 | /// | ||
| 1973 | /// 1 | ||
| 1974 | /// | ||
| 1975 | /// To connect a SNES controller to the second port of the multitap, the | ||
| 1976 | /// controller info is next set using the address: | ||
| 1977 | /// | ||
| 1978 | /// 1/game.controller.multitap/2 | ||
| 1979 | /// | ||
| 1980 | /// Any attempts to connect a controller to a port on a disconnected multitap | ||
| 1981 | /// will return false. | ||
| 1982 | /// | ||
| 1983 | virtual bool ConnectController(bool connect, | ||
| 1984 | const std::string& port_address, | ||
| 1985 | const std::string& controller_id) | ||
| 1986 | { | ||
| 1987 | return false; | ||
| 1988 | } | ||
| 1989 | //---------------------------------------------------------------------------- | ||
| 1990 | |||
| 1991 | //============================================================================ | ||
| 1992 | /// | ||
| 1993 | /// @brief Notify the add-on of an input event | ||
| 1994 | /// | ||
| 1995 | /// @param[in] event The input event | ||
| 1996 | /// | ||
| 1997 | /// @return true if the event was handled, false otherwise | ||
| 1998 | /// | ||
| 1999 | virtual bool InputEvent(const game_input_event& event) | ||
| 2000 | { | ||
| 2001 | return false; | ||
| 2002 | } | ||
| 2003 | //---------------------------------------------------------------------------- | ||
| 2004 | |||
| 2005 | //============================================================================ | ||
| 2006 | /// | ||
| 2007 | /// @brief **Callback to Kodi Function**<br>Notify the port of an input event | ||
| 2008 | /// | ||
| 2009 | /// @param[in] event The input event | ||
| 2010 | /// @return true if the event was handled, false otherwise | ||
| 2011 | /// | ||
| 2012 | /// @note Input events can arrive for the following sources: | ||
| 2013 | /// - \ref GAME_INPUT_EVENT_MOTOR | ||
| 2014 | /// | ||
| 2015 | /// @remarks Only called from addon itself | ||
| 2016 | /// | ||
| 2017 | bool KodiInputEvent(const game_input_event& event) | ||
| 2018 | { | ||
| 2019 | return m_instanceData->toKodi.InputEvent(m_instanceData->toKodi.kodiInstance, &event); | ||
| 2020 | } | ||
| 2021 | //---------------------------------------------------------------------------- | ||
| 2022 | |||
| 2023 | //@} | ||
| 2024 | |||
| 2025 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 2026 | |||
| 2027 | //============================================================================ | ||
| 2028 | /// | ||
| 2029 | /// @defgroup cpp_kodi_addon_game_SerializationOperations 5. Serialization operations | ||
| 2030 | /// @ingroup cpp_kodi_addon_game | ||
| 2031 | /// @brief **Serialization operations** | ||
| 2032 | /// | ||
| 2033 | //@{ | ||
| 2034 | |||
| 2035 | //============================================================================ | ||
| 2036 | /// | ||
| 2037 | /// @brief Get the number of bytes required to serialize the game | ||
| 2038 | /// | ||
| 2039 | /// @return the number of bytes, or 0 if serialization is not supported | ||
| 2040 | /// | ||
| 2041 | virtual size_t SerializeSize() | ||
| 2042 | { | ||
| 2043 | return 0; | ||
| 2044 | } | ||
| 2045 | //---------------------------------------------------------------------------- | ||
| 2046 | |||
| 2047 | //============================================================================ | ||
| 2048 | /// | ||
| 2049 | /// @brief Serialize the state of the game | ||
| 2050 | /// | ||
| 2051 | /// @param[in] data The buffer receiving the serialized game data | ||
| 2052 | /// @param[in] size The size of the buffer | ||
| 2053 | /// | ||
| 2054 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was serialized into the buffer | ||
| 2055 | /// | ||
| 2056 | virtual GAME_ERROR Serialize(uint8_t* data, size_t size) | ||
| 2057 | { | ||
| 2058 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 2059 | } | ||
| 2060 | //---------------------------------------------------------------------------- | ||
| 2061 | |||
| 2062 | //============================================================================ | ||
| 2063 | /// | ||
| 2064 | /// @brief Deserialize the game from the given state | ||
| 2065 | /// | ||
| 2066 | /// @param[in] data A buffer containing the game's new state | ||
| 2067 | /// @param[in] size The size of the buffer | ||
| 2068 | /// | ||
| 2069 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game deserialized | ||
| 2070 | /// | ||
| 2071 | virtual GAME_ERROR Deserialize(const uint8_t* data, size_t size) | ||
| 2072 | { | ||
| 2073 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 2074 | } | ||
| 2075 | //---------------------------------------------------------------------------- | ||
| 2076 | |||
| 2077 | //@} | ||
| 2078 | |||
| 2079 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 2080 | |||
| 2081 | //============================================================================ | ||
| 2082 | /// | ||
| 2083 | /// @defgroup cpp_kodi_addon_game_CheatOperations 6. Cheat operations | ||
| 2084 | /// @ingroup cpp_kodi_addon_game | ||
| 2085 | /// @brief **Cheat operations** | ||
| 2086 | /// | ||
| 2087 | //@{ | ||
| 2088 | |||
| 2089 | //============================================================================ | ||
| 2090 | /// | ||
| 2091 | /// @brief Reset the cheat system | ||
| 2092 | /// | ||
| 2093 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the cheat system was reset | ||
| 2094 | /// | ||
| 2095 | virtual GAME_ERROR CheatReset() | ||
| 2096 | { | ||
| 2097 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 2098 | } | ||
| 2099 | //---------------------------------------------------------------------------- | ||
| 2100 | |||
| 2101 | //============================================================================ | ||
| 2102 | /// | ||
| 2103 | /// @brief Get a region of memory | ||
| 2104 | /// | ||
| 2105 | /// @param[in] type The type of memory to retrieve | ||
| 2106 | /// @param[in] data Set to the region of memory; must remain valid until UnloadGame() is called | ||
| 2107 | /// @param[in] size Set to the size of the region of memory | ||
| 2108 | /// | ||
| 2109 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if data was set to a valid buffer | ||
| 2110 | /// | ||
| 2111 | virtual GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t*& data, size_t& size) | ||
| 2112 | { | ||
| 2113 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 2114 | } | ||
| 2115 | //---------------------------------------------------------------------------- | ||
| 2116 | |||
| 2117 | //============================================================================ | ||
| 2118 | /// | ||
| 2119 | /// @brief Set a cheat code | ||
| 2120 | /// | ||
| 2121 | /// @param[in] index | ||
| 2122 | /// @param[in] enabled | ||
| 2123 | /// @param[in] code | ||
| 2124 | /// | ||
| 2125 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the cheat was set | ||
| 2126 | /// | ||
| 2127 | virtual GAME_ERROR SetCheat(unsigned int index, bool enabled, const std::string& code) | ||
| 2128 | { | ||
| 2129 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 2130 | } | ||
| 2131 | //---------------------------------------------------------------------------- | ||
| 2132 | |||
| 2133 | //@} | ||
| 2134 | |||
| 2135 | private: | ||
| 2136 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 2137 | { | ||
| 2138 | if (instance == nullptr) | ||
| 2139 | throw std::logic_error("kodi::addon::CInstanceGame: Creation with empty addon structure not" | ||
| 2140 | "allowed, table must be given from Kodi!"); | ||
| 2141 | |||
| 2142 | m_instanceData = static_cast<AddonInstance_Game*>(instance); | ||
| 2143 | m_instanceData->toAddon.addonInstance = this; | ||
| 2144 | |||
| 2145 | m_instanceData->toAddon.LoadGame = ADDON_LoadGame; | ||
| 2146 | m_instanceData->toAddon.LoadGameSpecial = ADDON_LoadGameSpecial; | ||
| 2147 | m_instanceData->toAddon.LoadStandalone = ADDON_LoadStandalone; | ||
| 2148 | m_instanceData->toAddon.UnloadGame = ADDON_UnloadGame; | ||
| 2149 | m_instanceData->toAddon.GetGameTiming = ADDON_GetGameTiming; | ||
| 2150 | m_instanceData->toAddon.GetRegion = ADDON_GetRegion; | ||
| 2151 | m_instanceData->toAddon.RequiresGameLoop = ADDON_RequiresGameLoop; | ||
| 2152 | m_instanceData->toAddon.RunFrame = ADDON_RunFrame; | ||
| 2153 | m_instanceData->toAddon.Reset = ADDON_Reset; | ||
| 2154 | |||
| 2155 | m_instanceData->toAddon.HwContextReset = ADDON_HwContextReset; | ||
| 2156 | m_instanceData->toAddon.HwContextDestroy = ADDON_HwContextDestroy; | ||
| 2157 | |||
| 2158 | m_instanceData->toAddon.HasFeature = ADDON_HasFeature; | ||
| 2159 | m_instanceData->toAddon.GetTopology = ADDON_GetTopology; | ||
| 2160 | m_instanceData->toAddon.FreeTopology = ADDON_FreeTopology; | ||
| 2161 | m_instanceData->toAddon.SetControllerLayouts = ADDON_SetControllerLayouts; | ||
| 2162 | m_instanceData->toAddon.EnableKeyboard = ADDON_EnableKeyboard; | ||
| 2163 | m_instanceData->toAddon.EnableMouse = ADDON_EnableMouse; | ||
| 2164 | m_instanceData->toAddon.ConnectController = ADDON_ConnectController; | ||
| 2165 | m_instanceData->toAddon.InputEvent = ADDON_InputEvent; | ||
| 2166 | |||
| 2167 | m_instanceData->toAddon.SerializeSize = ADDON_SerializeSize; | ||
| 2168 | m_instanceData->toAddon.Serialize = ADDON_Serialize; | ||
| 2169 | m_instanceData->toAddon.Deserialize = ADDON_Deserialize; | ||
| 2170 | |||
| 2171 | m_instanceData->toAddon.CheatReset = ADDON_CheatReset; | ||
| 2172 | m_instanceData->toAddon.GetMemory = ADDON_GetMemory; | ||
| 2173 | m_instanceData->toAddon.SetCheat = ADDON_SetCheat; | ||
| 2174 | } | ||
| 2175 | |||
| 2176 | // --- Game operations --------------------------------------------------------- | ||
| 2177 | |||
| 2178 | inline static GAME_ERROR ADDON_LoadGame(const AddonInstance_Game* instance, const char* url) | ||
| 2179 | { | ||
| 2180 | return instance->toAddon.addonInstance->LoadGame(url); | ||
| 2181 | } | ||
| 2182 | |||
| 2183 | inline static GAME_ERROR ADDON_LoadGameSpecial(const AddonInstance_Game* instance, | ||
| 2184 | SPECIAL_GAME_TYPE type, | ||
| 2185 | const char** urls, | ||
| 2186 | size_t urlCount) | ||
| 2187 | { | ||
| 2188 | std::vector<std::string> urlList; | ||
| 2189 | for (size_t i = 0; i < urlCount; ++i) | ||
| 2190 | { | ||
| 2191 | if (urls[i] != nullptr) | ||
| 2192 | urlList.push_back(urls[i]); | ||
| 2193 | } | ||
| 2194 | |||
| 2195 | return instance->toAddon.addonInstance->LoadGameSpecial(type, urlList); | ||
| 2196 | } | ||
| 2197 | |||
| 2198 | inline static GAME_ERROR ADDON_LoadStandalone(const AddonInstance_Game* instance) | ||
| 2199 | { | ||
| 2200 | return instance->toAddon.addonInstance->LoadStandalone(); | ||
| 2201 | } | ||
| 2202 | |||
| 2203 | inline static GAME_ERROR ADDON_UnloadGame(const AddonInstance_Game* instance) | ||
| 2204 | { | ||
| 2205 | return instance->toAddon.addonInstance->UnloadGame(); | ||
| 2206 | } | ||
| 2207 | |||
| 2208 | inline static GAME_ERROR ADDON_GetGameTiming(const AddonInstance_Game* instance, | ||
| 2209 | game_system_timing* timing_info) | ||
| 2210 | { | ||
| 2211 | return instance->toAddon.addonInstance->GetGameTiming(*timing_info); | ||
| 2212 | } | ||
| 2213 | |||
| 2214 | inline static GAME_REGION ADDON_GetRegion(const AddonInstance_Game* instance) | ||
| 2215 | { | ||
| 2216 | return instance->toAddon.addonInstance->GetRegion(); | ||
| 2217 | } | ||
| 2218 | |||
| 2219 | inline static bool ADDON_RequiresGameLoop(const AddonInstance_Game* instance) | ||
| 2220 | { | ||
| 2221 | return instance->toAddon.addonInstance->RequiresGameLoop(); | ||
| 2222 | } | ||
| 2223 | |||
| 2224 | inline static GAME_ERROR ADDON_RunFrame(const AddonInstance_Game* instance) | ||
| 2225 | { | ||
| 2226 | return instance->toAddon.addonInstance->RunFrame(); | ||
| 2227 | } | ||
| 2228 | |||
| 2229 | inline static GAME_ERROR ADDON_Reset(const AddonInstance_Game* instance) | ||
| 2230 | { | ||
| 2231 | return instance->toAddon.addonInstance->Reset(); | ||
| 2232 | } | ||
| 2233 | |||
| 2234 | |||
| 2235 | // --- Hardware rendering operations ------------------------------------------- | ||
| 2236 | |||
| 2237 | inline static GAME_ERROR ADDON_HwContextReset(const AddonInstance_Game* instance) | ||
| 2238 | { | ||
| 2239 | return instance->toAddon.addonInstance->HwContextReset(); | ||
| 2240 | } | ||
| 2241 | |||
| 2242 | inline static GAME_ERROR ADDON_HwContextDestroy(const AddonInstance_Game* instance) | ||
| 2243 | { | ||
| 2244 | return instance->toAddon.addonInstance->HwContextDestroy(); | ||
| 2245 | } | ||
| 2246 | |||
| 2247 | |||
| 2248 | // --- Input operations -------------------------------------------------------- | ||
| 2249 | |||
| 2250 | inline static bool ADDON_HasFeature(const AddonInstance_Game* instance, | ||
| 2251 | const char* controller_id, | ||
| 2252 | const char* feature_name) | ||
| 2253 | { | ||
| 2254 | return instance->toAddon.addonInstance->HasFeature(controller_id, feature_name); | ||
| 2255 | } | ||
| 2256 | |||
| 2257 | inline static game_input_topology* ADDON_GetTopology(const AddonInstance_Game* instance) | ||
| 2258 | { | ||
| 2259 | return instance->toAddon.addonInstance->GetTopology(); | ||
| 2260 | } | ||
| 2261 | |||
| 2262 | inline static void ADDON_FreeTopology(const AddonInstance_Game* instance, | ||
| 2263 | game_input_topology* topology) | ||
| 2264 | { | ||
| 2265 | instance->toAddon.addonInstance->FreeTopology(topology); | ||
| 2266 | } | ||
| 2267 | |||
| 2268 | inline static void ADDON_SetControllerLayouts(const AddonInstance_Game* instance, | ||
| 2269 | const game_controller_layout* controllers, | ||
| 2270 | unsigned int controller_count) | ||
| 2271 | { | ||
| 2272 | if (controllers == nullptr) | ||
| 2273 | return; | ||
| 2274 | |||
| 2275 | std::vector<AddonGameControllerLayout> controllerList; | ||
| 2276 | for (unsigned int i = 0; i < controller_count; ++i) | ||
| 2277 | controllerList.push_back(controllers[i]); | ||
| 2278 | |||
| 2279 | instance->toAddon.addonInstance->SetControllerLayouts(controllerList); | ||
| 2280 | } | ||
| 2281 | |||
| 2282 | inline static bool ADDON_EnableKeyboard(const AddonInstance_Game* instance, | ||
| 2283 | bool enable, | ||
| 2284 | const char* controller_id) | ||
| 2285 | { | ||
| 2286 | return instance->toAddon.addonInstance->EnableKeyboard(enable, controller_id); | ||
| 2287 | } | ||
| 2288 | |||
| 2289 | inline static bool ADDON_EnableMouse(const AddonInstance_Game* instance, | ||
| 2290 | bool enable, | ||
| 2291 | const char* controller_id) | ||
| 2292 | { | ||
| 2293 | return instance->toAddon.addonInstance->EnableMouse(enable, controller_id); | ||
| 2294 | } | ||
| 2295 | |||
| 2296 | inline static bool ADDON_ConnectController(const AddonInstance_Game* instance, | ||
| 2297 | bool connect, | ||
| 2298 | const char* port_address, | ||
| 2299 | const char* controller_id) | ||
| 2300 | { | ||
| 2301 | return instance->toAddon.addonInstance->ConnectController(connect, port_address, controller_id); | ||
| 2302 | } | ||
| 2303 | |||
| 2304 | inline static bool ADDON_InputEvent(const AddonInstance_Game* instance, | ||
| 2305 | const game_input_event* event) | ||
| 2306 | { | ||
| 2307 | return instance->toAddon.addonInstance->InputEvent(*event); | ||
| 2308 | } | ||
| 2309 | |||
| 2310 | |||
| 2311 | // --- Serialization operations ------------------------------------------------ | ||
| 2312 | |||
| 2313 | inline static size_t ADDON_SerializeSize(const AddonInstance_Game* instance) | ||
| 2314 | { | ||
| 2315 | return instance->toAddon.addonInstance->SerializeSize(); | ||
| 2316 | } | ||
| 2317 | |||
| 2318 | inline static GAME_ERROR ADDON_Serialize(const AddonInstance_Game* instance, | ||
| 2319 | uint8_t* data, | ||
| 2320 | size_t size) | ||
| 2321 | { | ||
| 2322 | return instance->toAddon.addonInstance->Serialize(data, size); | ||
| 2323 | } | ||
| 2324 | |||
| 2325 | inline static GAME_ERROR ADDON_Deserialize(const AddonInstance_Game* instance, | ||
| 2326 | const uint8_t* data, | ||
| 2327 | size_t size) | ||
| 2328 | { | ||
| 2329 | return instance->toAddon.addonInstance->Deserialize(data, size); | ||
| 2330 | } | ||
| 2331 | |||
| 2332 | |||
| 2333 | // --- Cheat operations -------------------------------------------------------- | ||
| 2334 | |||
| 2335 | inline static GAME_ERROR ADDON_CheatReset(const AddonInstance_Game* instance) | ||
| 2336 | { | ||
| 2337 | return instance->toAddon.addonInstance->CheatReset(); | ||
| 2338 | } | ||
| 2339 | |||
| 2340 | inline static GAME_ERROR ADDON_GetMemory(const AddonInstance_Game* instance, | ||
| 2341 | GAME_MEMORY type, | ||
| 2342 | uint8_t** data, | ||
| 2343 | size_t* size) | ||
| 2344 | { | ||
| 2345 | return instance->toAddon.addonInstance->GetMemory(type, *data, *size); | ||
| 2346 | } | ||
| 2347 | |||
| 2348 | inline static GAME_ERROR ADDON_SetCheat(const AddonInstance_Game* instance, | ||
| 2349 | unsigned int index, | ||
| 2350 | bool enabled, | ||
| 2351 | const char* code) | ||
| 2352 | { | ||
| 2353 | return instance->toAddon.addonInstance->SetCheat(index, enabled, code); | ||
| 2354 | } | ||
| 2355 | |||
| 2356 | AddonInstance_Game* m_instanceData; | ||
| 2357 | }; | ||
| 2358 | |||
| 2359 | } /* namespace addon */ | ||
| 2360 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h deleted file mode 100644 index 2067d51..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h +++ /dev/null | |||
| @@ -1,847 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | |||
| 13 | namespace kodi { namespace addon { class CInstancePeripheral; }} | ||
| 14 | |||
| 15 | /* indicates a joystick has no preference for port number */ | ||
| 16 | #define NO_PORT_REQUESTED (-1) | ||
| 17 | |||
| 18 | /* joystick's driver button/hat/axis index is unknown */ | ||
| 19 | #define DRIVER_INDEX_UNKNOWN (-1) | ||
| 20 | |||
| 21 | extern "C" | ||
| 22 | { | ||
| 23 | |||
| 24 | /// @name Peripheral types | ||
| 25 | ///{ | ||
| 26 | |||
| 27 | /*! | ||
| 28 | * @brief API error codes | ||
| 29 | */ | ||
| 30 | typedef enum PERIPHERAL_ERROR | ||
| 31 | { | ||
| 32 | PERIPHERAL_NO_ERROR = 0, // no error occurred | ||
| 33 | PERIPHERAL_ERROR_UNKNOWN = -1, // an unknown error occurred | ||
| 34 | PERIPHERAL_ERROR_FAILED = -2, // the command failed | ||
| 35 | PERIPHERAL_ERROR_INVALID_PARAMETERS = -3, // the parameters of the method are invalid for this operation | ||
| 36 | PERIPHERAL_ERROR_NOT_IMPLEMENTED = -4, // the method that the frontend called is not implemented | ||
| 37 | PERIPHERAL_ERROR_NOT_CONNECTED = -5, // no peripherals are connected | ||
| 38 | PERIPHERAL_ERROR_CONNECTION_FAILED = -6, // peripherals are connected, but command was interrupted | ||
| 39 | } PERIPHERAL_ERROR; | ||
| 40 | |||
| 41 | /*! | ||
| 42 | * @brief Peripheral types | ||
| 43 | */ | ||
| 44 | typedef enum PERIPHERAL_TYPE | ||
| 45 | { | ||
| 46 | PERIPHERAL_TYPE_UNKNOWN, | ||
| 47 | PERIPHERAL_TYPE_JOYSTICK, | ||
| 48 | PERIPHERAL_TYPE_KEYBOARD, | ||
| 49 | } PERIPHERAL_TYPE; | ||
| 50 | |||
| 51 | /*! | ||
| 52 | * @brief Information shared between peripherals | ||
| 53 | */ | ||
| 54 | typedef struct PERIPHERAL_INFO | ||
| 55 | { | ||
| 56 | PERIPHERAL_TYPE type; /*!< @brief type of peripheral */ | ||
| 57 | char* name; /*!< @brief name of peripheral */ | ||
| 58 | uint16_t vendor_id; /*!< @brief vendor ID of peripheral, 0x0000 if unknown */ | ||
| 59 | uint16_t product_id; /*!< @brief product ID of peripheral, 0x0000 if unknown */ | ||
| 60 | unsigned int index; /*!< @brief the order in which the add-on identified this peripheral */ | ||
| 61 | } ATTRIBUTE_PACKED PERIPHERAL_INFO; | ||
| 62 | |||
| 63 | /*! | ||
| 64 | * @brief Peripheral add-on capabilities. | ||
| 65 | */ | ||
| 66 | typedef struct PERIPHERAL_CAPABILITIES | ||
| 67 | { | ||
| 68 | bool provides_joysticks; /*!< @brief true if the add-on provides joysticks */ | ||
| 69 | bool provides_joystick_rumble; | ||
| 70 | bool provides_joystick_power_off; | ||
| 71 | bool provides_buttonmaps; /*!< @brief true if the add-on provides button maps */ | ||
| 72 | } ATTRIBUTE_PACKED PERIPHERAL_CAPABILITIES; | ||
| 73 | ///} | ||
| 74 | |||
| 75 | /// @name Event types | ||
| 76 | ///{ | ||
| 77 | |||
| 78 | /*! | ||
| 79 | * @brief Types of events that can be sent and received | ||
| 80 | */ | ||
| 81 | typedef enum PERIPHERAL_EVENT_TYPE | ||
| 82 | { | ||
| 83 | PERIPHERAL_EVENT_TYPE_NONE, /*!< @brief unknown event */ | ||
| 84 | PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON, /*!< @brief state changed for joystick driver button */ | ||
| 85 | PERIPHERAL_EVENT_TYPE_DRIVER_HAT, /*!< @brief state changed for joystick driver hat */ | ||
| 86 | PERIPHERAL_EVENT_TYPE_DRIVER_AXIS, /*!< @brief state changed for joystick driver axis */ | ||
| 87 | PERIPHERAL_EVENT_TYPE_SET_MOTOR, /*!< @brief set the state for joystick rumble motor */ | ||
| 88 | } PERIPHERAL_EVENT_TYPE; | ||
| 89 | |||
| 90 | /*! | ||
| 91 | * @brief States a button can have | ||
| 92 | */ | ||
| 93 | typedef enum JOYSTICK_STATE_BUTTON | ||
| 94 | { | ||
| 95 | JOYSTICK_STATE_BUTTON_UNPRESSED = 0x0, /*!< @brief button is released */ | ||
| 96 | JOYSTICK_STATE_BUTTON_PRESSED = 0x1, /*!< @brief button is pressed */ | ||
| 97 | } JOYSTICK_STATE_BUTTON; | ||
| 98 | |||
| 99 | /*! | ||
| 100 | * @brief States a D-pad (also called a hat) can have | ||
| 101 | */ | ||
| 102 | typedef enum JOYSTICK_STATE_HAT | ||
| 103 | { | ||
| 104 | JOYSTICK_STATE_HAT_UNPRESSED = 0x0, /*!< @brief no directions are pressed */ | ||
| 105 | JOYSTICK_STATE_HAT_LEFT = 0x1, /*!< @brief only left is pressed */ | ||
| 106 | JOYSTICK_STATE_HAT_RIGHT = 0x2, /*!< @brief only right is pressed */ | ||
| 107 | JOYSTICK_STATE_HAT_UP = 0x4, /*!< @brief only up is pressed */ | ||
| 108 | JOYSTICK_STATE_HAT_DOWN = 0x8, /*!< @brief only down is pressed */ | ||
| 109 | JOYSTICK_STATE_HAT_LEFT_UP = JOYSTICK_STATE_HAT_LEFT | JOYSTICK_STATE_HAT_UP, | ||
| 110 | JOYSTICK_STATE_HAT_LEFT_DOWN = JOYSTICK_STATE_HAT_LEFT | JOYSTICK_STATE_HAT_DOWN, | ||
| 111 | JOYSTICK_STATE_HAT_RIGHT_UP = JOYSTICK_STATE_HAT_RIGHT | JOYSTICK_STATE_HAT_UP, | ||
| 112 | JOYSTICK_STATE_HAT_RIGHT_DOWN = JOYSTICK_STATE_HAT_RIGHT | JOYSTICK_STATE_HAT_DOWN, | ||
| 113 | } JOYSTICK_STATE_HAT; | ||
| 114 | |||
| 115 | /*! | ||
| 116 | * @brief Axis value in the closed interval [-1.0, 1.0] | ||
| 117 | * | ||
| 118 | * The axis state uses the XInput coordinate system: | ||
| 119 | * - Negative values signify down or to the left | ||
| 120 | * - Positive values signify up or to the right | ||
| 121 | */ | ||
| 122 | typedef float JOYSTICK_STATE_AXIS; | ||
| 123 | |||
| 124 | /*! | ||
| 125 | * @brief Motor value in the closed interval [0.0, 1.0] | ||
| 126 | */ | ||
| 127 | typedef float JOYSTICK_STATE_MOTOR; | ||
| 128 | |||
| 129 | /*! | ||
| 130 | * @brief Event information | ||
| 131 | */ | ||
| 132 | typedef struct PERIPHERAL_EVENT | ||
| 133 | { | ||
| 134 | /*! @brief Index of the peripheral handling/receiving the event */ | ||
| 135 | unsigned int peripheral_index; | ||
| 136 | |||
| 137 | /*! @brief Type of the event used to determine which enum field to access below */ | ||
| 138 | PERIPHERAL_EVENT_TYPE type; | ||
| 139 | |||
| 140 | /*! @brief The index of the event source */ | ||
| 141 | unsigned int driver_index; | ||
| 142 | |||
| 143 | JOYSTICK_STATE_BUTTON driver_button_state; | ||
| 144 | JOYSTICK_STATE_HAT driver_hat_state; | ||
| 145 | JOYSTICK_STATE_AXIS driver_axis_state; | ||
| 146 | JOYSTICK_STATE_MOTOR motor_state; | ||
| 147 | } ATTRIBUTE_PACKED PERIPHERAL_EVENT; | ||
| 148 | ///} | ||
| 149 | |||
| 150 | /// @name Joystick types | ||
| 151 | ///{ | ||
| 152 | |||
| 153 | /*! | ||
| 154 | * @brief Info specific to joystick peripherals | ||
| 155 | */ | ||
| 156 | typedef struct JOYSTICK_INFO | ||
| 157 | { | ||
| 158 | PERIPHERAL_INFO peripheral; /*!< @brief peripheral info for this joystick */ | ||
| 159 | char* provider; /*!< @brief name of the driver or interface providing the joystick */ | ||
| 160 | int requested_port; /*!< @brief requested port number (such as for 360 controllers), or NO_PORT_REQUESTED */ | ||
| 161 | unsigned int button_count; /*!< @brief number of buttons reported by the driver */ | ||
| 162 | unsigned int hat_count; /*!< @brief number of hats reported by the driver */ | ||
| 163 | unsigned int axis_count; /*!< @brief number of axes reported by the driver */ | ||
| 164 | unsigned int motor_count; /*!< @brief number of motors reported by the driver */ | ||
| 165 | bool supports_poweroff; /*!< @brief whether the joystick supports being powered off */ | ||
| 166 | } ATTRIBUTE_PACKED JOYSTICK_INFO; | ||
| 167 | |||
| 168 | /*! | ||
| 169 | * @brief Driver input primitives | ||
| 170 | * | ||
| 171 | * Mapping lower-level driver values to higher-level controller features is | ||
| 172 | * non-injective; two triggers can share a single axis. | ||
| 173 | * | ||
| 174 | * To handle this, driver values are subdivided into "primitives" that map | ||
| 175 | * injectively to higher-level features. | ||
| 176 | */ | ||
| 177 | typedef enum JOYSTICK_DRIVER_PRIMITIVE_TYPE | ||
| 178 | { | ||
| 179 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN, | ||
| 180 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON, | ||
| 181 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION, | ||
| 182 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS, | ||
| 183 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR, | ||
| 184 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY, | ||
| 185 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON, | ||
| 186 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION, | ||
| 187 | } JOYSTICK_DRIVER_PRIMITIVE_TYPE; | ||
| 188 | |||
| 189 | /*! | ||
| 190 | * @brief Button primitive | ||
| 191 | */ | ||
| 192 | typedef struct JOYSTICK_DRIVER_BUTTON | ||
| 193 | { | ||
| 194 | int index; | ||
| 195 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_BUTTON; | ||
| 196 | |||
| 197 | /*! | ||
| 198 | * @brief Hat direction | ||
| 199 | */ | ||
| 200 | typedef enum JOYSTICK_DRIVER_HAT_DIRECTION | ||
| 201 | { | ||
| 202 | JOYSTICK_DRIVER_HAT_UNKNOWN, | ||
| 203 | JOYSTICK_DRIVER_HAT_LEFT, | ||
| 204 | JOYSTICK_DRIVER_HAT_RIGHT, | ||
| 205 | JOYSTICK_DRIVER_HAT_UP, | ||
| 206 | JOYSTICK_DRIVER_HAT_DOWN, | ||
| 207 | } JOYSTICK_DRIVER_HAT_DIRECTION; | ||
| 208 | |||
| 209 | /*! | ||
| 210 | * @brief Hat direction primitive | ||
| 211 | */ | ||
| 212 | typedef struct JOYSTICK_DRIVER_HAT | ||
| 213 | { | ||
| 214 | int index; | ||
| 215 | JOYSTICK_DRIVER_HAT_DIRECTION direction; | ||
| 216 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_HAT; | ||
| 217 | |||
| 218 | /*! | ||
| 219 | * @brief Semiaxis direction | ||
| 220 | */ | ||
| 221 | typedef enum JOYSTICK_DRIVER_SEMIAXIS_DIRECTION | ||
| 222 | { | ||
| 223 | JOYSTICK_DRIVER_SEMIAXIS_NEGATIVE = -1, /*!< @brief negative half of the axis */ | ||
| 224 | JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN = 0, /*!< @brief unknown direction */ | ||
| 225 | JOYSTICK_DRIVER_SEMIAXIS_POSITIVE = 1, /*!< @brief positive half of the axis */ | ||
| 226 | } JOYSTICK_DRIVER_SEMIAXIS_DIRECTION; | ||
| 227 | |||
| 228 | /*! | ||
| 229 | * @brief Semiaxis primitive | ||
| 230 | */ | ||
| 231 | typedef struct JOYSTICK_DRIVER_SEMIAXIS | ||
| 232 | { | ||
| 233 | int index; | ||
| 234 | int center; | ||
| 235 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction; | ||
| 236 | unsigned int range; | ||
| 237 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_SEMIAXIS; | ||
| 238 | |||
| 239 | /*! | ||
| 240 | * @brief Motor primitive | ||
| 241 | */ | ||
| 242 | typedef struct JOYSTICK_DRIVER_MOTOR | ||
| 243 | { | ||
| 244 | int index; | ||
| 245 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOTOR; | ||
| 246 | |||
| 247 | /*! | ||
| 248 | * @brief Keyboard key primitive | ||
| 249 | */ | ||
| 250 | typedef struct JOYSTICK_DRIVER_KEY | ||
| 251 | { | ||
| 252 | char keycode[16]; | ||
| 253 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_KEY; | ||
| 254 | |||
| 255 | /*! | ||
| 256 | * @brief Mouse buttons | ||
| 257 | */ | ||
| 258 | typedef enum JOYSTICK_DRIVER_MOUSE_INDEX | ||
| 259 | { | ||
| 260 | JOYSTICK_DRIVER_MOUSE_INDEX_UNKNOWN, | ||
| 261 | JOYSTICK_DRIVER_MOUSE_INDEX_LEFT, | ||
| 262 | JOYSTICK_DRIVER_MOUSE_INDEX_RIGHT, | ||
| 263 | JOYSTICK_DRIVER_MOUSE_INDEX_MIDDLE, | ||
| 264 | JOYSTICK_DRIVER_MOUSE_INDEX_BUTTON4, | ||
| 265 | JOYSTICK_DRIVER_MOUSE_INDEX_BUTTON5, | ||
| 266 | JOYSTICK_DRIVER_MOUSE_INDEX_WHEEL_UP, | ||
| 267 | JOYSTICK_DRIVER_MOUSE_INDEX_WHEEL_DOWN, | ||
| 268 | JOYSTICK_DRIVER_MOUSE_INDEX_HORIZ_WHEEL_LEFT, | ||
| 269 | JOYSTICK_DRIVER_MOUSE_INDEX_HORIZ_WHEEL_RIGHT, | ||
| 270 | } JOYSTICK_DRIVER_MOUSE_INDEX; | ||
| 271 | |||
| 272 | /*! | ||
| 273 | * @brief Mouse button primitive | ||
| 274 | */ | ||
| 275 | typedef struct JOYSTICK_DRIVER_MOUSE_BUTTON | ||
| 276 | { | ||
| 277 | JOYSTICK_DRIVER_MOUSE_INDEX button; | ||
| 278 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOUSE_BUTTON; | ||
| 279 | |||
| 280 | /*! | ||
| 281 | * @brief Relative pointer direction | ||
| 282 | */ | ||
| 283 | typedef enum JOYSTICK_DRIVER_RELPOINTER_DIRECTION | ||
| 284 | { | ||
| 285 | JOYSTICK_DRIVER_RELPOINTER_UNKNOWN, | ||
| 286 | JOYSTICK_DRIVER_RELPOINTER_LEFT, | ||
| 287 | JOYSTICK_DRIVER_RELPOINTER_RIGHT, | ||
| 288 | JOYSTICK_DRIVER_RELPOINTER_UP, | ||
| 289 | JOYSTICK_DRIVER_RELPOINTER_DOWN, | ||
| 290 | } JOYSTICK_DRIVER_RELPOINTER_DIRECTION; | ||
| 291 | |||
| 292 | /*! | ||
| 293 | * @brief Relative pointer direction primitive | ||
| 294 | */ | ||
| 295 | typedef struct JOYSTICK_DRIVER_RELPOINTER | ||
| 296 | { | ||
| 297 | JOYSTICK_DRIVER_RELPOINTER_DIRECTION direction; | ||
| 298 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_RELPOINTER; | ||
| 299 | |||
| 300 | /*! | ||
| 301 | * @brief Driver primitive struct | ||
| 302 | */ | ||
| 303 | typedef struct JOYSTICK_DRIVER_PRIMITIVE | ||
| 304 | { | ||
| 305 | JOYSTICK_DRIVER_PRIMITIVE_TYPE type; | ||
| 306 | union | ||
| 307 | { | ||
| 308 | struct JOYSTICK_DRIVER_BUTTON button; | ||
| 309 | struct JOYSTICK_DRIVER_HAT hat; | ||
| 310 | struct JOYSTICK_DRIVER_SEMIAXIS semiaxis; | ||
| 311 | struct JOYSTICK_DRIVER_MOTOR motor; | ||
| 312 | struct JOYSTICK_DRIVER_KEY key; | ||
| 313 | struct JOYSTICK_DRIVER_MOUSE_BUTTON mouse; | ||
| 314 | struct JOYSTICK_DRIVER_RELPOINTER relpointer; | ||
| 315 | }; | ||
| 316 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_PRIMITIVE; | ||
| 317 | |||
| 318 | /*! | ||
| 319 | * @brief Controller feature | ||
| 320 | * | ||
| 321 | * Controller features are an abstraction over driver values. Each feature | ||
| 322 | * maps to one or more driver primitives. | ||
| 323 | */ | ||
| 324 | typedef enum JOYSTICK_FEATURE_TYPE | ||
| 325 | { | ||
| 326 | JOYSTICK_FEATURE_TYPE_UNKNOWN, | ||
| 327 | JOYSTICK_FEATURE_TYPE_SCALAR, | ||
| 328 | JOYSTICK_FEATURE_TYPE_ANALOG_STICK, | ||
| 329 | JOYSTICK_FEATURE_TYPE_ACCELEROMETER, | ||
| 330 | JOYSTICK_FEATURE_TYPE_MOTOR, | ||
| 331 | JOYSTICK_FEATURE_TYPE_RELPOINTER, | ||
| 332 | JOYSTICK_FEATURE_TYPE_ABSPOINTER, | ||
| 333 | JOYSTICK_FEATURE_TYPE_WHEEL, | ||
| 334 | JOYSTICK_FEATURE_TYPE_THROTTLE, | ||
| 335 | JOYSTICK_FEATURE_TYPE_KEY, | ||
| 336 | } JOYSTICK_FEATURE_TYPE; | ||
| 337 | |||
| 338 | /*! | ||
| 339 | * @brief Indices used to access a feature's driver primitives | ||
| 340 | */ | ||
| 341 | typedef enum JOYSTICK_FEATURE_PRIMITIVE | ||
| 342 | { | ||
| 343 | // Scalar feature (a button, hat direction or semiaxis) | ||
| 344 | JOYSTICK_SCALAR_PRIMITIVE = 0, | ||
| 345 | |||
| 346 | // Analog stick | ||
| 347 | JOYSTICK_ANALOG_STICK_UP = 0, | ||
| 348 | JOYSTICK_ANALOG_STICK_DOWN = 1, | ||
| 349 | JOYSTICK_ANALOG_STICK_RIGHT = 2, | ||
| 350 | JOYSTICK_ANALOG_STICK_LEFT = 3, | ||
| 351 | |||
| 352 | // Accelerometer | ||
| 353 | JOYSTICK_ACCELEROMETER_POSITIVE_X = 0, | ||
| 354 | JOYSTICK_ACCELEROMETER_POSITIVE_Y = 1, | ||
| 355 | JOYSTICK_ACCELEROMETER_POSITIVE_Z = 2, | ||
| 356 | |||
| 357 | // Motor | ||
| 358 | JOYSTICK_MOTOR_PRIMITIVE = 0, | ||
| 359 | |||
| 360 | // Wheel | ||
| 361 | JOYSTICK_WHEEL_LEFT = 0, | ||
| 362 | JOYSTICK_WHEEL_RIGHT = 1, | ||
| 363 | |||
| 364 | // Throttle | ||
| 365 | JOYSTICK_THROTTLE_UP = 0, | ||
| 366 | JOYSTICK_THROTTLE_DOWN = 1, | ||
| 367 | |||
| 368 | // Key | ||
| 369 | JOYSTICK_KEY_PRIMITIVE = 0, | ||
| 370 | |||
| 371 | // Mouse button | ||
| 372 | JOYSTICK_MOUSE_BUTTON = 0, | ||
| 373 | |||
| 374 | // Relative pointer direction | ||
| 375 | JOYSTICK_RELPOINTER_UP = 0, | ||
| 376 | JOYSTICK_RELPOINTER_DOWN = 1, | ||
| 377 | JOYSTICK_RELPOINTER_RIGHT = 2, | ||
| 378 | JOYSTICK_RELPOINTER_LEFT = 3, | ||
| 379 | |||
| 380 | // Maximum number of primitives | ||
| 381 | JOYSTICK_PRIMITIVE_MAX = 4, | ||
| 382 | } JOYSTICK_FEATURE_PRIMITIVE; | ||
| 383 | |||
| 384 | /*! | ||
| 385 | * @brief Mapping between higher-level controller feature and its driver primitives | ||
| 386 | */ | ||
| 387 | typedef struct JOYSTICK_FEATURE | ||
| 388 | { | ||
| 389 | char* name; | ||
| 390 | JOYSTICK_FEATURE_TYPE type; | ||
| 391 | struct JOYSTICK_DRIVER_PRIMITIVE primitives[JOYSTICK_PRIMITIVE_MAX]; | ||
| 392 | } ATTRIBUTE_PACKED JOYSTICK_FEATURE; | ||
| 393 | ///} | ||
| 394 | |||
| 395 | typedef struct AddonProps_Peripheral | ||
| 396 | { | ||
| 397 | const char* user_path; /*!< @brief path to the user profile */ | ||
| 398 | const char* addon_path; /*!< @brief path to this add-on */ | ||
| 399 | } ATTRIBUTE_PACKED AddonProps_Peripheral; | ||
| 400 | |||
| 401 | struct AddonInstance_Peripheral; | ||
| 402 | |||
| 403 | typedef struct AddonToKodiFuncTable_Peripheral | ||
| 404 | { | ||
| 405 | KODI_HANDLE kodiInstance; | ||
| 406 | void (*trigger_scan)(void* kodiInstance); | ||
| 407 | void (*refresh_button_maps)(void* kodiInstance, const char* device_name, const char* controller_id); | ||
| 408 | unsigned int (*feature_count)(void* kodiInstance, const char* controller_id, JOYSTICK_FEATURE_TYPE type); | ||
| 409 | JOYSTICK_FEATURE_TYPE (*feature_type)(void* kodiInstance, const char* controller_id, const char* feature_name); | ||
| 410 | } AddonToKodiFuncTable_Peripheral; | ||
| 411 | |||
| 412 | //! @todo Mouse, light gun, multitouch | ||
| 413 | |||
| 414 | typedef struct KodiToAddonFuncTable_Peripheral | ||
| 415 | { | ||
| 416 | kodi::addon::CInstancePeripheral* addonInstance; | ||
| 417 | |||
| 418 | void (__cdecl* get_capabilities)(const AddonInstance_Peripheral* addonInstance, PERIPHERAL_CAPABILITIES* capabilities); | ||
| 419 | PERIPHERAL_ERROR (__cdecl* perform_device_scan)(const AddonInstance_Peripheral* addonInstance, unsigned int* peripheral_count, PERIPHERAL_INFO** scan_results); | ||
| 420 | void (__cdecl* free_scan_results)(const AddonInstance_Peripheral* addonInstance, unsigned int peripheral_count, PERIPHERAL_INFO* scan_results); | ||
| 421 | PERIPHERAL_ERROR (__cdecl* get_events)(const AddonInstance_Peripheral* addonInstance, unsigned int* event_count, PERIPHERAL_EVENT** events); | ||
| 422 | void (__cdecl* free_events)(const AddonInstance_Peripheral* addonInstance, unsigned int event_count, PERIPHERAL_EVENT* events); | ||
| 423 | bool (__cdecl* send_event)(const AddonInstance_Peripheral* addonInstance, const PERIPHERAL_EVENT* event); | ||
| 424 | |||
| 425 | /// @name Joystick operations | ||
| 426 | ///{ | ||
| 427 | PERIPHERAL_ERROR (__cdecl* get_joystick_info)(const AddonInstance_Peripheral* addonInstance, unsigned int index, JOYSTICK_INFO* info); | ||
| 428 | void (__cdecl* free_joystick_info)(const AddonInstance_Peripheral* addonInstance, JOYSTICK_INFO* info); | ||
| 429 | PERIPHERAL_ERROR (__cdecl* get_features)(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick, const char* controller_id, unsigned int* feature_count, JOYSTICK_FEATURE** features); | ||
| 430 | void (__cdecl* free_features)(const AddonInstance_Peripheral* addonInstance, unsigned int feature_count, JOYSTICK_FEATURE* features); | ||
| 431 | PERIPHERAL_ERROR (__cdecl* map_features)(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick, const char* controller_id, unsigned int feature_count, const JOYSTICK_FEATURE* features); | ||
| 432 | PERIPHERAL_ERROR (__cdecl* get_ignored_primitives)(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick, unsigned int* feature_count, JOYSTICK_DRIVER_PRIMITIVE** primitives); | ||
| 433 | void (__cdecl* free_primitives)(const AddonInstance_Peripheral* addonInstance, unsigned int, JOYSTICK_DRIVER_PRIMITIVE* primitives); | ||
| 434 | PERIPHERAL_ERROR (__cdecl* set_ignored_primitives)(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick, unsigned int primitive_count, const JOYSTICK_DRIVER_PRIMITIVE* primitives); | ||
| 435 | void (__cdecl* save_button_map)(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick); | ||
| 436 | void (__cdecl* revert_button_map)(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick); | ||
| 437 | void (__cdecl* reset_button_map)(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick, const char* controller_id); | ||
| 438 | void (__cdecl* power_off_joystick)(const AddonInstance_Peripheral* addonInstance, unsigned int index); | ||
| 439 | ///} | ||
| 440 | } KodiToAddonFuncTable_Peripheral; | ||
| 441 | |||
| 442 | typedef struct AddonInstance_Peripheral | ||
| 443 | { | ||
| 444 | AddonProps_Peripheral props; | ||
| 445 | AddonToKodiFuncTable_Peripheral toKodi; | ||
| 446 | KodiToAddonFuncTable_Peripheral toAddon; | ||
| 447 | } AddonInstance_Peripheral; | ||
| 448 | |||
| 449 | } /* extern "C" */ | ||
| 450 | |||
| 451 | namespace kodi | ||
| 452 | { | ||
| 453 | namespace addon | ||
| 454 | { | ||
| 455 | |||
| 456 | class ATTRIBUTE_HIDDEN CInstancePeripheral : public IAddonInstance | ||
| 457 | { | ||
| 458 | public: | ||
| 459 | CInstancePeripheral() | ||
| 460 | : IAddonInstance(ADDON_INSTANCE_PERIPHERAL, GetKodiTypeVersion(ADDON_INSTANCE_PERIPHERAL)) | ||
| 461 | { | ||
| 462 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 463 | throw std::logic_error("kodi::addon::CInstancePeripheral: Creation of more as one in single instance way is not allowed!"); | ||
| 464 | |||
| 465 | SetAddonStruct(CAddonBase::m_interface->firstKodiInstance); | ||
| 466 | CAddonBase::m_interface->globalSingleInstance = this; | ||
| 467 | } | ||
| 468 | |||
| 469 | explicit CInstancePeripheral(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 470 | : IAddonInstance(ADDON_INSTANCE_PERIPHERAL, | ||
| 471 | !kodiVersion.empty() ? kodiVersion | ||
| 472 | : GetKodiTypeVersion(ADDON_INSTANCE_PERIPHERAL)) | ||
| 473 | { | ||
| 474 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 475 | throw std::logic_error("kodi::addon::CInstancePeripheral: Creation of multiple together with single instance way is not allowed!"); | ||
| 476 | |||
| 477 | SetAddonStruct(instance); | ||
| 478 | } | ||
| 479 | |||
| 480 | ~CInstancePeripheral() override = default; | ||
| 481 | |||
| 482 | /// @name Peripheral operations | ||
| 483 | ///{ | ||
| 484 | /*! | ||
| 485 | * @brief Get the list of features that this add-on provides | ||
| 486 | * @param capabilities The add-on's capabilities. | ||
| 487 | * @remarks Valid implementation required. | ||
| 488 | * | ||
| 489 | * Called by the frontend to query the add-on's capabilities and supported | ||
| 490 | * peripherals. All capabilities that the add-on supports should be set to true. | ||
| 491 | * | ||
| 492 | */ | ||
| 493 | virtual void GetCapabilities(PERIPHERAL_CAPABILITIES &capabilities) { } | ||
| 494 | |||
| 495 | /*! | ||
| 496 | * @brief Perform a scan for joysticks | ||
| 497 | * @param peripheral_count Assigned to the number of peripherals allocated | ||
| 498 | * @param scan_results Assigned to allocated memory | ||
| 499 | * @return PERIPHERAL_NO_ERROR if successful; peripherals must be freed using | ||
| 500 | * FreeScanResults() in this case | ||
| 501 | * | ||
| 502 | * The frontend calls this when a hardware change is detected. If an add-on | ||
| 503 | * detects a hardware change, it can trigger this function using the | ||
| 504 | * TriggerScan() callback. | ||
| 505 | */ | ||
| 506 | virtual PERIPHERAL_ERROR PerformDeviceScan(unsigned int* peripheral_count, PERIPHERAL_INFO** scan_results) { return PERIPHERAL_ERROR_NOT_IMPLEMENTED; } | ||
| 507 | |||
| 508 | /*! | ||
| 509 | * @brief Free the memory allocated in PerformDeviceScan() | ||
| 510 | * | ||
| 511 | * Must be called if PerformDeviceScan() returns PERIPHERAL_NO_ERROR. | ||
| 512 | * | ||
| 513 | * @param peripheral_count The number of events allocated for the events array | ||
| 514 | * @param scan_results The array of allocated peripherals | ||
| 515 | */ | ||
| 516 | virtual void FreeScanResults(unsigned int peripheral_count, PERIPHERAL_INFO* scan_results) { } | ||
| 517 | |||
| 518 | /*! | ||
| 519 | * @brief Get all events that have occurred since the last call to GetEvents() | ||
| 520 | * @return PERIPHERAL_NO_ERROR if successful; events must be freed using | ||
| 521 | * FreeEvents() in this case | ||
| 522 | */ | ||
| 523 | virtual PERIPHERAL_ERROR GetEvents(unsigned int* event_count, PERIPHERAL_EVENT** events) { return PERIPHERAL_ERROR_NOT_IMPLEMENTED; } | ||
| 524 | |||
| 525 | /*! | ||
| 526 | * @brief Free the memory allocated in GetEvents() | ||
| 527 | * | ||
| 528 | * Must be called if GetEvents() returns PERIPHERAL_NO_ERROR. | ||
| 529 | * | ||
| 530 | * @param event_count The number of events allocated for the events array | ||
| 531 | * @param events The array of allocated events | ||
| 532 | */ | ||
| 533 | virtual void FreeEvents(unsigned int event_count, PERIPHERAL_EVENT* events) { } | ||
| 534 | |||
| 535 | /*! | ||
| 536 | * @brief Send an input event to the peripheral | ||
| 537 | * @param event The input event | ||
| 538 | * @return true if the event was handled, false otherwise | ||
| 539 | */ | ||
| 540 | virtual bool SendEvent(const PERIPHERAL_EVENT* event) { return false; } | ||
| 541 | ///} | ||
| 542 | |||
| 543 | /// @name Joystick operations | ||
| 544 | /*! | ||
| 545 | * @note #define PERIPHERAL_ADDON_JOYSTICKS before including kodi_peripheral_dll.h | ||
| 546 | * in the add-on if the add-on provides joysticks and add provides_joysticks="true" | ||
| 547 | * to the kodi.peripheral extension point node in addon.xml. | ||
| 548 | */ | ||
| 549 | ///{ | ||
| 550 | /*! | ||
| 551 | * @brief Get extended info about an attached joystick | ||
| 552 | * @param index The joystick's driver index | ||
| 553 | * @param info The container for the allocated joystick info | ||
| 554 | * @return PERIPHERAL_NO_ERROR if successful; array must be freed using | ||
| 555 | * FreeJoystickInfo() in this case | ||
| 556 | */ | ||
| 557 | virtual PERIPHERAL_ERROR GetJoystickInfo(unsigned int index, JOYSTICK_INFO* info) { return PERIPHERAL_ERROR_NOT_IMPLEMENTED; } | ||
| 558 | |||
| 559 | /*! | ||
| 560 | * @brief Free the memory allocated in GetJoystickInfo() | ||
| 561 | */ | ||
| 562 | virtual void FreeJoystickInfo(JOYSTICK_INFO* info) { } | ||
| 563 | |||
| 564 | /*! | ||
| 565 | * @brief Get the features that allow translating the joystick into the controller profile | ||
| 566 | * @param joystick The device's joystick properties; unknown values may be left at their default | ||
| 567 | * @param controller_id The controller profile being requested, e.g. game.controller.default | ||
| 568 | * @param feature_count The number of features allocated for the features array | ||
| 569 | * @param features The array of allocated features | ||
| 570 | * @return PERIPHERAL_NO_ERROR if successful; array must be freed using | ||
| 571 | * FreeButtonMap() in this case | ||
| 572 | */ | ||
| 573 | virtual PERIPHERAL_ERROR GetFeatures(const JOYSTICK_INFO* joystick, const char* controller_id, | ||
| 574 | unsigned int* feature_count, JOYSTICK_FEATURE** features) { return PERIPHERAL_ERROR_NOT_IMPLEMENTED; } | ||
| 575 | |||
| 576 | /*! | ||
| 577 | * @brief Free the memory allocated in GetFeatures() | ||
| 578 | * | ||
| 579 | * Must be called if GetFeatures() returns PERIPHERAL_NO_ERROR. | ||
| 580 | * | ||
| 581 | * @param feature_count The number of features allocated for the features array | ||
| 582 | * @param features The array of allocated features | ||
| 583 | */ | ||
| 584 | virtual void FreeFeatures(unsigned int feature_count, JOYSTICK_FEATURE* features) { } | ||
| 585 | |||
| 586 | /*! | ||
| 587 | * @brief Add or update joystick features | ||
| 588 | * @param joystick The device's joystick properties; unknown values may be left at their default | ||
| 589 | * @param controller_id The game controller profile being updated | ||
| 590 | * @param feature_count The number of features in the features array | ||
| 591 | * @param features The array of features | ||
| 592 | * @return PERIPHERAL_NO_ERROR if successful | ||
| 593 | */ | ||
| 594 | virtual PERIPHERAL_ERROR MapFeatures(const JOYSTICK_INFO* joystick, const char* controller_id, | ||
| 595 | unsigned int feature_count, const JOYSTICK_FEATURE* features) { return PERIPHERAL_ERROR_NOT_IMPLEMENTED; } | ||
| 596 | |||
| 597 | /*! | ||
| 598 | * @brief Get the driver primitives that should be ignored while mapping the device | ||
| 599 | * @param joystick The device's joystick properties; unknown values may be left at their default | ||
| 600 | * @param primitive_count The number of features allocated for the primitives array | ||
| 601 | * @param primitives The array of allocated driver primitives to be ignored | ||
| 602 | * @return PERIPHERAL_NO_ERROR if successful; array must be freed using | ||
| 603 | * FreePrimitives() in this case | ||
| 604 | */ | ||
| 605 | virtual PERIPHERAL_ERROR GetIgnoredPrimitives(const JOYSTICK_INFO* joystick, | ||
| 606 | unsigned int* primitive_count, | ||
| 607 | JOYSTICK_DRIVER_PRIMITIVE** primitives) { return PERIPHERAL_ERROR_NOT_IMPLEMENTED; } | ||
| 608 | |||
| 609 | /*! | ||
| 610 | * @brief Free the memory allocated in GetIgnoredPrimitives() | ||
| 611 | * | ||
| 612 | * Must be called if GetIgnoredPrimitives() returns PERIPHERAL_NO_ERROR. | ||
| 613 | * | ||
| 614 | * @param primitive_count The number of driver primitives allocated for the primitives array | ||
| 615 | * @param primitives The array of allocated driver primitives | ||
| 616 | */ | ||
| 617 | virtual void FreePrimitives(unsigned int primitive_count, JOYSTICK_DRIVER_PRIMITIVE* primitives) { } | ||
| 618 | |||
| 619 | /*! | ||
| 620 | * @brief Set the list of driver primitives that are ignored for the device | ||
| 621 | * @param joystick The device's joystick properties; unknown values may be left at their default | ||
| 622 | * @param primitive_count The number of driver features in the primitives array | ||
| 623 | * @param primitives The array of driver primitives to ignore | ||
| 624 | * @return PERIPHERAL_NO_ERROR if successful | ||
| 625 | */ | ||
| 626 | virtual PERIPHERAL_ERROR SetIgnoredPrimitives(const JOYSTICK_INFO* joystick, | ||
| 627 | unsigned int primitive_count, | ||
| 628 | const JOYSTICK_DRIVER_PRIMITIVE* primitives) { return PERIPHERAL_ERROR_NOT_IMPLEMENTED; } | ||
| 629 | |||
| 630 | /*! | ||
| 631 | * @brief Save the button map for the given joystick | ||
| 632 | * @param joystick The device's joystick properties | ||
| 633 | */ | ||
| 634 | virtual void SaveButtonMap(const JOYSTICK_INFO* joystick) { } | ||
| 635 | |||
| 636 | /*! | ||
| 637 | * @brief Revert the button map to the last time it was loaded or committed to disk | ||
| 638 | * @param joystick The device's joystick properties | ||
| 639 | */ | ||
| 640 | virtual void RevertButtonMap(const JOYSTICK_INFO* joystick) { } | ||
| 641 | |||
| 642 | /*! | ||
| 643 | * @brief Reset the button map for the given joystick and controller profile ID | ||
| 644 | * @param joystick The device's joystick properties | ||
| 645 | * @param controller_id The game controller profile being reset | ||
| 646 | */ | ||
| 647 | virtual void ResetButtonMap(const JOYSTICK_INFO* joystick, const char* controller_id) { } | ||
| 648 | |||
| 649 | /*! | ||
| 650 | * @brief Powers off the given joystick if supported | ||
| 651 | * @param index The joystick's driver index | ||
| 652 | */ | ||
| 653 | virtual void PowerOffJoystick(unsigned int index) { } | ||
| 654 | |||
| 655 | const std::string AddonPath() const | ||
| 656 | { | ||
| 657 | return m_instanceData->props.addon_path; | ||
| 658 | } | ||
| 659 | |||
| 660 | const std::string UserPath() const | ||
| 661 | { | ||
| 662 | return m_instanceData->props.user_path; | ||
| 663 | } | ||
| 664 | |||
| 665 | /*! | ||
| 666 | * @brief Trigger a scan for peripherals | ||
| 667 | * | ||
| 668 | * The add-on calls this if a change in hardware is detected. | ||
| 669 | */ | ||
| 670 | void TriggerScan(void) | ||
| 671 | { | ||
| 672 | return m_instanceData->toKodi.trigger_scan(m_instanceData->toKodi.kodiInstance); | ||
| 673 | } | ||
| 674 | |||
| 675 | /*! | ||
| 676 | * @brief Notify the frontend that button maps have changed | ||
| 677 | * | ||
| 678 | * @param[optional] deviceName The name of the device to refresh, or empty/null for all devices | ||
| 679 | * @param[optional] controllerId The controller ID to refresh, or empty/null for all controllers | ||
| 680 | */ | ||
| 681 | void RefreshButtonMaps(const std::string& deviceName = "", const std::string& controllerId = "") | ||
| 682 | { | ||
| 683 | return m_instanceData->toKodi.refresh_button_maps(m_instanceData->toKodi.kodiInstance, deviceName.c_str(), controllerId.c_str()); | ||
| 684 | } | ||
| 685 | |||
| 686 | /*! | ||
| 687 | * @brief Return the number of features belonging to the specified controller | ||
| 688 | * | ||
| 689 | * @param controllerId The controller ID to enumerate | ||
| 690 | * @param type[optional] Type to filter by, or JOYSTICK_FEATURE_TYPE_UNKNOWN for all features | ||
| 691 | * | ||
| 692 | * @return The number of features matching the request parameters | ||
| 693 | */ | ||
| 694 | unsigned int FeatureCount(const std::string& controllerId, JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN) | ||
| 695 | { | ||
| 696 | return m_instanceData->toKodi.feature_count(m_instanceData->toKodi.kodiInstance, controllerId.c_str(), type); | ||
| 697 | } | ||
| 698 | |||
| 699 | /*! | ||
| 700 | * @brief Return the type of the feature | ||
| 701 | * | ||
| 702 | * @param controllerId The controller ID to check | ||
| 703 | * @param featureName The feature to check | ||
| 704 | * | ||
| 705 | * @return The type of the specified feature, or JOYSTICK_FEATURE_TYPE_UNKNOWN | ||
| 706 | * if unknown | ||
| 707 | */ | ||
| 708 | JOYSTICK_FEATURE_TYPE FeatureType(const std::string& controllerId, const std::string &featureName) | ||
| 709 | { | ||
| 710 | return m_instanceData->toKodi.feature_type(m_instanceData->toKodi.kodiInstance, controllerId.c_str(), featureName.c_str()); | ||
| 711 | } | ||
| 712 | |||
| 713 | private: | ||
| 714 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 715 | { | ||
| 716 | if (instance == nullptr) | ||
| 717 | throw std::logic_error("kodi::addon::CInstancePeripheral: Creation with empty addon structure not allowed, table must be given from Kodi!"); | ||
| 718 | |||
| 719 | m_instanceData = static_cast<AddonInstance_Peripheral*>(instance); | ||
| 720 | m_instanceData->toAddon.addonInstance = this; | ||
| 721 | |||
| 722 | m_instanceData->toAddon.get_capabilities = ADDON_GetCapabilities; | ||
| 723 | m_instanceData->toAddon.perform_device_scan = ADDON_PerformDeviceScan; | ||
| 724 | m_instanceData->toAddon.free_scan_results = ADDON_FreeScanResults; | ||
| 725 | m_instanceData->toAddon.get_events = ADDON_GetEvents; | ||
| 726 | m_instanceData->toAddon.free_events = ADDON_FreeEvents; | ||
| 727 | m_instanceData->toAddon.send_event = ADDON_SendEvent; | ||
| 728 | |||
| 729 | m_instanceData->toAddon.get_joystick_info = ADDON_GetJoystickInfo; | ||
| 730 | m_instanceData->toAddon.free_joystick_info = ADDON_FreeJoystickInfo; | ||
| 731 | m_instanceData->toAddon.get_features = ADDON_GetFeatures; | ||
| 732 | m_instanceData->toAddon.free_features = ADDON_FreeFeatures; | ||
| 733 | m_instanceData->toAddon.map_features = ADDON_MapFeatures; | ||
| 734 | m_instanceData->toAddon.get_ignored_primitives = ADDON_GetIgnoredPrimitives; | ||
| 735 | m_instanceData->toAddon.free_primitives = ADDON_FreePrimitives; | ||
| 736 | m_instanceData->toAddon.set_ignored_primitives = ADDON_SetIgnoredPrimitives; | ||
| 737 | m_instanceData->toAddon.save_button_map = ADDON_SaveButtonMap; | ||
| 738 | m_instanceData->toAddon.revert_button_map = ADDON_RevertButtonMap; | ||
| 739 | m_instanceData->toAddon.reset_button_map = ADDON_ResetButtonMap; | ||
| 740 | m_instanceData->toAddon.power_off_joystick = ADDON_PowerOffJoystick; | ||
| 741 | } | ||
| 742 | |||
| 743 | inline static void ADDON_GetCapabilities(const AddonInstance_Peripheral* addonInstance, PERIPHERAL_CAPABILITIES *capabilities) | ||
| 744 | { | ||
| 745 | addonInstance->toAddon.addonInstance->GetCapabilities(*capabilities); | ||
| 746 | } | ||
| 747 | |||
| 748 | inline static PERIPHERAL_ERROR ADDON_PerformDeviceScan(const AddonInstance_Peripheral* addonInstance, unsigned int* peripheral_count, PERIPHERAL_INFO** scan_results) | ||
| 749 | { | ||
| 750 | return addonInstance->toAddon.addonInstance->PerformDeviceScan(peripheral_count, scan_results); | ||
| 751 | } | ||
| 752 | |||
| 753 | inline static void ADDON_FreeScanResults(const AddonInstance_Peripheral* addonInstance, unsigned int peripheral_count, PERIPHERAL_INFO* scan_results) | ||
| 754 | { | ||
| 755 | addonInstance->toAddon.addonInstance->FreeScanResults(peripheral_count, scan_results); | ||
| 756 | } | ||
| 757 | |||
| 758 | inline static PERIPHERAL_ERROR ADDON_GetEvents(const AddonInstance_Peripheral* addonInstance, unsigned int* event_count, PERIPHERAL_EVENT** events) | ||
| 759 | { | ||
| 760 | return addonInstance->toAddon.addonInstance->GetEvents(event_count, events); | ||
| 761 | } | ||
| 762 | |||
| 763 | inline static void ADDON_FreeEvents(const AddonInstance_Peripheral* addonInstance, unsigned int event_count, PERIPHERAL_EVENT* events) | ||
| 764 | { | ||
| 765 | addonInstance->toAddon.addonInstance->FreeEvents(event_count, events); | ||
| 766 | } | ||
| 767 | |||
| 768 | inline static bool ADDON_SendEvent(const AddonInstance_Peripheral* addonInstance, const PERIPHERAL_EVENT* event) | ||
| 769 | { | ||
| 770 | return addonInstance->toAddon.addonInstance->SendEvent(event); | ||
| 771 | } | ||
| 772 | |||
| 773 | |||
| 774 | inline static PERIPHERAL_ERROR ADDON_GetJoystickInfo(const AddonInstance_Peripheral* addonInstance, unsigned int index, JOYSTICK_INFO* info) | ||
| 775 | { | ||
| 776 | return addonInstance->toAddon.addonInstance->GetJoystickInfo(index, info); | ||
| 777 | } | ||
| 778 | |||
| 779 | inline static void ADDON_FreeJoystickInfo(const AddonInstance_Peripheral* addonInstance, JOYSTICK_INFO* info) | ||
| 780 | { | ||
| 781 | addonInstance->toAddon.addonInstance->FreeJoystickInfo(info); | ||
| 782 | } | ||
| 783 | |||
| 784 | inline static PERIPHERAL_ERROR ADDON_GetFeatures(const AddonInstance_Peripheral* addonInstance, | ||
| 785 | const JOYSTICK_INFO* joystick, const char* controller_id, | ||
| 786 | unsigned int* feature_count, JOYSTICK_FEATURE** features) | ||
| 787 | { | ||
| 788 | return addonInstance->toAddon.addonInstance->GetFeatures(joystick, controller_id, feature_count, features); | ||
| 789 | } | ||
| 790 | |||
| 791 | inline static void ADDON_FreeFeatures(const AddonInstance_Peripheral* addonInstance, unsigned int feature_count, JOYSTICK_FEATURE* features) | ||
| 792 | { | ||
| 793 | addonInstance->toAddon.addonInstance->FreeFeatures(feature_count, features); | ||
| 794 | } | ||
| 795 | |||
| 796 | inline static PERIPHERAL_ERROR ADDON_MapFeatures(const AddonInstance_Peripheral* addonInstance, | ||
| 797 | const JOYSTICK_INFO* joystick, const char* controller_id, | ||
| 798 | unsigned int feature_count, const JOYSTICK_FEATURE* features) | ||
| 799 | { | ||
| 800 | return addonInstance->toAddon.addonInstance->MapFeatures(joystick, controller_id, feature_count, features); | ||
| 801 | } | ||
| 802 | |||
| 803 | inline static PERIPHERAL_ERROR ADDON_GetIgnoredPrimitives(const AddonInstance_Peripheral* addonInstance, | ||
| 804 | const JOYSTICK_INFO* joystick, unsigned int* primitive_count, | ||
| 805 | JOYSTICK_DRIVER_PRIMITIVE** primitives) | ||
| 806 | { | ||
| 807 | return addonInstance->toAddon.addonInstance->GetIgnoredPrimitives(joystick, primitive_count, primitives); | ||
| 808 | } | ||
| 809 | |||
| 810 | inline static void ADDON_FreePrimitives(const AddonInstance_Peripheral* addonInstance, | ||
| 811 | unsigned int primitive_count, JOYSTICK_DRIVER_PRIMITIVE* primitives) | ||
| 812 | { | ||
| 813 | addonInstance->toAddon.addonInstance->FreePrimitives(primitive_count, primitives); | ||
| 814 | } | ||
| 815 | |||
| 816 | inline static PERIPHERAL_ERROR ADDON_SetIgnoredPrimitives(const AddonInstance_Peripheral* addonInstance, | ||
| 817 | const JOYSTICK_INFO* joystick, unsigned int primitive_count, | ||
| 818 | const JOYSTICK_DRIVER_PRIMITIVE* primitives) | ||
| 819 | { | ||
| 820 | return addonInstance->toAddon.addonInstance->SetIgnoredPrimitives(joystick, primitive_count, primitives); | ||
| 821 | } | ||
| 822 | |||
| 823 | inline static void ADDON_SaveButtonMap(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick) | ||
| 824 | { | ||
| 825 | addonInstance->toAddon.addonInstance->SaveButtonMap(joystick); | ||
| 826 | } | ||
| 827 | |||
| 828 | inline static void ADDON_RevertButtonMap(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick) | ||
| 829 | { | ||
| 830 | addonInstance->toAddon.addonInstance->RevertButtonMap(joystick); | ||
| 831 | } | ||
| 832 | |||
| 833 | inline static void ADDON_ResetButtonMap(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick, const char* controller_id) | ||
| 834 | { | ||
| 835 | addonInstance->toAddon.addonInstance->ResetButtonMap(joystick, controller_id); | ||
| 836 | } | ||
| 837 | |||
| 838 | inline static void ADDON_PowerOffJoystick(const AddonInstance_Peripheral* addonInstance, unsigned int index) | ||
| 839 | { | ||
| 840 | addonInstance->toAddon.addonInstance->PowerOffJoystick(index); | ||
| 841 | } | ||
| 842 | |||
| 843 | AddonInstance_Peripheral* m_instanceData; | ||
| 844 | }; | ||
| 845 | |||
| 846 | } /* namespace addon */ | ||
| 847 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h deleted file mode 100644 index 62e5a93..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h +++ /dev/null | |||
| @@ -1,735 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "Peripheral.h" | ||
| 12 | |||
| 13 | #include <array> // Requires c++11 | ||
| 14 | #include <cstring> | ||
| 15 | #include <string> | ||
| 16 | #include <utility> | ||
| 17 | #include <vector> | ||
| 18 | |||
| 19 | #define PERIPHERAL_SAFE_DELETE(x) do { delete (x); (x) = NULL; } while (0) | ||
| 20 | #define PERIPHERAL_SAFE_DELETE_ARRAY(x) do { delete[] (x); (x) = NULL; } while (0) | ||
| 21 | |||
| 22 | namespace kodi | ||
| 23 | { | ||
| 24 | namespace addon | ||
| 25 | { | ||
| 26 | /*! | ||
| 27 | * Utility class to manipulate arrays of peripheral types. | ||
| 28 | */ | ||
| 29 | template <class THE_CLASS, typename THE_STRUCT> | ||
| 30 | class PeripheralVector | ||
| 31 | { | ||
| 32 | public: | ||
| 33 | static void ToStructs(const std::vector<THE_CLASS>& vecObjects, THE_STRUCT** pStructs) | ||
| 34 | { | ||
| 35 | if (!pStructs) | ||
| 36 | return; | ||
| 37 | |||
| 38 | if (vecObjects.empty()) | ||
| 39 | { | ||
| 40 | *pStructs = NULL; | ||
| 41 | } | ||
| 42 | else | ||
| 43 | { | ||
| 44 | (*pStructs) = new THE_STRUCT[vecObjects.size()]; | ||
| 45 | for (unsigned int i = 0; i < vecObjects.size(); i++) | ||
| 46 | vecObjects.at(i).ToStruct((*pStructs)[i]); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | static void ToStructs(const std::vector<THE_CLASS*>& vecObjects, THE_STRUCT** pStructs) | ||
| 51 | { | ||
| 52 | if (!pStructs) | ||
| 53 | return; | ||
| 54 | |||
| 55 | if (vecObjects.empty()) | ||
| 56 | { | ||
| 57 | *pStructs = NULL; | ||
| 58 | } | ||
| 59 | else | ||
| 60 | { | ||
| 61 | *pStructs = new THE_STRUCT[vecObjects.size()]; | ||
| 62 | for (unsigned int i = 0; i < vecObjects.size(); i++) | ||
| 63 | vecObjects.at(i)->ToStruct((*pStructs)[i]); | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | static void FreeStructs(unsigned int structCount, THE_STRUCT* structs) | ||
| 68 | { | ||
| 69 | if (structs) | ||
| 70 | { | ||
| 71 | for (unsigned int i = 0; i < structCount; i++) | ||
| 72 | THE_CLASS::FreeStruct(structs[i]); | ||
| 73 | } | ||
| 74 | PERIPHERAL_SAFE_DELETE_ARRAY(structs); | ||
| 75 | } | ||
| 76 | }; | ||
| 77 | |||
| 78 | /*! | ||
| 79 | * ADDON::Peripheral | ||
| 80 | * | ||
| 81 | * Wrapper class providing peripheral information. Classes can extend | ||
| 82 | * Peripheral to inherit peripheral properties. | ||
| 83 | */ | ||
| 84 | class Peripheral | ||
| 85 | { | ||
| 86 | public: | ||
| 87 | Peripheral(PERIPHERAL_TYPE type = PERIPHERAL_TYPE_UNKNOWN, const std::string& strName = "") : | ||
| 88 | m_type(type), | ||
| 89 | m_strName(strName) | ||
| 90 | { | ||
| 91 | } | ||
| 92 | |||
| 93 | explicit Peripheral(const PERIPHERAL_INFO& info) : | ||
| 94 | m_type(info.type), | ||
| 95 | m_strName(info.name ? info.name : ""), | ||
| 96 | m_vendorId(info.vendor_id), | ||
| 97 | m_productId(info.product_id), | ||
| 98 | m_index(info.index) | ||
| 99 | { | ||
| 100 | } | ||
| 101 | |||
| 102 | virtual ~Peripheral(void) = default; | ||
| 103 | |||
| 104 | PERIPHERAL_TYPE Type(void) const { return m_type; } | ||
| 105 | const std::string& Name(void) const { return m_strName; } | ||
| 106 | uint16_t VendorID(void) const { return m_vendorId; } | ||
| 107 | uint16_t ProductID(void) const { return m_productId; } | ||
| 108 | unsigned int Index(void) const { return m_index; } | ||
| 109 | |||
| 110 | // Derived property: VID and PID are 0x0000 if unknown | ||
| 111 | bool IsVidPidKnown(void) const { return m_vendorId != 0 || m_productId != 0; } | ||
| 112 | |||
| 113 | void SetType(PERIPHERAL_TYPE type) { m_type = type; } | ||
| 114 | void SetName(const std::string& strName) { m_strName = strName; } | ||
| 115 | void SetVendorID(uint16_t vendorId) { m_vendorId = vendorId; } | ||
| 116 | void SetProductID(uint16_t productId) { m_productId = productId; } | ||
| 117 | void SetIndex(unsigned int index) { m_index = index; } | ||
| 118 | |||
| 119 | void ToStruct(PERIPHERAL_INFO& info) const | ||
| 120 | { | ||
| 121 | info.type = m_type; | ||
| 122 | info.name = new char[m_strName.size() + 1]; | ||
| 123 | info.vendor_id = m_vendorId; | ||
| 124 | info.product_id = m_productId; | ||
| 125 | info.index = m_index; | ||
| 126 | |||
| 127 | std::strcpy(info.name, m_strName.c_str()); | ||
| 128 | } | ||
| 129 | |||
| 130 | static void FreeStruct(PERIPHERAL_INFO& info) | ||
| 131 | { | ||
| 132 | PERIPHERAL_SAFE_DELETE_ARRAY(info.name); | ||
| 133 | } | ||
| 134 | |||
| 135 | private: | ||
| 136 | PERIPHERAL_TYPE m_type; | ||
| 137 | std::string m_strName; | ||
| 138 | uint16_t m_vendorId = 0; | ||
| 139 | uint16_t m_productId = 0; | ||
| 140 | unsigned int m_index = 0; | ||
| 141 | }; | ||
| 142 | |||
| 143 | typedef PeripheralVector<Peripheral, PERIPHERAL_INFO> Peripherals; | ||
| 144 | |||
| 145 | /*! | ||
| 146 | * ADDON::PeripheralEvent | ||
| 147 | * | ||
| 148 | * Wrapper class for peripheral events. | ||
| 149 | */ | ||
| 150 | class PeripheralEvent | ||
| 151 | { | ||
| 152 | public: | ||
| 153 | PeripheralEvent() = default; | ||
| 154 | |||
| 155 | PeripheralEvent(unsigned int peripheralIndex, unsigned int buttonIndex, JOYSTICK_STATE_BUTTON state) : | ||
| 156 | m_type(PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON), | ||
| 157 | m_peripheralIndex(peripheralIndex), | ||
| 158 | m_driverIndex(buttonIndex), | ||
| 159 | m_buttonState(state) | ||
| 160 | { | ||
| 161 | } | ||
| 162 | |||
| 163 | PeripheralEvent(unsigned int peripheralIndex, unsigned int hatIndex, JOYSTICK_STATE_HAT state) : | ||
| 164 | m_type(PERIPHERAL_EVENT_TYPE_DRIVER_HAT), | ||
| 165 | m_peripheralIndex(peripheralIndex), | ||
| 166 | m_driverIndex(hatIndex), | ||
| 167 | m_hatState(state) | ||
| 168 | { | ||
| 169 | } | ||
| 170 | |||
| 171 | PeripheralEvent(unsigned int peripheralIndex, unsigned int axisIndex, JOYSTICK_STATE_AXIS state) : | ||
| 172 | m_type(PERIPHERAL_EVENT_TYPE_DRIVER_AXIS), | ||
| 173 | m_peripheralIndex(peripheralIndex), | ||
| 174 | m_driverIndex(axisIndex), | ||
| 175 | m_axisState(state) | ||
| 176 | { | ||
| 177 | } | ||
| 178 | |||
| 179 | explicit PeripheralEvent(const PERIPHERAL_EVENT& event) : | ||
| 180 | m_type(event.type), | ||
| 181 | m_peripheralIndex(event.peripheral_index), | ||
| 182 | m_driverIndex(event.driver_index), | ||
| 183 | m_buttonState(event.driver_button_state), | ||
| 184 | m_hatState(event.driver_hat_state), | ||
| 185 | m_axisState(event.driver_axis_state), | ||
| 186 | m_motorState(event.motor_state) | ||
| 187 | { | ||
| 188 | } | ||
| 189 | |||
| 190 | PERIPHERAL_EVENT_TYPE Type(void) const { return m_type; } | ||
| 191 | unsigned int PeripheralIndex(void) const { return m_peripheralIndex; } | ||
| 192 | unsigned int DriverIndex(void) const { return m_driverIndex; } | ||
| 193 | JOYSTICK_STATE_BUTTON ButtonState(void) const { return m_buttonState; } | ||
| 194 | JOYSTICK_STATE_HAT HatState(void) const { return m_hatState; } | ||
| 195 | JOYSTICK_STATE_AXIS AxisState(void) const { return m_axisState; } | ||
| 196 | JOYSTICK_STATE_MOTOR MotorState(void) const { return m_motorState; } | ||
| 197 | |||
| 198 | void SetType(PERIPHERAL_EVENT_TYPE type) { m_type = type; } | ||
| 199 | void SetPeripheralIndex(unsigned int index) { m_peripheralIndex = index; } | ||
| 200 | void SetDriverIndex(unsigned int index) { m_driverIndex = index; } | ||
| 201 | void SetButtonState(JOYSTICK_STATE_BUTTON state) { m_buttonState = state; } | ||
| 202 | void SetHatState(JOYSTICK_STATE_HAT state) { m_hatState = state; } | ||
| 203 | void SetAxisState(JOYSTICK_STATE_AXIS state) { m_axisState = state; } | ||
| 204 | void SetMotorState(JOYSTICK_STATE_MOTOR state) { m_motorState = state; } | ||
| 205 | |||
| 206 | void ToStruct(PERIPHERAL_EVENT& event) const | ||
| 207 | { | ||
| 208 | event.type = m_type; | ||
| 209 | event.peripheral_index = m_peripheralIndex; | ||
| 210 | event.driver_index = m_driverIndex; | ||
| 211 | event.driver_button_state = m_buttonState; | ||
| 212 | event.driver_hat_state = m_hatState; | ||
| 213 | event.driver_axis_state = m_axisState; | ||
| 214 | event.motor_state = m_motorState; | ||
| 215 | } | ||
| 216 | |||
| 217 | static void FreeStruct(PERIPHERAL_EVENT& event) | ||
| 218 | { | ||
| 219 | (void)event; | ||
| 220 | } | ||
| 221 | |||
| 222 | private: | ||
| 223 | PERIPHERAL_EVENT_TYPE m_type = PERIPHERAL_EVENT_TYPE_NONE; | ||
| 224 | unsigned int m_peripheralIndex = 0; | ||
| 225 | unsigned int m_driverIndex = 0; | ||
| 226 | JOYSTICK_STATE_BUTTON m_buttonState = JOYSTICK_STATE_BUTTON_UNPRESSED; | ||
| 227 | JOYSTICK_STATE_HAT m_hatState = JOYSTICK_STATE_HAT_UNPRESSED; | ||
| 228 | JOYSTICK_STATE_AXIS m_axisState = 0.0f; | ||
| 229 | JOYSTICK_STATE_MOTOR m_motorState = 0.0f; | ||
| 230 | }; | ||
| 231 | |||
| 232 | typedef PeripheralVector<PeripheralEvent, PERIPHERAL_EVENT> PeripheralEvents; | ||
| 233 | |||
| 234 | /*! | ||
| 235 | * kodi::addon::Joystick | ||
| 236 | * | ||
| 237 | * Wrapper class providing additional joystick information not provided by | ||
| 238 | * ADDON::Peripheral. | ||
| 239 | */ | ||
| 240 | class Joystick : public Peripheral | ||
| 241 | { | ||
| 242 | public: | ||
| 243 | Joystick(const std::string& provider = "", const std::string& strName = "") : | ||
| 244 | Peripheral(PERIPHERAL_TYPE_JOYSTICK, strName), | ||
| 245 | m_provider(provider), | ||
| 246 | m_requestedPort(NO_PORT_REQUESTED) | ||
| 247 | { | ||
| 248 | } | ||
| 249 | |||
| 250 | Joystick(const Joystick& other) | ||
| 251 | { | ||
| 252 | *this = other; | ||
| 253 | } | ||
| 254 | |||
| 255 | explicit Joystick(const JOYSTICK_INFO& info) : | ||
| 256 | Peripheral(info.peripheral), | ||
| 257 | m_provider(info.provider ? info.provider : ""), | ||
| 258 | m_requestedPort(info.requested_port), | ||
| 259 | m_buttonCount(info.button_count), | ||
| 260 | m_hatCount(info.hat_count), | ||
| 261 | m_axisCount(info.axis_count), | ||
| 262 | m_motorCount(info.motor_count), | ||
| 263 | m_supportsPowerOff(info.supports_poweroff) | ||
| 264 | { | ||
| 265 | } | ||
| 266 | |||
| 267 | ~Joystick(void) override = default; | ||
| 268 | |||
| 269 | Joystick& operator=(const Joystick& rhs) | ||
| 270 | { | ||
| 271 | if (this != &rhs) | ||
| 272 | { | ||
| 273 | Peripheral::operator=(rhs); | ||
| 274 | |||
| 275 | m_provider = rhs.m_provider; | ||
| 276 | m_requestedPort = rhs.m_requestedPort; | ||
| 277 | m_buttonCount = rhs.m_buttonCount; | ||
| 278 | m_hatCount = rhs.m_hatCount; | ||
| 279 | m_axisCount = rhs.m_axisCount; | ||
| 280 | m_motorCount = rhs.m_motorCount; | ||
| 281 | m_supportsPowerOff = rhs.m_supportsPowerOff; | ||
| 282 | } | ||
| 283 | return *this; | ||
| 284 | } | ||
| 285 | |||
| 286 | const std::string& Provider(void) const { return m_provider; } | ||
| 287 | int RequestedPort(void) const { return m_requestedPort; } | ||
| 288 | unsigned int ButtonCount(void) const { return m_buttonCount; } | ||
| 289 | unsigned int HatCount(void) const { return m_hatCount; } | ||
| 290 | unsigned int AxisCount(void) const { return m_axisCount; } | ||
| 291 | unsigned int MotorCount(void) const { return m_motorCount; } | ||
| 292 | bool SupportsPowerOff(void) const { return m_supportsPowerOff; } | ||
| 293 | |||
| 294 | void SetProvider(const std::string& provider) { m_provider = provider; } | ||
| 295 | void SetRequestedPort(int requestedPort) { m_requestedPort = requestedPort; } | ||
| 296 | void SetButtonCount(unsigned int buttonCount) { m_buttonCount = buttonCount; } | ||
| 297 | void SetHatCount(unsigned int hatCount) { m_hatCount = hatCount; } | ||
| 298 | void SetAxisCount(unsigned int axisCount) { m_axisCount = axisCount; } | ||
| 299 | void SetMotorCount(unsigned int motorCount) { m_motorCount = motorCount; } | ||
| 300 | void SetSupportsPowerOff(bool supportsPowerOff) { m_supportsPowerOff = supportsPowerOff; } | ||
| 301 | |||
| 302 | void ToStruct(JOYSTICK_INFO& info) const | ||
| 303 | { | ||
| 304 | Peripheral::ToStruct(info.peripheral); | ||
| 305 | |||
| 306 | info.provider = new char[m_provider.size() + 1]; | ||
| 307 | info.requested_port = m_requestedPort; | ||
| 308 | info.button_count = m_buttonCount; | ||
| 309 | info.hat_count = m_hatCount; | ||
| 310 | info.axis_count = m_axisCount; | ||
| 311 | info.motor_count = m_motorCount; | ||
| 312 | info.supports_poweroff = m_supportsPowerOff; | ||
| 313 | |||
| 314 | std::strcpy(info.provider, m_provider.c_str()); | ||
| 315 | } | ||
| 316 | |||
| 317 | static void FreeStruct(JOYSTICK_INFO& info) | ||
| 318 | { | ||
| 319 | Peripheral::FreeStruct(info.peripheral); | ||
| 320 | |||
| 321 | PERIPHERAL_SAFE_DELETE_ARRAY(info.provider); | ||
| 322 | } | ||
| 323 | |||
| 324 | private: | ||
| 325 | std::string m_provider; | ||
| 326 | int m_requestedPort; | ||
| 327 | unsigned int m_buttonCount = 0; | ||
| 328 | unsigned int m_hatCount = 0; | ||
| 329 | unsigned int m_axisCount = 0; | ||
| 330 | unsigned int m_motorCount = 0; | ||
| 331 | bool m_supportsPowerOff = false; | ||
| 332 | }; | ||
| 333 | |||
| 334 | typedef PeripheralVector<Joystick, JOYSTICK_INFO> Joysticks; | ||
| 335 | |||
| 336 | /*! | ||
| 337 | * ADDON::DriverPrimitive | ||
| 338 | * | ||
| 339 | * Base class for joystick driver primitives. A driver primitive can be: | ||
| 340 | * | ||
| 341 | * 1) a button | ||
| 342 | * 2) a hat direction | ||
| 343 | * 3) a semiaxis (either the positive or negative half of an axis) | ||
| 344 | * 4) a motor | ||
| 345 | * 5) a keyboard key | ||
| 346 | * 6) a mouse button | ||
| 347 | * 7) a relative pointer direction | ||
| 348 | * | ||
| 349 | * The type determines the fields in use: | ||
| 350 | * | ||
| 351 | * Button: | ||
| 352 | * - driver index | ||
| 353 | * | ||
| 354 | * Hat direction: | ||
| 355 | * - driver index | ||
| 356 | * - hat direction | ||
| 357 | * | ||
| 358 | * Semiaxis: | ||
| 359 | * - driver index | ||
| 360 | * - center | ||
| 361 | * - semiaxis direction | ||
| 362 | * - range | ||
| 363 | * | ||
| 364 | * Motor: | ||
| 365 | * - driver index | ||
| 366 | * | ||
| 367 | * Key: | ||
| 368 | * - key code | ||
| 369 | * | ||
| 370 | * Mouse button: | ||
| 371 | * - driver index | ||
| 372 | * | ||
| 373 | * Relative pointer direction: | ||
| 374 | * - relative pointer direction | ||
| 375 | */ | ||
| 376 | struct DriverPrimitive | ||
| 377 | { | ||
| 378 | protected: | ||
| 379 | /*! | ||
| 380 | * \brief Construct a driver primitive of the specified type | ||
| 381 | */ | ||
| 382 | DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE type, unsigned int driverIndex) : | ||
| 383 | m_type(type), | ||
| 384 | m_driverIndex(driverIndex) | ||
| 385 | { | ||
| 386 | } | ||
| 387 | |||
| 388 | public: | ||
| 389 | /*! | ||
| 390 | * \brief Construct an invalid driver primitive | ||
| 391 | */ | ||
| 392 | DriverPrimitive(void) = default; | ||
| 393 | |||
| 394 | /*! | ||
| 395 | * \brief Construct a driver primitive representing a joystick button | ||
| 396 | */ | ||
| 397 | static DriverPrimitive CreateButton(unsigned int buttonIndex) | ||
| 398 | { | ||
| 399 | return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON, buttonIndex); | ||
| 400 | } | ||
| 401 | |||
| 402 | /*! | ||
| 403 | * \brief Construct a driver primitive representing one of the four direction | ||
| 404 | * arrows on a dpad | ||
| 405 | */ | ||
| 406 | DriverPrimitive(unsigned int hatIndex, JOYSTICK_DRIVER_HAT_DIRECTION direction) : | ||
| 407 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION), | ||
| 408 | m_driverIndex(hatIndex), | ||
| 409 | m_hatDirection(direction) | ||
| 410 | { | ||
| 411 | } | ||
| 412 | |||
| 413 | /*! | ||
| 414 | * \brief Construct a driver primitive representing the positive or negative | ||
| 415 | * half of an axis | ||
| 416 | */ | ||
| 417 | DriverPrimitive(unsigned int axisIndex, int center, JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction, unsigned int range) : | ||
| 418 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS), | ||
| 419 | m_driverIndex(axisIndex), | ||
| 420 | m_center(center), | ||
| 421 | m_semiAxisDirection(direction), | ||
| 422 | m_range(range) | ||
| 423 | { | ||
| 424 | } | ||
| 425 | |||
| 426 | /*! | ||
| 427 | * \brief Construct a driver primitive representing a motor | ||
| 428 | */ | ||
| 429 | static DriverPrimitive CreateMotor(unsigned int motorIndex) | ||
| 430 | { | ||
| 431 | return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR, motorIndex); | ||
| 432 | } | ||
| 433 | |||
| 434 | /*! | ||
| 435 | * \brief Construct a driver primitive representing a key on a keyboard | ||
| 436 | */ | ||
| 437 | DriverPrimitive(std::string keycode) : | ||
| 438 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY), | ||
| 439 | m_keycode(std::move(keycode)) | ||
| 440 | { | ||
| 441 | } | ||
| 442 | |||
| 443 | /*! | ||
| 444 | * \brief Construct a driver primitive representing a mouse button | ||
| 445 | */ | ||
| 446 | static DriverPrimitive CreateMouseButton(JOYSTICK_DRIVER_MOUSE_INDEX buttonIndex) | ||
| 447 | { | ||
| 448 | return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON, static_cast<unsigned int>(buttonIndex)); | ||
| 449 | } | ||
| 450 | |||
| 451 | /*! | ||
| 452 | * \brief Construct a driver primitive representing one of the four | ||
| 453 | * direction in which a relative pointer can move | ||
| 454 | */ | ||
| 455 | DriverPrimitive(JOYSTICK_DRIVER_RELPOINTER_DIRECTION direction) : | ||
| 456 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION), | ||
| 457 | m_relPointerDirection(direction) | ||
| 458 | { | ||
| 459 | } | ||
| 460 | |||
| 461 | explicit DriverPrimitive(const JOYSTICK_DRIVER_PRIMITIVE& primitive) : | ||
| 462 | m_type(primitive.type) | ||
| 463 | { | ||
| 464 | switch (m_type) | ||
| 465 | { | ||
| 466 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: | ||
| 467 | { | ||
| 468 | m_driverIndex = primitive.button.index; | ||
| 469 | break; | ||
| 470 | } | ||
| 471 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION: | ||
| 472 | { | ||
| 473 | m_driverIndex = primitive.hat.index; | ||
| 474 | m_hatDirection = primitive.hat.direction; | ||
| 475 | break; | ||
| 476 | } | ||
| 477 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: | ||
| 478 | { | ||
| 479 | m_driverIndex = primitive.semiaxis.index; | ||
| 480 | m_center = primitive.semiaxis.center; | ||
| 481 | m_semiAxisDirection = primitive.semiaxis.direction; | ||
| 482 | m_range = primitive.semiaxis.range; | ||
| 483 | break; | ||
| 484 | } | ||
| 485 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: | ||
| 486 | { | ||
| 487 | m_driverIndex = primitive.motor.index; | ||
| 488 | break; | ||
| 489 | } | ||
| 490 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY: | ||
| 491 | { | ||
| 492 | m_keycode = primitive.key.keycode; | ||
| 493 | break; | ||
| 494 | } | ||
| 495 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON: | ||
| 496 | { | ||
| 497 | m_driverIndex = primitive.mouse.button; | ||
| 498 | break; | ||
| 499 | } | ||
| 500 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION: | ||
| 501 | { | ||
| 502 | m_relPointerDirection = primitive.relpointer.direction; | ||
| 503 | break; | ||
| 504 | } | ||
| 505 | default: | ||
| 506 | break; | ||
| 507 | } | ||
| 508 | } | ||
| 509 | |||
| 510 | JOYSTICK_DRIVER_PRIMITIVE_TYPE Type(void) const { return m_type; } | ||
| 511 | unsigned int DriverIndex(void) const { return m_driverIndex; } | ||
| 512 | JOYSTICK_DRIVER_HAT_DIRECTION HatDirection(void) const { return m_hatDirection; } | ||
| 513 | int Center(void) const { return m_center; } | ||
| 514 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION SemiAxisDirection(void) const { return m_semiAxisDirection; } | ||
| 515 | unsigned int Range(void) const { return m_range; } | ||
| 516 | const std::string& Keycode(void) const { return m_keycode; } | ||
| 517 | JOYSTICK_DRIVER_MOUSE_INDEX MouseIndex(void) const { return static_cast<JOYSTICK_DRIVER_MOUSE_INDEX>(m_driverIndex); } | ||
| 518 | JOYSTICK_DRIVER_RELPOINTER_DIRECTION RelPointerDirection(void) const { return m_relPointerDirection; } | ||
| 519 | |||
| 520 | bool operator==(const DriverPrimitive& other) const | ||
| 521 | { | ||
| 522 | if (m_type == other.m_type) | ||
| 523 | { | ||
| 524 | switch (m_type) | ||
| 525 | { | ||
| 526 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: | ||
| 527 | { | ||
| 528 | return m_driverIndex == other.m_driverIndex; | ||
| 529 | } | ||
| 530 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION: | ||
| 531 | { | ||
| 532 | return m_driverIndex == other.m_driverIndex && | ||
| 533 | m_hatDirection == other.m_hatDirection; | ||
| 534 | } | ||
| 535 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: | ||
| 536 | { | ||
| 537 | return m_driverIndex == other.m_driverIndex && | ||
| 538 | m_center == other.m_center && | ||
| 539 | m_semiAxisDirection == other.m_semiAxisDirection && | ||
| 540 | m_range == other.m_range; | ||
| 541 | } | ||
| 542 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY: | ||
| 543 | { | ||
| 544 | return m_keycode == other.m_keycode; | ||
| 545 | } | ||
| 546 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: | ||
| 547 | { | ||
| 548 | return m_driverIndex == other.m_driverIndex; | ||
| 549 | } | ||
| 550 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON: | ||
| 551 | { | ||
| 552 | return m_driverIndex == other.m_driverIndex; | ||
| 553 | } | ||
| 554 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION: | ||
| 555 | { | ||
| 556 | return m_relPointerDirection == other.m_relPointerDirection; | ||
| 557 | } | ||
| 558 | default: | ||
| 559 | break; | ||
| 560 | } | ||
| 561 | } | ||
| 562 | return false; | ||
| 563 | } | ||
| 564 | |||
| 565 | void ToStruct(JOYSTICK_DRIVER_PRIMITIVE& driver_primitive) const | ||
| 566 | { | ||
| 567 | driver_primitive.type = m_type; | ||
| 568 | switch (m_type) | ||
| 569 | { | ||
| 570 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: | ||
| 571 | { | ||
| 572 | driver_primitive.button.index = m_driverIndex; | ||
| 573 | break; | ||
| 574 | } | ||
| 575 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION: | ||
| 576 | { | ||
| 577 | driver_primitive.hat.index = m_driverIndex; | ||
| 578 | driver_primitive.hat.direction = m_hatDirection; | ||
| 579 | break; | ||
| 580 | } | ||
| 581 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: | ||
| 582 | { | ||
| 583 | driver_primitive.semiaxis.index = m_driverIndex; | ||
| 584 | driver_primitive.semiaxis.center = m_center; | ||
| 585 | driver_primitive.semiaxis.direction = m_semiAxisDirection; | ||
| 586 | driver_primitive.semiaxis.range = m_range; | ||
| 587 | break; | ||
| 588 | } | ||
| 589 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: | ||
| 590 | { | ||
| 591 | driver_primitive.motor.index = m_driverIndex; | ||
| 592 | break; | ||
| 593 | } | ||
| 594 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY: | ||
| 595 | { | ||
| 596 | const size_t size = sizeof(driver_primitive.key.keycode); | ||
| 597 | std::strncpy(driver_primitive.key.keycode, m_keycode.c_str(), size - 1); | ||
| 598 | driver_primitive.key.keycode[size - 1] = '\0'; | ||
| 599 | break; | ||
| 600 | } | ||
| 601 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON: | ||
| 602 | { | ||
| 603 | driver_primitive.mouse.button = static_cast<JOYSTICK_DRIVER_MOUSE_INDEX>(m_driverIndex); | ||
| 604 | break; | ||
| 605 | } | ||
| 606 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION: | ||
| 607 | { | ||
| 608 | driver_primitive.relpointer.direction = m_relPointerDirection; | ||
| 609 | break; | ||
| 610 | } | ||
| 611 | default: | ||
| 612 | break; | ||
| 613 | } | ||
| 614 | } | ||
| 615 | |||
| 616 | static void FreeStruct(JOYSTICK_DRIVER_PRIMITIVE& primitive) | ||
| 617 | { | ||
| 618 | (void)primitive; | ||
| 619 | } | ||
| 620 | |||
| 621 | private: | ||
| 622 | JOYSTICK_DRIVER_PRIMITIVE_TYPE m_type = JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN; | ||
| 623 | unsigned int m_driverIndex = 0; | ||
| 624 | JOYSTICK_DRIVER_HAT_DIRECTION m_hatDirection = JOYSTICK_DRIVER_HAT_UNKNOWN; | ||
| 625 | int m_center = 0; | ||
| 626 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION m_semiAxisDirection = JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN; | ||
| 627 | unsigned int m_range = 1; | ||
| 628 | std::string m_keycode; | ||
| 629 | JOYSTICK_DRIVER_RELPOINTER_DIRECTION m_relPointerDirection = JOYSTICK_DRIVER_RELPOINTER_UNKNOWN; | ||
| 630 | }; | ||
| 631 | |||
| 632 | typedef PeripheralVector<DriverPrimitive, JOYSTICK_DRIVER_PRIMITIVE> DriverPrimitives; | ||
| 633 | |||
| 634 | /*! | ||
| 635 | * kodi::addon::JoystickFeature | ||
| 636 | * | ||
| 637 | * Class for joystick features. A feature can be: | ||
| 638 | * | ||
| 639 | * 1) scalar[1] | ||
| 640 | * 2) analog stick | ||
| 641 | * 3) accelerometer | ||
| 642 | * 4) motor | ||
| 643 | * 5) relative pointer[2] | ||
| 644 | * 6) absolute pointer | ||
| 645 | * 7) wheel | ||
| 646 | * 8) throttle | ||
| 647 | * 9) keyboard key | ||
| 648 | * | ||
| 649 | * [1] All three driver primitives (buttons, hats and axes) have a state that | ||
| 650 | * can be represented using a single scalar value. For this reason, | ||
| 651 | * features that map to a single primitive are called "scalar features". | ||
| 652 | * | ||
| 653 | * [2] Relative pointers are similar to analog sticks, but they use | ||
| 654 | * relative distances instead of positions. | ||
| 655 | */ | ||
| 656 | class JoystickFeature | ||
| 657 | { | ||
| 658 | public: | ||
| 659 | JoystickFeature(const std::string& name = "", JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN) : | ||
| 660 | m_name(name), | ||
| 661 | m_type(type), | ||
| 662 | m_primitives{} | ||
| 663 | { | ||
| 664 | } | ||
| 665 | |||
| 666 | JoystickFeature(const JoystickFeature& other) | ||
| 667 | { | ||
| 668 | *this = other; | ||
| 669 | } | ||
| 670 | |||
| 671 | explicit JoystickFeature(const JOYSTICK_FEATURE& feature) : | ||
| 672 | m_name(feature.name ? feature.name : ""), | ||
| 673 | m_type(feature.type) | ||
| 674 | { | ||
| 675 | for (unsigned int i = 0; i < JOYSTICK_PRIMITIVE_MAX; i++) | ||
| 676 | m_primitives[i] = DriverPrimitive(feature.primitives[i]); | ||
| 677 | } | ||
| 678 | |||
| 679 | JoystickFeature& operator=(const JoystickFeature& rhs) | ||
| 680 | { | ||
| 681 | if (this != &rhs) | ||
| 682 | { | ||
| 683 | m_name = rhs.m_name; | ||
| 684 | m_type = rhs.m_type; | ||
| 685 | m_primitives = rhs.m_primitives; | ||
| 686 | } | ||
| 687 | return *this; | ||
| 688 | } | ||
| 689 | |||
| 690 | bool operator==(const JoystickFeature& other) const | ||
| 691 | { | ||
| 692 | return m_name == other.m_name && | ||
| 693 | m_type == other.m_type && | ||
| 694 | m_primitives == other.m_primitives; | ||
| 695 | } | ||
| 696 | |||
| 697 | const std::string& Name(void) const { return m_name; } | ||
| 698 | JOYSTICK_FEATURE_TYPE Type(void) const { return m_type; } | ||
| 699 | bool IsValid() const { return m_type != JOYSTICK_FEATURE_TYPE_UNKNOWN; } | ||
| 700 | |||
| 701 | void SetName(const std::string& name) { m_name = name; } | ||
| 702 | void SetType(JOYSTICK_FEATURE_TYPE type) { m_type = type; } | ||
| 703 | void SetInvalid(void) { m_type = JOYSTICK_FEATURE_TYPE_UNKNOWN; } | ||
| 704 | |||
| 705 | const DriverPrimitive& Primitive(JOYSTICK_FEATURE_PRIMITIVE which) const { return m_primitives[which]; } | ||
| 706 | void SetPrimitive(JOYSTICK_FEATURE_PRIMITIVE which, const DriverPrimitive& primitive) { m_primitives[which] = primitive; } | ||
| 707 | |||
| 708 | std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX>& Primitives() { return m_primitives; } | ||
| 709 | const std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX>& Primitives() const { return m_primitives; } | ||
| 710 | |||
| 711 | void ToStruct(JOYSTICK_FEATURE& feature) const | ||
| 712 | { | ||
| 713 | feature.name = new char[m_name.length() + 1]; | ||
| 714 | feature.type = m_type; | ||
| 715 | for (unsigned int i = 0; i < JOYSTICK_PRIMITIVE_MAX; i++) | ||
| 716 | m_primitives[i].ToStruct(feature.primitives[i]); | ||
| 717 | |||
| 718 | std::strcpy(feature.name, m_name.c_str()); | ||
| 719 | } | ||
| 720 | |||
| 721 | static void FreeStruct(JOYSTICK_FEATURE& feature) | ||
| 722 | { | ||
| 723 | PERIPHERAL_SAFE_DELETE_ARRAY(feature.name); | ||
| 724 | } | ||
| 725 | |||
| 726 | private: | ||
| 727 | std::string m_name; | ||
| 728 | JOYSTICK_FEATURE_TYPE m_type; | ||
| 729 | std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX> m_primitives; | ||
| 730 | }; | ||
| 731 | |||
| 732 | typedef PeripheralVector<JoystickFeature, JOYSTICK_FEATURE> JoystickFeatures; | ||
| 733 | |||
| 734 | } /* namespace addon */ | ||
| 735 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h deleted file mode 100644 index f8a7380..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h +++ /dev/null | |||
| @@ -1,460 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | #include "../gui/renderHelper.h" | ||
| 13 | |||
| 14 | namespace kodi { namespace addon { class CInstanceScreensaver; }} | ||
| 15 | |||
| 16 | extern "C" | ||
| 17 | { | ||
| 18 | |||
| 19 | struct AddonInstance_Screensaver; | ||
| 20 | |||
| 21 | /*! | ||
| 22 | * @brief Screensaver properties | ||
| 23 | * | ||
| 24 | * Not to be used outside this header. | ||
| 25 | */ | ||
| 26 | typedef struct AddonProps_Screensaver | ||
| 27 | { | ||
| 28 | void *device; | ||
| 29 | int x; | ||
| 30 | int y; | ||
| 31 | int width; | ||
| 32 | int height; | ||
| 33 | float pixelRatio; | ||
| 34 | const char *name; | ||
| 35 | const char *presets; | ||
| 36 | const char *profile; | ||
| 37 | } AddonProps_Screensaver; | ||
| 38 | |||
| 39 | /*! | ||
| 40 | * @brief Screensaver callbacks | ||
| 41 | * | ||
| 42 | * Not to be used outside this header. | ||
| 43 | */ | ||
| 44 | typedef struct AddonToKodiFuncTable_Screensaver | ||
| 45 | { | ||
| 46 | KODI_HANDLE kodiInstance; | ||
| 47 | } AddonToKodiFuncTable_Screensaver; | ||
| 48 | |||
| 49 | /*! | ||
| 50 | * @brief Screensaver function hooks | ||
| 51 | * | ||
| 52 | * Not to be used outside this header. | ||
| 53 | */ | ||
| 54 | typedef struct KodiToAddonFuncTable_Screensaver | ||
| 55 | { | ||
| 56 | kodi::addon::CInstanceScreensaver* addonInstance; | ||
| 57 | bool (__cdecl* Start) (AddonInstance_Screensaver* instance); | ||
| 58 | void (__cdecl* Stop) (AddonInstance_Screensaver* instance); | ||
| 59 | void (__cdecl* Render) (AddonInstance_Screensaver* instance); | ||
| 60 | } KodiToAddonFuncTable_Screensaver; | ||
| 61 | |||
| 62 | /*! | ||
| 63 | * @brief Screensaver instance | ||
| 64 | * | ||
| 65 | * Not to be used outside this header. | ||
| 66 | */ | ||
| 67 | typedef struct AddonInstance_Screensaver | ||
| 68 | { | ||
| 69 | AddonProps_Screensaver props; | ||
| 70 | AddonToKodiFuncTable_Screensaver toKodi; | ||
| 71 | KodiToAddonFuncTable_Screensaver toAddon; | ||
| 72 | } AddonInstance_Screensaver; | ||
| 73 | |||
| 74 | } /* extern "C" */ | ||
| 75 | |||
| 76 | namespace kodi | ||
| 77 | { | ||
| 78 | namespace addon | ||
| 79 | { | ||
| 80 | |||
| 81 | //============================================================================ | ||
| 82 | /// | ||
| 83 | /// \addtogroup cpp_kodi_addon_screensaver | ||
| 84 | /// @brief \cpp_class{ kodi::addon::CInstanceScreensaver } | ||
| 85 | /// **Screensaver add-on instance** | ||
| 86 | /// | ||
| 87 | /// A screensaver is a Kodi addon that fills the screen with moving images or | ||
| 88 | /// patterns when the computer is not in use. Initially designed to prevent | ||
| 89 | /// phosphor burn-in on CRT and plasma computer monitors (hence the name), | ||
| 90 | /// screensavers are now used primarily for entertainment, security or to | ||
| 91 | /// display system status information. | ||
| 92 | /// | ||
| 93 | /// Include the header \ref ScreenSaver.h "#include <kodi/addon-instance/ScreenSaver.h>" | ||
| 94 | /// to use this class. | ||
| 95 | /// | ||
| 96 | /// This interface allows the creating of screensavers for Kodi, based upon | ||
| 97 | /// **DirectX** or/and **OpenGL** rendering with `C++` code. | ||
| 98 | /// | ||
| 99 | /// The interface is small and easy usable. It has three functions: | ||
| 100 | /// | ||
| 101 | /// * <b><c>Start()</c></b> - Called on creation | ||
| 102 | /// * <b><c>Render()</c></b> - Called at render time | ||
| 103 | /// * <b><c>Stop()</c></b> - Called when the screensaver has no work | ||
| 104 | /// | ||
| 105 | /// Additionally, there are several \ref cpp_kodi_addon_screensaver_CB "other functions" | ||
| 106 | /// available in which the child class can ask about the current hardware, | ||
| 107 | /// including the device, display and several other parts. | ||
| 108 | /// | ||
| 109 | /// | ||
| 110 | /// -------------------------------------------------------------------------- | ||
| 111 | /// | ||
| 112 | /// | ||
| 113 | /// **Here is an example of the minimum required code to start a screensaver:** | ||
| 114 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 115 | /// #include <kodi/addon-instance/Screensaver.h> | ||
| 116 | /// | ||
| 117 | /// class CMyScreenSaver : public kodi::addon::CAddonBase, | ||
| 118 | /// public kodi::addon::CInstanceScreensaver | ||
| 119 | /// { | ||
| 120 | /// public: | ||
| 121 | /// CMyScreenSaver(); | ||
| 122 | /// | ||
| 123 | /// bool Start() override; | ||
| 124 | /// void Render() override; | ||
| 125 | /// }; | ||
| 126 | /// | ||
| 127 | /// CMyScreenSaver::CMyScreenSaver() | ||
| 128 | /// { | ||
| 129 | /// ... | ||
| 130 | /// } | ||
| 131 | /// | ||
| 132 | /// bool CMyScreenSaver::Start() | ||
| 133 | /// { | ||
| 134 | /// ... | ||
| 135 | /// return true; | ||
| 136 | /// } | ||
| 137 | /// | ||
| 138 | /// void CMyScreenSaver::Render() | ||
| 139 | /// { | ||
| 140 | /// ... | ||
| 141 | /// } | ||
| 142 | /// | ||
| 143 | /// ADDONCREATOR(CMyScreenSaver) | ||
| 144 | /// ~~~~~~~~~~~~~ | ||
| 145 | /// | ||
| 146 | /// | ||
| 147 | /// -------------------------------------------------------------------------- | ||
| 148 | /// | ||
| 149 | /// | ||
| 150 | /// **Here is another example where the screensaver is used together with | ||
| 151 | /// other instance types:** | ||
| 152 | /// | ||
| 153 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 154 | /// #include <kodi/addon-instance/Screensaver.h> | ||
| 155 | /// | ||
| 156 | /// class CMyScreenSaver : public ::kodi::addon::CInstanceScreensaver | ||
| 157 | /// { | ||
| 158 | /// public: | ||
| 159 | /// CMyScreenSaver(KODI_HANDLE instance); | ||
| 160 | /// | ||
| 161 | /// bool Start() override; | ||
| 162 | /// void Render() override; | ||
| 163 | /// }; | ||
| 164 | /// | ||
| 165 | /// CMyScreenSaver::CMyScreenSaver(KODI_HANDLE instance) | ||
| 166 | /// : CInstanceScreensaver(instance) | ||
| 167 | /// { | ||
| 168 | /// ... | ||
| 169 | /// } | ||
| 170 | /// | ||
| 171 | /// bool CMyScreenSaver::Start() | ||
| 172 | /// { | ||
| 173 | /// ... | ||
| 174 | /// return true; | ||
| 175 | /// } | ||
| 176 | /// | ||
| 177 | /// void CMyScreenSaver::Render() | ||
| 178 | /// { | ||
| 179 | /// ... | ||
| 180 | /// } | ||
| 181 | /// | ||
| 182 | /// | ||
| 183 | /// /*----------------------------------------------------------------------*/ | ||
| 184 | /// | ||
| 185 | /// class CMyAddon : public ::kodi::addon::CAddonBase | ||
| 186 | /// { | ||
| 187 | /// public: | ||
| 188 | /// CMyAddon() { } | ||
| 189 | /// ADDON_STATUS CreateInstance(int instanceType, | ||
| 190 | /// std::string instanceID, | ||
| 191 | /// KODI_HANDLE instance, | ||
| 192 | /// KODI_HANDLE& addonInstance) override; | ||
| 193 | /// }; | ||
| 194 | /// | ||
| 195 | /// /* If you use only one instance in your add-on, can be instanceType and | ||
| 196 | /// * instanceID ignored */ | ||
| 197 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 198 | /// std::string instanceID, | ||
| 199 | /// KODI_HANDLE instance, | ||
| 200 | /// KODI_HANDLE& addonInstance) | ||
| 201 | /// { | ||
| 202 | /// if (instanceType == ADDON_INSTANCE_SCREENSAVER) | ||
| 203 | /// { | ||
| 204 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my Screensaver"); | ||
| 205 | /// addonInstance = new CMyScreenSaver(instance); | ||
| 206 | /// return ADDON_STATUS_OK; | ||
| 207 | /// } | ||
| 208 | /// else if (...) | ||
| 209 | /// { | ||
| 210 | /// ... | ||
| 211 | /// } | ||
| 212 | /// return ADDON_STATUS_UNKNOWN; | ||
| 213 | /// } | ||
| 214 | /// | ||
| 215 | /// ADDONCREATOR(CMyAddon) | ||
| 216 | /// ~~~~~~~~~~~~~ | ||
| 217 | /// | ||
| 218 | /// The destruction of the example class `CMyScreenSaver` is called from | ||
| 219 | /// Kodi's header. Manually deleting the add-on instance is not required. | ||
| 220 | /// | ||
| 221 | //---------------------------------------------------------------------------- | ||
| 222 | class ATTRIBUTE_HIDDEN CInstanceScreensaver : public IAddonInstance | ||
| 223 | { | ||
| 224 | public: | ||
| 225 | //========================================================================== | ||
| 226 | /// | ||
| 227 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 228 | /// @brief Screensaver class constructor | ||
| 229 | /// | ||
| 230 | /// Used by an add-on that only supports screensavers. | ||
| 231 | /// | ||
| 232 | CInstanceScreensaver() | ||
| 233 | : IAddonInstance(ADDON_INSTANCE_SCREENSAVER, GetKodiTypeVersion(ADDON_INSTANCE_SCREENSAVER)) | ||
| 234 | { | ||
| 235 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 236 | throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation of more as one in single instance way is not allowed!"); | ||
| 237 | |||
| 238 | SetAddonStruct(CAddonBase::m_interface->firstKodiInstance); | ||
| 239 | CAddonBase::m_interface->globalSingleInstance = this; | ||
| 240 | } | ||
| 241 | //-------------------------------------------------------------------------- | ||
| 242 | |||
| 243 | //========================================================================== | ||
| 244 | /// | ||
| 245 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 246 | /// @brief Screensaver class constructor used to support multiple instance | ||
| 247 | /// types | ||
| 248 | /// | ||
| 249 | /// @param[in] instance The instance value given to | ||
| 250 | /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>. | ||
| 251 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to | ||
| 252 | /// allow compatibility to older Kodi versions. | ||
| 253 | /// @note Recommended to set. | ||
| 254 | /// | ||
| 255 | /// @warning Only use `instance` from the CreateInstance call | ||
| 256 | /// | ||
| 257 | explicit CInstanceScreensaver(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 258 | : IAddonInstance(ADDON_INSTANCE_SCREENSAVER, | ||
| 259 | !kodiVersion.empty() ? kodiVersion | ||
| 260 | : GetKodiTypeVersion(ADDON_INSTANCE_SCREENSAVER)) | ||
| 261 | { | ||
| 262 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 263 | throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation of multiple together with single instance way is not allowed!"); | ||
| 264 | |||
| 265 | SetAddonStruct(instance); | ||
| 266 | } | ||
| 267 | //-------------------------------------------------------------------------- | ||
| 268 | |||
| 269 | //========================================================================== | ||
| 270 | /// | ||
| 271 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 272 | /// @brief Destructor | ||
| 273 | /// | ||
| 274 | ~CInstanceScreensaver() override = default; | ||
| 275 | //-------------------------------------------------------------------------- | ||
| 276 | |||
| 277 | //========================================================================== | ||
| 278 | /// | ||
| 279 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 280 | /// @brief Used to notify the screensaver that it has been started | ||
| 281 | /// | ||
| 282 | /// @return true if the screensaver was started | ||
| 283 | /// successfully, false otherwise | ||
| 284 | /// | ||
| 285 | virtual bool Start() { return true; } | ||
| 286 | //-------------------------------------------------------------------------- | ||
| 287 | |||
| 288 | //========================================================================== | ||
| 289 | /// | ||
| 290 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 291 | /// @brief Used to inform the screensaver that the rendering control was | ||
| 292 | /// stopped | ||
| 293 | /// | ||
| 294 | virtual void Stop() {} | ||
| 295 | //-------------------------------------------------------------------------- | ||
| 296 | |||
| 297 | //========================================================================== | ||
| 298 | /// | ||
| 299 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 300 | /// @brief Used to indicate when the add-on should render | ||
| 301 | /// | ||
| 302 | virtual void Render() {} | ||
| 303 | //-------------------------------------------------------------------------- | ||
| 304 | |||
| 305 | //========================================================================== | ||
| 306 | /// | ||
| 307 | /// \defgroup cpp_kodi_addon_screensaver_CB Information functions | ||
| 308 | /// \ingroup cpp_kodi_addon_screensaver | ||
| 309 | /// @brief **To get info about the device, display and several other parts** | ||
| 310 | /// | ||
| 311 | //@{ | ||
| 312 | |||
| 313 | //========================================================================== | ||
| 314 | /// | ||
| 315 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 316 | /// @brief Device that represents the display adapter | ||
| 317 | /// | ||
| 318 | /// @return A pointer to the device | ||
| 319 | /// | ||
| 320 | /// @note This is only available on **DirectX**, It us unused (`nullptr`) on | ||
| 321 | /// **OpenGL** | ||
| 322 | /// | ||
| 323 | inline void* Device() { return m_instanceData->props.device; } | ||
| 324 | //-------------------------------------------------------------------------- | ||
| 325 | |||
| 326 | //========================================================================== | ||
| 327 | /// | ||
| 328 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 329 | /// @brief Returns the X position of the rendering window | ||
| 330 | /// | ||
| 331 | /// @return The X position, in pixels | ||
| 332 | /// | ||
| 333 | inline int X() { return m_instanceData->props.x; } | ||
| 334 | //-------------------------------------------------------------------------- | ||
| 335 | |||
| 336 | //========================================================================== | ||
| 337 | /// | ||
| 338 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 339 | /// @brief Returns the Y position of the rendering window | ||
| 340 | /// | ||
| 341 | /// @return The Y position, in pixels | ||
| 342 | /// | ||
| 343 | inline int Y() { return m_instanceData->props.y; } | ||
| 344 | //-------------------------------------------------------------------------- | ||
| 345 | |||
| 346 | //========================================================================== | ||
| 347 | /// | ||
| 348 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 349 | /// @brief Returns the width of the rendering window | ||
| 350 | /// | ||
| 351 | /// @return The width, in pixels | ||
| 352 | /// | ||
| 353 | inline int Width() { return m_instanceData->props.width; } | ||
| 354 | //-------------------------------------------------------------------------- | ||
| 355 | |||
| 356 | //========================================================================== | ||
| 357 | /// | ||
| 358 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 359 | /// @brief Returns the height of the rendering window | ||
| 360 | /// | ||
| 361 | /// @return The height, in pixels | ||
| 362 | /// | ||
| 363 | inline int Height() { return m_instanceData->props.height; } | ||
| 364 | //-------------------------------------------------------------------------- | ||
| 365 | |||
| 366 | //========================================================================== | ||
| 367 | /// | ||
| 368 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 369 | /// @brief Pixel aspect ratio (often abbreviated PAR) is a ratio that | ||
| 370 | /// describes how the width of a pixel compares to the height of that pixel. | ||
| 371 | /// | ||
| 372 | /// @return The pixel aspect ratio used by the display | ||
| 373 | /// | ||
| 374 | inline float PixelRatio() { return m_instanceData->props.pixelRatio; } | ||
| 375 | //-------------------------------------------------------------------------- | ||
| 376 | |||
| 377 | //========================================================================== | ||
| 378 | /// | ||
| 379 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 380 | /// @brief Used to get the name of the add-on defined in `addon.xml` | ||
| 381 | /// | ||
| 382 | /// @return The add-on name | ||
| 383 | /// | ||
| 384 | inline std::string Name() { return m_instanceData->props.name; } | ||
| 385 | //-------------------------------------------------------------------------- | ||
| 386 | |||
| 387 | //========================================================================== | ||
| 388 | /// | ||
| 389 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 390 | /// @brief Used to get the full path where the add-on is installed | ||
| 391 | /// | ||
| 392 | /// @return The add-on installation path | ||
| 393 | /// | ||
| 394 | inline std::string Presets() { return m_instanceData->props.presets; } | ||
| 395 | //-------------------------------------------------------------------------- | ||
| 396 | |||
| 397 | //========================================================================== | ||
| 398 | /// | ||
| 399 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 400 | /// @brief Used to get the full path to the add-on's user profile | ||
| 401 | /// | ||
| 402 | /// @note The trailing folder (consisting of the add-on's ID) is not created | ||
| 403 | /// by default. If it is needed, you must call kodi::vfs::CreateDirectory() | ||
| 404 | /// to create the folder. | ||
| 405 | /// | ||
| 406 | /// @return Path to the user profile | ||
| 407 | /// | ||
| 408 | inline std::string Profile() { return m_instanceData->props.profile; } | ||
| 409 | //-------------------------------------------------------------------------- | ||
| 410 | //@} | ||
| 411 | |||
| 412 | private: | ||
| 413 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 414 | { | ||
| 415 | if (instance == nullptr) | ||
| 416 | throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation with empty addon structure not allowed, table must be given from Kodi!"); | ||
| 417 | |||
| 418 | m_instanceData = static_cast<AddonInstance_Screensaver*>(instance); | ||
| 419 | m_instanceData->toAddon.addonInstance = this; | ||
| 420 | m_instanceData->toAddon.Start = ADDON_Start; | ||
| 421 | m_instanceData->toAddon.Stop = ADDON_Stop; | ||
| 422 | m_instanceData->toAddon.Render = ADDON_Render; | ||
| 423 | } | ||
| 424 | |||
| 425 | inline static bool ADDON_Start(AddonInstance_Screensaver* instance) | ||
| 426 | { | ||
| 427 | instance->toAddon.addonInstance->m_renderHelper = kodi::gui::GetRenderHelper(); | ||
| 428 | return instance->toAddon.addonInstance->Start(); | ||
| 429 | } | ||
| 430 | |||
| 431 | inline static void ADDON_Stop(AddonInstance_Screensaver* instance) | ||
| 432 | { | ||
| 433 | instance->toAddon.addonInstance->Stop(); | ||
| 434 | instance->toAddon.addonInstance->m_renderHelper = nullptr; | ||
| 435 | } | ||
| 436 | |||
| 437 | inline static void ADDON_Render(AddonInstance_Screensaver* instance) | ||
| 438 | { | ||
| 439 | if (!instance->toAddon.addonInstance->m_renderHelper) | ||
| 440 | return; | ||
| 441 | instance->toAddon.addonInstance->m_renderHelper->Begin(); | ||
| 442 | instance->toAddon.addonInstance->Render(); | ||
| 443 | instance->toAddon.addonInstance->m_renderHelper->End(); | ||
| 444 | } | ||
| 445 | |||
| 446 | /* | ||
| 447 | * Background render helper holds here and in addon base. | ||
| 448 | * In addon base also to have for the others, and stored here for the worst | ||
| 449 | * case where this class is independent from base and base becomes closed | ||
| 450 | * before. | ||
| 451 | * | ||
| 452 | * This is on Kodi with GL unused and the calls to there are empty (no work) | ||
| 453 | * On Kodi with Direct X where angle is present becomes this used. | ||
| 454 | */ | ||
| 455 | std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper; | ||
| 456 | AddonInstance_Screensaver* m_instanceData; | ||
| 457 | }; | ||
| 458 | |||
| 459 | } /* namespace addon */ | ||
| 460 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h deleted file mode 100644 index 4be785d..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h +++ /dev/null | |||
| @@ -1,789 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | /* | ||
| 12 | * Parts with a comment named "internal" are only used inside header and not | ||
| 13 | * used or accessed direct during add-on development! | ||
| 14 | */ | ||
| 15 | |||
| 16 | #include "../AddonBase.h" | ||
| 17 | #include "../gui/renderHelper.h" | ||
| 18 | |||
| 19 | namespace kodi { namespace addon { class CInstanceVisualization; }} | ||
| 20 | |||
| 21 | extern "C" | ||
| 22 | { | ||
| 23 | |||
| 24 | struct AddonInstance_Visualization; | ||
| 25 | |||
| 26 | typedef enum VIS_ACTION : unsigned int /* internal */ | ||
| 27 | { | ||
| 28 | VIS_ACTION_NONE = 0, | ||
| 29 | VIS_ACTION_NEXT_PRESET, | ||
| 30 | VIS_ACTION_PREV_PRESET, | ||
| 31 | VIS_ACTION_LOAD_PRESET, | ||
| 32 | VIS_ACTION_RANDOM_PRESET, | ||
| 33 | VIS_ACTION_LOCK_PRESET, | ||
| 34 | VIS_ACTION_RATE_PRESET_PLUS, | ||
| 35 | VIS_ACTION_RATE_PRESET_MINUS, | ||
| 36 | VIS_ACTION_UPDATE_ALBUMART, | ||
| 37 | VIS_ACTION_UPDATE_TRACK | ||
| 38 | } VIS_ACTION; | ||
| 39 | |||
| 40 | struct VIS_INFO /* internal */ | ||
| 41 | { | ||
| 42 | bool bWantsFreq; | ||
| 43 | int iSyncDelay; | ||
| 44 | }; | ||
| 45 | |||
| 46 | typedef struct AddonProps_Visualization /* internal */ | ||
| 47 | { | ||
| 48 | void *device; | ||
| 49 | int x; | ||
| 50 | int y; | ||
| 51 | int width; | ||
| 52 | int height; | ||
| 53 | float pixelRatio; | ||
| 54 | const char *name; | ||
| 55 | const char *presets; | ||
| 56 | const char *profile; | ||
| 57 | } AddonProps_Visualization; | ||
| 58 | |||
| 59 | typedef struct AddonToKodiFuncTable_Visualization /* internal */ | ||
| 60 | { | ||
| 61 | KODI_HANDLE kodiInstance; | ||
| 62 | void (__cdecl* transfer_preset) (void* kodiInstance, const char* preset); | ||
| 63 | void (__cdecl* clear_presets) (void* kodiInstance); | ||
| 64 | } AddonToKodiFuncTable_Visualization; | ||
| 65 | |||
| 66 | typedef struct KodiToAddonFuncTable_Visualization /* internal */ | ||
| 67 | { | ||
| 68 | kodi::addon::CInstanceVisualization* addonInstance; | ||
| 69 | bool (__cdecl* start)(const AddonInstance_Visualization* instance, int channels, int samples_per_sec, int bits_per_sample, const char* song_name); | ||
| 70 | void (__cdecl* stop)(const AddonInstance_Visualization* instance); | ||
| 71 | void (__cdecl* audio_data)(const AddonInstance_Visualization* instance, const float* audio_data, int audio_data_length, float *freq_data, int freq_data_length); | ||
| 72 | bool (__cdecl* is_dirty)(const AddonInstance_Visualization* instance); | ||
| 73 | void (__cdecl* render)(const AddonInstance_Visualization* instance); | ||
| 74 | void (__cdecl* get_info)(const AddonInstance_Visualization* instance, VIS_INFO *info); | ||
| 75 | bool (__cdecl* on_action)(const AddonInstance_Visualization* instance, VIS_ACTION action, const void *param); | ||
| 76 | unsigned int (__cdecl *get_presets)(const AddonInstance_Visualization* instance); | ||
| 77 | int (__cdecl *get_active_preset)(const AddonInstance_Visualization* instance); | ||
| 78 | bool (__cdecl* is_locked)(const AddonInstance_Visualization* instance); | ||
| 79 | } KodiToAddonFuncTable_Visualization; | ||
| 80 | |||
| 81 | typedef struct AddonInstance_Visualization /* internal */ | ||
| 82 | { | ||
| 83 | AddonProps_Visualization* props; | ||
| 84 | AddonToKodiFuncTable_Visualization* toKodi; | ||
| 85 | KodiToAddonFuncTable_Visualization* toAddon; | ||
| 86 | } AddonInstance_Visualization; | ||
| 87 | |||
| 88 | //============================================================================ | ||
| 89 | /// \defgroup cpp_kodi_addon_visualization_VisTrack class VisTrack | ||
| 90 | /// \ingroup cpp_kodi_addon_visualization | ||
| 91 | /// @brief **Visualization track information structure** | ||
| 92 | /// | ||
| 93 | /// Called from kodi::addon::CInstanceVisualization::UpdateTrack() with the | ||
| 94 | /// information of the currently-playing song. | ||
| 95 | /// | ||
| 96 | //@{ | ||
| 97 | struct VisTrack | ||
| 98 | { | ||
| 99 | /// @brief Title of the current song. | ||
| 100 | const char *title; | ||
| 101 | |||
| 102 | /// @brief Artist names, as a single string | ||
| 103 | const char *artist; | ||
| 104 | |||
| 105 | /// @brief Album that the current song is from. | ||
| 106 | const char *album; | ||
| 107 | |||
| 108 | /// @brief Album artist names, as a single string | ||
| 109 | const char *albumArtist; | ||
| 110 | |||
| 111 | /// @brief The genre name from the music tag, if present. | ||
| 112 | const char *genre; | ||
| 113 | |||
| 114 | /// @brief Comment of the current song stored in the ID tag info. | ||
| 115 | const char *comment; | ||
| 116 | |||
| 117 | /// @brief Lyrics of the current song, if available. | ||
| 118 | const char *lyrics; | ||
| 119 | |||
| 120 | const char *reserved1; | ||
| 121 | const char *reserved2; | ||
| 122 | |||
| 123 | /// @brief Track number of the current song. | ||
| 124 | int trackNumber; | ||
| 125 | |||
| 126 | /// @brief Disc number of the current song stored in the ID tag info. | ||
| 127 | int discNumber; | ||
| 128 | |||
| 129 | /// @brief Duration of the current song, in seconds. | ||
| 130 | int duration; | ||
| 131 | |||
| 132 | /// @brief Year that the current song was released. | ||
| 133 | int year; | ||
| 134 | |||
| 135 | /// @brief The user-defined rating of the current song. | ||
| 136 | int rating; | ||
| 137 | |||
| 138 | int reserved3; | ||
| 139 | int reserved4; | ||
| 140 | }; | ||
| 141 | //@} | ||
| 142 | //---------------------------------------------------------------------------- | ||
| 143 | |||
| 144 | } /* extern "C" */ | ||
| 145 | |||
| 146 | namespace kodi | ||
| 147 | { | ||
| 148 | namespace addon | ||
| 149 | { | ||
| 150 | |||
| 151 | //============================================================================ | ||
| 152 | /// | ||
| 153 | /// \addtogroup cpp_kodi_addon_visualization | ||
| 154 | /// @brief \cpp_class{ kodi::addon::CInstanceVisualization } | ||
| 155 | /// **Visualization add-on instance** | ||
| 156 | /// | ||
| 157 | /// [Music visualization](https://en.wikipedia.org/wiki/Music_visualization), | ||
| 158 | /// or music visualisation, is a feature in Kodi that generates animated | ||
| 159 | /// imagery based on a piece of music. The imagery is usually generated and | ||
| 160 | /// rendered in real time synchronized to the music. | ||
| 161 | /// | ||
| 162 | /// Visualization techniques range from simple ones (e.g., a simulation of an | ||
| 163 | /// oscilloscope display) to elaborate ones, which often include a plurality | ||
| 164 | /// of composited effects. The changes in the music's loudness and frequency | ||
| 165 | /// spectrum are among the properties used as input to the visualization. | ||
| 166 | /// | ||
| 167 | /// Include the header \ref Visualization.h "#include <kodi/addon-instance/Visualization.h>" | ||
| 168 | /// to use this class. | ||
| 169 | /// | ||
| 170 | /// This interface allows the creation of visualizations for Kodi, based upon | ||
| 171 | /// **DirectX** or/and **OpenGL** rendering with `C++` code. | ||
| 172 | /// | ||
| 173 | /// Additionally, there are several \ref cpp_kodi_addon_visualization_CB "other functions" | ||
| 174 | /// available in which the child class can ask about the current hardware, | ||
| 175 | /// including the device, display and several other parts. | ||
| 176 | /// | ||
| 177 | /// -------------------------------------------------------------------------- | ||
| 178 | /// | ||
| 179 | /// | ||
| 180 | /// **Here is an example of the minimum required code to start a visualization:** | ||
| 181 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 182 | /// #include <kodi/addon-instance/Visualization.h> | ||
| 183 | /// | ||
| 184 | /// class CMyVisualization : public kodi::addon::CAddonBase, | ||
| 185 | /// public kodi::addon::CInstanceVisualization | ||
| 186 | /// { | ||
| 187 | /// public: | ||
| 188 | /// CMyVisualization(); | ||
| 189 | /// | ||
| 190 | /// bool Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) override; | ||
| 191 | /// void AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength) override; | ||
| 192 | /// void Render() override; | ||
| 193 | /// }; | ||
| 194 | /// | ||
| 195 | /// CMyVisualization::CMyVisualization() | ||
| 196 | /// { | ||
| 197 | /// ... | ||
| 198 | /// } | ||
| 199 | /// | ||
| 200 | /// bool CMyVisualization::Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) | ||
| 201 | /// { | ||
| 202 | /// ... | ||
| 203 | /// return true; | ||
| 204 | /// } | ||
| 205 | /// | ||
| 206 | /// void CMyVisualization::AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength) | ||
| 207 | /// { | ||
| 208 | /// ... | ||
| 209 | /// } | ||
| 210 | /// | ||
| 211 | /// void CMyVisualization::Render() | ||
| 212 | /// { | ||
| 213 | /// ... | ||
| 214 | /// } | ||
| 215 | /// | ||
| 216 | /// ADDONCREATOR(CMyVisualization) | ||
| 217 | /// ~~~~~~~~~~~~~ | ||
| 218 | /// | ||
| 219 | /// | ||
| 220 | /// -------------------------------------------------------------------------- | ||
| 221 | /// | ||
| 222 | /// | ||
| 223 | /// **Here is another example where the visualization is used together with | ||
| 224 | /// other instance types:** | ||
| 225 | /// | ||
| 226 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 227 | /// #include <kodi/addon-instance/Visualization.h> | ||
| 228 | /// | ||
| 229 | /// class CMyVisualization : public ::kodi::addon::CInstanceVisualization | ||
| 230 | /// { | ||
| 231 | /// public: | ||
| 232 | /// CMyVisualization(KODI_HANDLE instance); | ||
| 233 | /// | ||
| 234 | /// bool Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) override; | ||
| 235 | /// void AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength) override; | ||
| 236 | /// void Render() override; | ||
| 237 | /// }; | ||
| 238 | /// | ||
| 239 | /// CMyVisualization::CMyVisualization(KODI_HANDLE instance) | ||
| 240 | /// : CInstanceVisualization(instance) | ||
| 241 | /// { | ||
| 242 | /// ... | ||
| 243 | /// } | ||
| 244 | /// | ||
| 245 | /// bool CMyVisualization::Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) | ||
| 246 | /// { | ||
| 247 | /// ... | ||
| 248 | /// return true; | ||
| 249 | /// } | ||
| 250 | /// | ||
| 251 | /// void CMyVisualization::AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength) | ||
| 252 | /// { | ||
| 253 | /// ... | ||
| 254 | /// } | ||
| 255 | /// | ||
| 256 | /// void CMyVisualization::Render() | ||
| 257 | /// { | ||
| 258 | /// ... | ||
| 259 | /// } | ||
| 260 | /// | ||
| 261 | /// | ||
| 262 | /// /*----------------------------------------------------------------------*/ | ||
| 263 | /// | ||
| 264 | /// class CMyAddon : public ::kodi::addon::CAddonBase | ||
| 265 | /// { | ||
| 266 | /// public: | ||
| 267 | /// CMyAddon() { } | ||
| 268 | /// ADDON_STATUS CreateInstance(int instanceType, | ||
| 269 | /// std::string instanceID, | ||
| 270 | /// KODI_HANDLE instance, | ||
| 271 | /// KODI_HANDLE& addonInstance) override; | ||
| 272 | /// }; | ||
| 273 | /// | ||
| 274 | /// /* If you use only one instance in your add-on, can be instanceType and | ||
| 275 | /// * instanceID ignored */ | ||
| 276 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 277 | /// std::string instanceID, | ||
| 278 | /// KODI_HANDLE instance, | ||
| 279 | /// KODI_HANDLE& addonInstance) | ||
| 280 | /// { | ||
| 281 | /// if (instanceType == ADDON_INSTANCE_VISUALIZATION) | ||
| 282 | /// { | ||
| 283 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my Visualization"); | ||
| 284 | /// addonInstance = new CMyVisualization(instance); | ||
| 285 | /// return ADDON_STATUS_OK; | ||
| 286 | /// } | ||
| 287 | /// else if (...) | ||
| 288 | /// { | ||
| 289 | /// ... | ||
| 290 | /// } | ||
| 291 | /// return ADDON_STATUS_UNKNOWN; | ||
| 292 | /// } | ||
| 293 | /// | ||
| 294 | /// ADDONCREATOR(CMyAddon) | ||
| 295 | /// ~~~~~~~~~~~~~ | ||
| 296 | /// | ||
| 297 | /// The destruction of the example class `CMyVisualization` is called from | ||
| 298 | /// Kodi's header. Manually deleting the add-on instance is not required. | ||
| 299 | /// | ||
| 300 | //---------------------------------------------------------------------------- | ||
| 301 | class ATTRIBUTE_HIDDEN CInstanceVisualization : public IAddonInstance | ||
| 302 | { | ||
| 303 | public: | ||
| 304 | //========================================================================== | ||
| 305 | /// | ||
| 306 | /// @ingroup cpp_kodi_addon_visualization | ||
| 307 | /// @brief Visualization class constructor | ||
| 308 | /// | ||
| 309 | /// Used by an add-on that only supports visualizations. | ||
| 310 | /// | ||
| 311 | CInstanceVisualization() | ||
| 312 | : IAddonInstance(ADDON_INSTANCE_VISUALIZATION, | ||
| 313 | GetKodiTypeVersion(ADDON_INSTANCE_VISUALIZATION)) | ||
| 314 | { | ||
| 315 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 316 | throw std::logic_error("kodi::addon::CInstanceVisualization: Cannot create multiple instances of add-on."); | ||
| 317 | |||
| 318 | SetAddonStruct(CAddonBase::m_interface->firstKodiInstance); | ||
| 319 | CAddonBase::m_interface->globalSingleInstance = this; | ||
| 320 | } | ||
| 321 | //-------------------------------------------------------------------------- | ||
| 322 | |||
| 323 | //========================================================================== | ||
| 324 | /// | ||
| 325 | /// @ingroup cpp_kodi_addon_visualization | ||
| 326 | /// @brief Visualization class constructor used to support multiple instance | ||
| 327 | /// types | ||
| 328 | /// | ||
| 329 | /// @param[in] instance The instance value given to | ||
| 330 | /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>. | ||
| 331 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to | ||
| 332 | /// allow compatibility to older Kodi versions. | ||
| 333 | /// @note Recommended to set. | ||
| 334 | /// | ||
| 335 | /// @warning Only use `instance` from the CreateInstance call | ||
| 336 | /// | ||
| 337 | explicit CInstanceVisualization(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 338 | : IAddonInstance(ADDON_INSTANCE_VISUALIZATION, | ||
| 339 | !kodiVersion.empty() ? kodiVersion | ||
| 340 | : GetKodiTypeVersion(ADDON_INSTANCE_VISUALIZATION)) | ||
| 341 | { | ||
| 342 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 343 | throw std::logic_error("kodi::addon::CInstanceVisualization: Creation of multiple together with single instance way is not allowed!"); | ||
| 344 | |||
| 345 | SetAddonStruct(instance); | ||
| 346 | } | ||
| 347 | //-------------------------------------------------------------------------- | ||
| 348 | |||
| 349 | //========================================================================== | ||
| 350 | /// | ||
| 351 | /// @ingroup cpp_kodi_addon_visualization | ||
| 352 | /// @brief Destructor | ||
| 353 | /// | ||
| 354 | ~CInstanceVisualization() override = default; | ||
| 355 | //-------------------------------------------------------------------------- | ||
| 356 | |||
| 357 | //========================================================================== | ||
| 358 | /// | ||
| 359 | /// @ingroup cpp_kodi_addon_visualization | ||
| 360 | /// @brief Used to notify the visualization that a new song has been started | ||
| 361 | /// | ||
| 362 | /// @param[in] channels Number of channels in the stream | ||
| 363 | /// @param[in] samplesPerSec Samples per second of stream | ||
| 364 | /// @param[in] bitsPerSample Number of bits in one sample | ||
| 365 | /// @param[in] songName The name of the currently-playing song | ||
| 366 | /// @return true if start successful done | ||
| 367 | /// | ||
| 368 | virtual bool Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) { return true; } | ||
| 369 | //-------------------------------------------------------------------------- | ||
| 370 | |||
| 371 | //========================================================================== | ||
| 372 | /// | ||
| 373 | /// @ingroup cpp_kodi_addon_visualization | ||
| 374 | /// @brief Used to inform the visualization that the rendering control was | ||
| 375 | /// stopped | ||
| 376 | /// | ||
| 377 | virtual void Stop() {} | ||
| 378 | //-------------------------------------------------------------------------- | ||
| 379 | |||
| 380 | //========================================================================== | ||
| 381 | /// | ||
| 382 | /// @ingroup cpp_kodi_addon_visualization | ||
| 383 | /// @brief Pass audio data to the visualization | ||
| 384 | /// | ||
| 385 | /// @param[in] audioData The raw audio data | ||
| 386 | /// @param[in] audioDataLength Length of the audioData array | ||
| 387 | /// @param[in] freqData The [FFT](https://en.wikipedia.org/wiki/Fast_Fourier_transform) | ||
| 388 | /// of the audio data | ||
| 389 | /// @param[in] freqDataLength Length of frequency data array | ||
| 390 | /// | ||
| 391 | /// Values **freqData** and **freqDataLength** are used if GetInfo() returns | ||
| 392 | /// true for the `wantsFreq` parameter. Otherwise, **freqData** is set to | ||
| 393 | /// `nullptr` and **freqDataLength** is `0`. | ||
| 394 | /// | ||
| 395 | virtual void AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength) {} | ||
| 396 | //-------------------------------------------------------------------------- | ||
| 397 | |||
| 398 | //========================================================================== | ||
| 399 | /// | ||
| 400 | /// @ingroup cpp_kodi_addon_visualization | ||
| 401 | /// @brief Used to inform Kodi that the rendered region is dirty and need an | ||
| 402 | /// update | ||
| 403 | /// | ||
| 404 | /// @return True if dirty | ||
| 405 | /// | ||
| 406 | virtual bool IsDirty() { return true; } | ||
| 407 | //-------------------------------------------------------------------------- | ||
| 408 | |||
| 409 | //========================================================================== | ||
| 410 | /// | ||
| 411 | /// @ingroup cpp_kodi_addon_visualization | ||
| 412 | /// @brief Used to indicate when the add-on should render | ||
| 413 | /// | ||
| 414 | virtual void Render() {} | ||
| 415 | //-------------------------------------------------------------------------- | ||
| 416 | |||
| 417 | //========================================================================== | ||
| 418 | /// | ||
| 419 | /// @ingroup cpp_kodi_addon_visualization | ||
| 420 | /// @brief Used to get the number of buffers from the current visualization | ||
| 421 | /// | ||
| 422 | /// @param[out] wantsFreq Indicates whether the add-on wants FFT | ||
| 423 | /// data. If set to true, the **freqData** | ||
| 424 | /// and **freqDataLength** parameters of | ||
| 425 | /// AudioData() are used | ||
| 426 | /// @param[out] syncDelay The number of buffers to delay before | ||
| 427 | /// calling AudioData() | ||
| 428 | /// | ||
| 429 | /// @note If this function is not implemented, it will default to | ||
| 430 | /// `wantsFreq` = false and `syncDelay` = 0. | ||
| 431 | /// | ||
| 432 | virtual void GetInfo(bool& wantsFreq, int& syncDelay) { wantsFreq = false; syncDelay = 0; } | ||
| 433 | //-------------------------------------------------------------------------- | ||
| 434 | |||
| 435 | //========================================================================== | ||
| 436 | /// | ||
| 437 | /// @ingroup cpp_kodi_addon_visualization | ||
| 438 | /// @brief Used to get a list of visualization presets the user can select | ||
| 439 | /// from | ||
| 440 | /// | ||
| 441 | /// @param[out] presets The vector list containing the names of | ||
| 442 | /// presets that the user can select | ||
| 443 | /// @return Return true if successful, or false if | ||
| 444 | /// there are no presets to choose from | ||
| 445 | /// | ||
| 446 | virtual bool GetPresets(std::vector<std::string>& presets) { return false; } | ||
| 447 | //-------------------------------------------------------------------------- | ||
| 448 | |||
| 449 | //========================================================================== | ||
| 450 | /// | ||
| 451 | /// @ingroup cpp_kodi_addon_visualization | ||
| 452 | /// @brief Get the index of the current preset | ||
| 453 | /// | ||
| 454 | /// @return Index number of the current preset | ||
| 455 | /// | ||
| 456 | virtual int GetActivePreset() { return -1; } | ||
| 457 | //-------------------------------------------------------------------------- | ||
| 458 | |||
| 459 | //========================================================================== | ||
| 460 | /// | ||
| 461 | /// @ingroup cpp_kodi_addon_visualization | ||
| 462 | /// @brief Check if the add-on is locked to the current preset | ||
| 463 | /// | ||
| 464 | /// @return True if locked to the current preset | ||
| 465 | /// | ||
| 466 | virtual bool IsLocked() { return false; } | ||
| 467 | //-------------------------------------------------------------------------- | ||
| 468 | |||
| 469 | //========================================================================== | ||
| 470 | /// | ||
| 471 | /// @ingroup cpp_kodi_addon_visualization | ||
| 472 | /// @brief Load the previous visualization preset | ||
| 473 | /// | ||
| 474 | /// @return Return true if the previous preset was loaded | ||
| 475 | virtual bool PrevPreset() { return false; } | ||
| 476 | //-------------------------------------------------------------------------- | ||
| 477 | |||
| 478 | //========================================================================== | ||
| 479 | /// | ||
| 480 | /// @ingroup cpp_kodi_addon_visualization | ||
| 481 | /// @brief Load the next visualization preset | ||
| 482 | /// | ||
| 483 | /// @return Return true if the next preset was loaded | ||
| 484 | virtual bool NextPreset() { return false; } | ||
| 485 | //-------------------------------------------------------------------------- | ||
| 486 | |||
| 487 | //========================================================================== | ||
| 488 | /// | ||
| 489 | /// @ingroup cpp_kodi_addon_visualization | ||
| 490 | /// @brief Load a visualization preset | ||
| 491 | /// | ||
| 492 | /// This function is called after a new preset is selected. | ||
| 493 | /// | ||
| 494 | /// @param[in] select Preset index to use | ||
| 495 | /// @return Return true if the preset is loaded | ||
| 496 | virtual bool LoadPreset(int select) { return false; } | ||
| 497 | //-------------------------------------------------------------------------- | ||
| 498 | |||
| 499 | //========================================================================== | ||
| 500 | /// | ||
| 501 | /// @ingroup cpp_kodi_addon_visualization | ||
| 502 | /// @brief Switch to a new random preset | ||
| 503 | /// | ||
| 504 | /// @return Return true if a random preset was loaded | ||
| 505 | virtual bool RandomPreset() { return false; } | ||
| 506 | //-------------------------------------------------------------------------- | ||
| 507 | |||
| 508 | //========================================================================== | ||
| 509 | /// | ||
| 510 | /// @ingroup cpp_kodi_addon_visualization | ||
| 511 | /// @brief Lock the current visualization preset, preventing it from changing | ||
| 512 | /// | ||
| 513 | /// @param[in] lockUnlock If set to true, the preset should be locked | ||
| 514 | /// @return Return true if the current preset is locked | ||
| 515 | virtual bool LockPreset(bool lockUnlock) { return false; } | ||
| 516 | //-------------------------------------------------------------------------- | ||
| 517 | |||
| 518 | //========================================================================== | ||
| 519 | /// | ||
| 520 | /// @ingroup cpp_kodi_addon_visualization | ||
| 521 | /// @brief Used to increase/decrease the visualization preset rating | ||
| 522 | /// | ||
| 523 | /// @param[in] plusMinus If set to true the rating is increased, otherwise | ||
| 524 | /// decreased | ||
| 525 | /// @return Return true if the rating is modified | ||
| 526 | virtual bool RatePreset(bool plusMinus) { return false; } | ||
| 527 | //-------------------------------------------------------------------------- | ||
| 528 | |||
| 529 | //========================================================================== | ||
| 530 | /// | ||
| 531 | /// @ingroup cpp_kodi_addon_visualization | ||
| 532 | /// @brief Inform the visualization of the current album art image | ||
| 533 | /// | ||
| 534 | /// @param[in] albumart Path to the current album art image | ||
| 535 | /// @return Return true if the image is used | ||
| 536 | virtual bool UpdateAlbumart(std::string albumart) { return false; } | ||
| 537 | //-------------------------------------------------------------------------- | ||
| 538 | |||
| 539 | //========================================================================== | ||
| 540 | /// | ||
| 541 | /// @ingroup cpp_kodi_addon_visualization | ||
| 542 | /// @brief Inform the visualization of the current track's tag information | ||
| 543 | /// | ||
| 544 | /// @param[in] track Visualization track information structure | ||
| 545 | /// @return Return true if the track information is used | ||
| 546 | virtual bool UpdateTrack(const VisTrack &track) { return false; } | ||
| 547 | |||
| 548 | //========================================================================== | ||
| 549 | /// | ||
| 550 | /// \defgroup cpp_kodi_addon_visualization_CB Information functions | ||
| 551 | /// \ingroup cpp_kodi_addon_visualization | ||
| 552 | /// @brief **To get info about the device, display and several other parts** | ||
| 553 | /// | ||
| 554 | //@{ | ||
| 555 | |||
| 556 | //========================================================================== | ||
| 557 | /// | ||
| 558 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 559 | /// @brief To transfer available presets on addon | ||
| 560 | /// | ||
| 561 | /// Used if @ref GetPresets not possible to use, e.g. where available presets | ||
| 562 | /// are only known during @ref Start call. | ||
| 563 | /// | ||
| 564 | /// @param[in] presets List to store available presets. | ||
| 565 | /// | ||
| 566 | /// @note The function should only be called once, if possible | ||
| 567 | /// | ||
| 568 | inline void TransferPresets(const std::vector<std::string>& presets) | ||
| 569 | { | ||
| 570 | m_instanceData->toKodi->clear_presets(m_instanceData->toKodi->kodiInstance); | ||
| 571 | for (auto it : presets) | ||
| 572 | m_instanceData->toKodi->transfer_preset(m_instanceData->toKodi->kodiInstance, it.c_str()); | ||
| 573 | } | ||
| 574 | //-------------------------------------------------------------------------- | ||
| 575 | |||
| 576 | //========================================================================== | ||
| 577 | /// | ||
| 578 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 579 | /// @brief Device that represents the display adapter | ||
| 580 | /// | ||
| 581 | /// @return A pointer to the used device | ||
| 582 | /// | ||
| 583 | /// @note This is only available on **DirectX**, It us unused (`nullptr`) on | ||
| 584 | /// **OpenGL** | ||
| 585 | /// | ||
| 586 | inline void* Device() { return m_instanceData->props->device; } | ||
| 587 | //-------------------------------------------------------------------------- | ||
| 588 | |||
| 589 | //========================================================================== | ||
| 590 | /// | ||
| 591 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 592 | /// @brief Returns the X position of the rendering window | ||
| 593 | /// | ||
| 594 | /// @return The X position, in pixels | ||
| 595 | /// | ||
| 596 | inline int X() { return m_instanceData->props->x; } | ||
| 597 | //-------------------------------------------------------------------------- | ||
| 598 | |||
| 599 | //========================================================================== | ||
| 600 | /// | ||
| 601 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 602 | /// @brief Returns the Y position of the rendering window | ||
| 603 | /// | ||
| 604 | /// @return The Y position, in pixels | ||
| 605 | /// | ||
| 606 | inline int Y() { return m_instanceData->props->y; } | ||
| 607 | //-------------------------------------------------------------------------- | ||
| 608 | |||
| 609 | //========================================================================== | ||
| 610 | /// | ||
| 611 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 612 | /// @brief Returns the width of the rendering window | ||
| 613 | /// | ||
| 614 | /// @return The width, in pixels | ||
| 615 | /// | ||
| 616 | inline int Width() { return m_instanceData->props->width; } | ||
| 617 | //-------------------------------------------------------------------------- | ||
| 618 | |||
| 619 | //========================================================================== | ||
| 620 | /// | ||
| 621 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 622 | /// @brief Returns the height of the rendering window | ||
| 623 | /// | ||
| 624 | /// @return The height, in pixels | ||
| 625 | /// | ||
| 626 | inline int Height() { return m_instanceData->props->height; } | ||
| 627 | //-------------------------------------------------------------------------- | ||
| 628 | |||
| 629 | //========================================================================== | ||
| 630 | /// | ||
| 631 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 632 | /// @brief Pixel aspect ratio (often abbreviated PAR) is a ratio that | ||
| 633 | /// describes how the width of a pixel compares to the height of that pixel. | ||
| 634 | /// | ||
| 635 | /// @return The pixel aspect ratio used by the display | ||
| 636 | /// | ||
| 637 | inline float PixelRatio() { return m_instanceData->props->pixelRatio; } | ||
| 638 | //-------------------------------------------------------------------------- | ||
| 639 | |||
| 640 | //========================================================================== | ||
| 641 | /// | ||
| 642 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 643 | /// @brief Used to get the name of the add-on defined in `addon.xml` | ||
| 644 | /// | ||
| 645 | /// @return The add-on name | ||
| 646 | /// | ||
| 647 | inline std::string Name() { return m_instanceData->props->name; } | ||
| 648 | //-------------------------------------------------------------------------- | ||
| 649 | |||
| 650 | //========================================================================== | ||
| 651 | /// | ||
| 652 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 653 | /// @brief Used to get the full path where the add-on is installed | ||
| 654 | /// | ||
| 655 | /// @return The add-on installation path | ||
| 656 | /// | ||
| 657 | inline std::string Presets() { return m_instanceData->props->presets; } | ||
| 658 | //-------------------------------------------------------------------------- | ||
| 659 | |||
| 660 | //========================================================================== | ||
| 661 | /// | ||
| 662 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 663 | /// @brief Used to get the full path to the add-on's user profile | ||
| 664 | /// | ||
| 665 | /// @note The trailing folder (consisting of the add-on's ID) is not created | ||
| 666 | /// by default. If it is needed, you must call kodi::vfs::CreateDirectory() | ||
| 667 | /// to create the folder. | ||
| 668 | /// | ||
| 669 | /// @return Path to the user profile | ||
| 670 | /// | ||
| 671 | inline std::string Profile() { return m_instanceData->props->profile; } | ||
| 672 | //-------------------------------------------------------------------------- | ||
| 673 | //@} | ||
| 674 | |||
| 675 | private: | ||
| 676 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 677 | { | ||
| 678 | if (instance == nullptr) | ||
| 679 | throw std::logic_error("kodi::addon::CInstanceVisualization: Null pointer instance passed."); | ||
| 680 | |||
| 681 | m_instanceData = static_cast<AddonInstance_Visualization*>(instance); | ||
| 682 | m_instanceData->toAddon->addonInstance = this; | ||
| 683 | m_instanceData->toAddon->start = ADDON_Start; | ||
| 684 | m_instanceData->toAddon->stop = ADDON_Stop; | ||
| 685 | m_instanceData->toAddon->audio_data = ADDON_AudioData; | ||
| 686 | m_instanceData->toAddon->is_dirty = ADDON_IsDirty; | ||
| 687 | m_instanceData->toAddon->render = ADDON_Render; | ||
| 688 | m_instanceData->toAddon->get_info = ADDON_GetInfo; | ||
| 689 | m_instanceData->toAddon->on_action = ADDON_OnAction; | ||
| 690 | m_instanceData->toAddon->get_presets = ADDON_GetPresets; | ||
| 691 | m_instanceData->toAddon->get_active_preset = ADDON_GetActivePreset; | ||
| 692 | m_instanceData->toAddon->is_locked = ADDON_IsLocked; | ||
| 693 | } | ||
| 694 | |||
| 695 | inline static bool ADDON_Start(const AddonInstance_Visualization* addon, int channels, int samplesPerSec, int bitsPerSample, const char* songName) | ||
| 696 | { | ||
| 697 | addon->toAddon->addonInstance->m_renderHelper = kodi::gui::GetRenderHelper(); | ||
| 698 | return addon->toAddon->addonInstance->Start(channels, samplesPerSec, bitsPerSample, songName); | ||
| 699 | } | ||
| 700 | |||
| 701 | inline static void ADDON_Stop(const AddonInstance_Visualization* addon) | ||
| 702 | { | ||
| 703 | addon->toAddon->addonInstance->Stop(); | ||
| 704 | addon->toAddon->addonInstance->m_renderHelper = nullptr; | ||
| 705 | } | ||
| 706 | |||
| 707 | inline static void ADDON_AudioData(const AddonInstance_Visualization* addon, const float* audioData, int audioDataLength, float *freqData, int freqDataLength) | ||
| 708 | { | ||
| 709 | addon->toAddon->addonInstance->AudioData(audioData, audioDataLength, freqData, freqDataLength); | ||
| 710 | } | ||
| 711 | |||
| 712 | inline static bool ADDON_IsDirty(const AddonInstance_Visualization* addon) | ||
| 713 | { | ||
| 714 | return addon->toAddon->addonInstance->IsDirty(); | ||
| 715 | } | ||
| 716 | |||
| 717 | inline static void ADDON_Render(const AddonInstance_Visualization* addon) | ||
| 718 | { | ||
| 719 | if (!addon->toAddon->addonInstance->m_renderHelper) | ||
| 720 | return; | ||
| 721 | addon->toAddon->addonInstance->m_renderHelper->Begin(); | ||
| 722 | addon->toAddon->addonInstance->Render(); | ||
| 723 | addon->toAddon->addonInstance->m_renderHelper->End(); | ||
| 724 | } | ||
| 725 | |||
| 726 | inline static void ADDON_GetInfo(const AddonInstance_Visualization* addon, VIS_INFO *info) | ||
| 727 | { | ||
| 728 | addon->toAddon->addonInstance->GetInfo(info->bWantsFreq, info->iSyncDelay); | ||
| 729 | } | ||
| 730 | |||
| 731 | inline static bool ADDON_OnAction(const AddonInstance_Visualization* addon, VIS_ACTION action, const void *param) | ||
| 732 | { | ||
| 733 | switch (action) | ||
| 734 | { | ||
| 735 | case VIS_ACTION_NEXT_PRESET: | ||
| 736 | return addon->toAddon->addonInstance->NextPreset(); | ||
| 737 | case VIS_ACTION_PREV_PRESET: | ||
| 738 | return addon->toAddon->addonInstance->PrevPreset(); | ||
| 739 | case VIS_ACTION_LOAD_PRESET: | ||
| 740 | return addon->toAddon->addonInstance->LoadPreset(*static_cast<const int*>(param)); | ||
| 741 | case VIS_ACTION_RANDOM_PRESET: | ||
| 742 | return addon->toAddon->addonInstance->RandomPreset(); | ||
| 743 | case VIS_ACTION_LOCK_PRESET: | ||
| 744 | addon->toAddon->addonInstance->m_presetLockedByUser = !addon->toAddon->addonInstance->m_presetLockedByUser; | ||
| 745 | return addon->toAddon->addonInstance->LockPreset(addon->toAddon->addonInstance->m_presetLockedByUser); | ||
| 746 | case VIS_ACTION_RATE_PRESET_PLUS: | ||
| 747 | return addon->toAddon->addonInstance->RatePreset(true); | ||
| 748 | case VIS_ACTION_RATE_PRESET_MINUS: | ||
| 749 | return addon->toAddon->addonInstance->RatePreset(false); | ||
| 750 | case VIS_ACTION_UPDATE_ALBUMART: | ||
| 751 | return addon->toAddon->addonInstance->UpdateAlbumart(static_cast<const char*>(param)); | ||
| 752 | case VIS_ACTION_UPDATE_TRACK: | ||
| 753 | return addon->toAddon->addonInstance->UpdateTrack(*static_cast<const VisTrack*>(param)); | ||
| 754 | case VIS_ACTION_NONE: | ||
| 755 | default: | ||
| 756 | break; | ||
| 757 | } | ||
| 758 | return false; | ||
| 759 | } | ||
| 760 | |||
| 761 | inline static unsigned int ADDON_GetPresets(const AddonInstance_Visualization* addon) | ||
| 762 | { | ||
| 763 | std::vector<std::string> presets; | ||
| 764 | if (addon->toAddon->addonInstance->GetPresets(presets)) | ||
| 765 | { | ||
| 766 | for (auto it : presets) | ||
| 767 | addon->toAddon->addonInstance->m_instanceData->toKodi->transfer_preset(addon->toKodi->kodiInstance, it.c_str()); | ||
| 768 | } | ||
| 769 | |||
| 770 | return static_cast<unsigned int>(presets.size()); | ||
| 771 | } | ||
| 772 | |||
| 773 | inline static int ADDON_GetActivePreset(const AddonInstance_Visualization* addon) | ||
| 774 | { | ||
| 775 | return addon->toAddon->addonInstance->GetActivePreset(); | ||
| 776 | } | ||
| 777 | |||
| 778 | inline static bool ADDON_IsLocked(const AddonInstance_Visualization* addon) | ||
| 779 | { | ||
| 780 | return addon->toAddon->addonInstance->IsLocked(); | ||
| 781 | } | ||
| 782 | |||
| 783 | std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper; | ||
| 784 | bool m_presetLockedByUser = false; | ||
| 785 | AddonInstance_Visualization* m_instanceData; | ||
| 786 | }; | ||
| 787 | |||
| 788 | } /* namespace addon */ | ||
| 789 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt deleted file mode 100644 index dfcfe66..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt +++ /dev/null | |||
| @@ -1,6 +0,0 @@ | |||
| 1 | set(HEADERS image_decoder.h | ||
| 2 | pvr.h) | ||
| 3 | |||
| 4 | if(NOT ENABLE_STATIC_LIBS) | ||
| 5 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_c-api_addon-instance) | ||
| 6 | endif() | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h deleted file mode 100644 index b5a6393..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h +++ /dev/null | |||
| @@ -1,175 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | #include "definitions.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | |||
| 19 | //============================================================================ | ||
| 20 | /// | ||
| 21 | // \defgroup cpp_kodi_gui ::general | ||
| 22 | /// \addtogroup cpp_kodi_gui | ||
| 23 | /// @{ | ||
| 24 | /// @brief **Allow use of binary classes and function to use on add-on's** | ||
| 25 | /// | ||
| 26 | /// Permits the use of the required functions of the add-on to Kodi. This class | ||
| 27 | /// also contains some functions to the control. | ||
| 28 | /// | ||
| 29 | /// These are pure functions them no other initialization need. | ||
| 30 | /// | ||
| 31 | /// It has the header \ref kodi/gui/General.h "#include <kodi/gui/General.h>" be included | ||
| 32 | /// to enjoy it. | ||
| 33 | /// | ||
| 34 | |||
| 35 | //========================================================================== | ||
| 36 | /// | ||
| 37 | /// \ingroup cpp_kodi_gui | ||
| 38 | /// @brief Performs a graphical lock of rendering engine | ||
| 39 | /// | ||
| 40 | inline void ATTRIBUTE_HIDDEN Lock() | ||
| 41 | { | ||
| 42 | using namespace ::kodi::addon; | ||
| 43 | CAddonBase::m_interface->toKodi->kodi_gui->general->lock(); | ||
| 44 | } | ||
| 45 | |||
| 46 | //-------------------------------------------------------------------------- | ||
| 47 | |||
| 48 | //========================================================================== | ||
| 49 | /// | ||
| 50 | /// \ingroup cpp_kodi_gui | ||
| 51 | /// @brief Performs a graphical unlock of previous locked rendering engine | ||
| 52 | /// | ||
| 53 | inline void ATTRIBUTE_HIDDEN Unlock() | ||
| 54 | { | ||
| 55 | using namespace ::kodi::addon; | ||
| 56 | CAddonBase::m_interface->toKodi->kodi_gui->general->unlock(); | ||
| 57 | } | ||
| 58 | //-------------------------------------------------------------------------- | ||
| 59 | |||
| 60 | //========================================================================== | ||
| 61 | /// | ||
| 62 | /// \ingroup cpp_kodi_gui | ||
| 63 | /// @brief Return the the current screen height with pixel | ||
| 64 | /// | ||
| 65 | inline int ATTRIBUTE_HIDDEN GetScreenHeight() | ||
| 66 | { | ||
| 67 | using namespace ::kodi::addon; | ||
| 68 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_height(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 69 | } | ||
| 70 | //-------------------------------------------------------------------------- | ||
| 71 | |||
| 72 | //========================================================================== | ||
| 73 | /// | ||
| 74 | /// \ingroup cpp_kodi_gui | ||
| 75 | /// @brief Return the the current screen width with pixel | ||
| 76 | /// | ||
| 77 | inline int ATTRIBUTE_HIDDEN GetScreenWidth() | ||
| 78 | { | ||
| 79 | using namespace ::kodi::addon; | ||
| 80 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_width(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 81 | } | ||
| 82 | //-------------------------------------------------------------------------- | ||
| 83 | |||
| 84 | //========================================================================== | ||
| 85 | /// | ||
| 86 | /// \ingroup cpp_kodi_gui | ||
| 87 | /// @brief Return the the current screen rendering resolution | ||
| 88 | /// | ||
| 89 | inline int ATTRIBUTE_HIDDEN GetVideoResolution() | ||
| 90 | { | ||
| 91 | using namespace ::kodi::addon; | ||
| 92 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_video_resolution(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 93 | } | ||
| 94 | //-------------------------------------------------------------------------- | ||
| 95 | |||
| 96 | //========================================================================== | ||
| 97 | /// | ||
| 98 | /// \ingroup cpp_kodi_gui | ||
| 99 | /// @brief Returns the id for the current 'active' dialog as an integer. | ||
| 100 | /// | ||
| 101 | /// @return The currently active dialog Id | ||
| 102 | /// | ||
| 103 | /// | ||
| 104 | ///------------------------------------------------------------------------- | ||
| 105 | /// | ||
| 106 | /// **Example:** | ||
| 107 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 108 | /// .. | ||
| 109 | /// int wid = kodi::gui::GetCurrentWindowDialogId(); | ||
| 110 | /// .. | ||
| 111 | /// ~~~~~~~~~~~~~ | ||
| 112 | /// | ||
| 113 | inline int ATTRIBUTE_HIDDEN GetCurrentWindowDialogId() | ||
| 114 | { | ||
| 115 | using namespace ::kodi::addon; | ||
| 116 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_dialog_id(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 117 | } | ||
| 118 | //-------------------------------------------------------------------------- | ||
| 119 | |||
| 120 | //========================================================================== | ||
| 121 | /// | ||
| 122 | /// \ingroup cpp_kodi_gui | ||
| 123 | /// @brief Returns the id for the current 'active' window as an integer. | ||
| 124 | /// | ||
| 125 | /// @return The currently active window Id | ||
| 126 | /// | ||
| 127 | /// | ||
| 128 | ///------------------------------------------------------------------------- | ||
| 129 | /// | ||
| 130 | /// **Example:** | ||
| 131 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 132 | /// .. | ||
| 133 | /// int wid = kodi::gui::GetCurrentWindowId(); | ||
| 134 | /// .. | ||
| 135 | /// ~~~~~~~~~~~~~ | ||
| 136 | /// | ||
| 137 | inline int ATTRIBUTE_HIDDEN GetCurrentWindowId() | ||
| 138 | { | ||
| 139 | using namespace ::kodi::addon; | ||
| 140 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_id(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 141 | } | ||
| 142 | //-------------------------------------------------------------------------- | ||
| 143 | |||
| 144 | //========================================================================== | ||
| 145 | /// | ||
| 146 | /// \ingroup cpp_kodi_gui | ||
| 147 | /// \brief To get hardware specific device context interface | ||
| 148 | /// | ||
| 149 | /// \return The currently active device context | ||
| 150 | /// | ||
| 151 | /// \warning This function is only be supported under Windows, on all other | ||
| 152 | /// OS it return `nullptr`! | ||
| 153 | /// | ||
| 154 | /// \note Returned Windows class pointer is `ID3D11DeviceContext1`. | ||
| 155 | /// | ||
| 156 | /// | ||
| 157 | ///------------------------------------------------------------------------- | ||
| 158 | /// | ||
| 159 | /// **Example:** | ||
| 160 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 161 | /// #include <d3d11_1.h> | ||
| 162 | /// .. | ||
| 163 | /// ID3D11DeviceContext1* context = static_cast<ID3D11DeviceContext1*>(kodi::gui::GetHWContext()); | ||
| 164 | /// .. | ||
| 165 | /// ~~~~~~~~~~~~~ | ||
| 166 | /// | ||
| 167 | inline void* GetHWContext() | ||
| 168 | { | ||
| 169 | using namespace ::kodi::addon; | ||
| 170 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_hw_context(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 171 | } | ||
| 172 | //-------------------------------------------------------------------------- | ||
| 173 | |||
| 174 | } /* namespace gui */ | ||
| 175 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h deleted file mode 100644 index 1af4863..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h +++ /dev/null | |||
| @@ -1,366 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | #include "definitions.h" | ||
| 13 | |||
| 14 | #include <memory> | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | |||
| 21 | class CWindow; | ||
| 22 | |||
| 23 | class ATTRIBUTE_HIDDEN CAddonGUIControlBase | ||
| 24 | { | ||
| 25 | public: | ||
| 26 | GUIHANDLE GetControlHandle() const { return m_controlHandle; } | ||
| 27 | |||
| 28 | protected: | ||
| 29 | explicit CAddonGUIControlBase(CAddonGUIControlBase* window) | ||
| 30 | : m_controlHandle(nullptr), | ||
| 31 | m_interface(::kodi::addon::CAddonBase::m_interface->toKodi), | ||
| 32 | m_Window(window) {} | ||
| 33 | |||
| 34 | virtual ~CAddonGUIControlBase() = default; | ||
| 35 | |||
| 36 | friend class CWindow; | ||
| 37 | |||
| 38 | GUIHANDLE m_controlHandle; | ||
| 39 | AddonToKodiFuncTable_Addon* m_interface; | ||
| 40 | CAddonGUIControlBase* m_Window; | ||
| 41 | |||
| 42 | private: | ||
| 43 | CAddonGUIControlBase() = delete; | ||
| 44 | CAddonGUIControlBase(const CAddonGUIControlBase&) = delete; | ||
| 45 | CAddonGUIControlBase &operator=(const CAddonGUIControlBase&) = delete; | ||
| 46 | }; | ||
| 47 | |||
| 48 | class CListItem; | ||
| 49 | typedef std::shared_ptr<CListItem> ListItemPtr; | ||
| 50 | |||
| 51 | //============================================================================ | ||
| 52 | /// | ||
| 53 | /// \defgroup cpp_kodi_gui_CListItem List Item | ||
| 54 | /// \ingroup cpp_kodi_gui | ||
| 55 | /// @brief \cpp_class{ kodi::gui::CListItem } | ||
| 56 | /// **Selectable window list item** | ||
| 57 | /// | ||
| 58 | /// The list item control is used for creating item lists in Kodi | ||
| 59 | /// | ||
| 60 | /// The with \ref ListItem.h "#include <kodi/gui/ListItem.h>" given | ||
| 61 | /// class is used to create a item entry for a list on window and to support it's | ||
| 62 | /// control. | ||
| 63 | /// | ||
| 64 | |||
| 65 | //============================================================================ | ||
| 66 | /// | ||
| 67 | /// \defgroup cpp_kodi_gui_CListItem_Defs Definitions, structures and enumerators | ||
| 68 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 69 | /// @brief **Library definition values** | ||
| 70 | /// | ||
| 71 | |||
| 72 | class ATTRIBUTE_HIDDEN CListItem : public CAddonGUIControlBase | ||
| 73 | { | ||
| 74 | public: | ||
| 75 | //========================================================================== | ||
| 76 | /// | ||
| 77 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 78 | /// @brief Class constructor with parameters | ||
| 79 | /// | ||
| 80 | /// @param[in] label Item label | ||
| 81 | /// @param[in] label2 Second Item label (if needed) | ||
| 82 | /// @param[in] iconImage Item icon image (if needed) | ||
| 83 | /// @param[in] path Path to where item is defined | ||
| 84 | /// | ||
| 85 | CListItem( | ||
| 86 | const std::string& label = "", | ||
| 87 | const std::string& label2 = "", | ||
| 88 | const std::string& iconImage = "", | ||
| 89 | const std::string& path = "") | ||
| 90 | : CAddonGUIControlBase(nullptr) | ||
| 91 | { | ||
| 92 | m_controlHandle = m_interface->kodi_gui->listItem->create(m_interface->kodiBase, label.c_str(), | ||
| 93 | label2.c_str(), iconImage.c_str(), | ||
| 94 | path.c_str()); | ||
| 95 | } | ||
| 96 | |||
| 97 | /* | ||
| 98 | * Constructor used for parts given by list items from addon window | ||
| 99 | * | ||
| 100 | * Related to call of "ListItemPtr kodi::gui::CWindow::GetListItem(int listPos)" | ||
| 101 | * Not needed for addon development itself | ||
| 102 | */ | ||
| 103 | explicit CListItem(GUIHANDLE listItemHandle) | ||
| 104 | : CAddonGUIControlBase(nullptr) | ||
| 105 | { | ||
| 106 | m_controlHandle = listItemHandle; | ||
| 107 | } | ||
| 108 | |||
| 109 | //========================================================================== | ||
| 110 | /// | ||
| 111 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 112 | /// @brief Class destructor | ||
| 113 | /// | ||
| 114 | ~CListItem() override | ||
| 115 | { | ||
| 116 | m_interface->kodi_gui->listItem->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 117 | } | ||
| 118 | //-------------------------------------------------------------------------- | ||
| 119 | |||
| 120 | //========================================================================== | ||
| 121 | /// | ||
| 122 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 123 | /// @brief Returns the listitem label. | ||
| 124 | /// | ||
| 125 | /// @return Label of item | ||
| 126 | /// | ||
| 127 | std::string GetLabel() | ||
| 128 | { | ||
| 129 | std::string label; | ||
| 130 | char* ret = m_interface->kodi_gui->listItem->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 131 | if (ret != nullptr) | ||
| 132 | { | ||
| 133 | if (std::strlen(ret)) | ||
| 134 | label = ret; | ||
| 135 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 136 | } | ||
| 137 | return label; | ||
| 138 | } | ||
| 139 | //-------------------------------------------------------------------------- | ||
| 140 | |||
| 141 | //========================================================================== | ||
| 142 | /// | ||
| 143 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 144 | /// @brief Sets the listitem label. | ||
| 145 | /// | ||
| 146 | /// @param[in] label string or unicode - text string. | ||
| 147 | /// | ||
| 148 | void SetLabel(const std::string& label) | ||
| 149 | { | ||
| 150 | m_interface->kodi_gui->listItem->set_label(m_interface->kodiBase, m_controlHandle, label.c_str()); | ||
| 151 | } | ||
| 152 | //-------------------------------------------------------------------------- | ||
| 153 | |||
| 154 | //========================================================================== | ||
| 155 | /// | ||
| 156 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 157 | /// @brief Returns the second listitem label. | ||
| 158 | /// | ||
| 159 | /// @return Second label of item | ||
| 160 | /// | ||
| 161 | std::string GetLabel2() | ||
| 162 | { | ||
| 163 | std::string label; | ||
| 164 | char* ret = m_interface->kodi_gui->listItem->get_label2(m_interface->kodiBase, m_controlHandle); | ||
| 165 | if (ret != nullptr) | ||
| 166 | { | ||
| 167 | if (std::strlen(ret)) | ||
| 168 | label = ret; | ||
| 169 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 170 | } | ||
| 171 | return label; | ||
| 172 | } | ||
| 173 | //-------------------------------------------------------------------------- | ||
| 174 | |||
| 175 | //========================================================================== | ||
| 176 | /// | ||
| 177 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 178 | /// @brief Sets the listitem's label2. | ||
| 179 | /// | ||
| 180 | /// @param[in] label string or unicode - text string. | ||
| 181 | /// | ||
| 182 | void SetLabel2(const std::string& label) | ||
| 183 | { | ||
| 184 | m_interface->kodi_gui->listItem->set_label2(m_interface->kodiBase, m_controlHandle, label.c_str()); | ||
| 185 | } | ||
| 186 | //-------------------------------------------------------------------------- | ||
| 187 | |||
| 188 | //========================================================================== | ||
| 189 | /// | ||
| 190 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 191 | /// @brief Sets the listitem's art | ||
| 192 | /// | ||
| 193 | /// @param[in] type Type of Art to set | ||
| 194 | /// - Some default art values (any string possible): | ||
| 195 | /// | value (type) | Type | | ||
| 196 | /// |:-------------:|:--------------------------------------------------| | ||
| 197 | /// | thumb | string - image filename | ||
| 198 | /// | poster | string - image filename | ||
| 199 | /// | banner | string - image filename | ||
| 200 | /// | fanart | string - image filename | ||
| 201 | /// | clearart | string - image filename | ||
| 202 | /// | clearlogo | string - image filename | ||
| 203 | /// | landscape | string - image filename | ||
| 204 | /// | icon | string - image filename | ||
| 205 | /// @return The url to use for Art | ||
| 206 | /// | ||
| 207 | std::string GetArt(const std::string& type) | ||
| 208 | { | ||
| 209 | std::string strReturn; | ||
| 210 | char* ret = m_interface->kodi_gui->listItem->get_art(m_interface->kodiBase, m_controlHandle, type.c_str()); | ||
| 211 | if (ret != nullptr) | ||
| 212 | { | ||
| 213 | if (std::strlen(ret)) | ||
| 214 | strReturn = ret; | ||
| 215 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 216 | } | ||
| 217 | return strReturn; | ||
| 218 | } | ||
| 219 | //-------------------------------------------------------------------------- | ||
| 220 | |||
| 221 | //========================================================================== | ||
| 222 | /// | ||
| 223 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 224 | /// @brief Sets the listitem's art | ||
| 225 | /// | ||
| 226 | /// @param[in] type Type of Art to set | ||
| 227 | /// @param[in] url The url to use for Art | ||
| 228 | /// - Some default art values (any string possible): | ||
| 229 | /// | value (type) | Type | | ||
| 230 | /// |:-------------:|:--------------------------------------------------| | ||
| 231 | /// | thumb | string - image filename | ||
| 232 | /// | poster | string - image filename | ||
| 233 | /// | banner | string - image filename | ||
| 234 | /// | fanart | string - image filename | ||
| 235 | /// | clearart | string - image filename | ||
| 236 | /// | clearlogo | string - image filename | ||
| 237 | /// | landscape | string - image filename | ||
| 238 | /// | icon | string - image filename | ||
| 239 | /// | ||
| 240 | void SetArt(const std::string& type, const std::string& url) | ||
| 241 | { | ||
| 242 | m_interface->kodi_gui->listItem->set_art(m_interface->kodiBase, m_controlHandle, type.c_str(), url.c_str()); | ||
| 243 | } | ||
| 244 | //-------------------------------------------------------------------------- | ||
| 245 | |||
| 246 | //========================================================================== | ||
| 247 | /// | ||
| 248 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 249 | /// @brief Returns the path / filename of this listitem. | ||
| 250 | /// | ||
| 251 | /// @return Path string | ||
| 252 | /// | ||
| 253 | std::string GetPath() | ||
| 254 | { | ||
| 255 | std::string strReturn; | ||
| 256 | char* ret = m_interface->kodi_gui->listItem->get_path(m_interface->kodiBase, m_controlHandle); | ||
| 257 | if (ret != nullptr) | ||
| 258 | { | ||
| 259 | if (std::strlen(ret)) | ||
| 260 | strReturn = ret; | ||
| 261 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 262 | } | ||
| 263 | return strReturn; | ||
| 264 | } | ||
| 265 | //-------------------------------------------------------------------------- | ||
| 266 | |||
| 267 | //========================================================================== | ||
| 268 | /// | ||
| 269 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 270 | /// @brief Sets the listitem's path. | ||
| 271 | /// | ||
| 272 | /// @param[in] path string or unicode - path, activated when | ||
| 273 | /// item is clicked. | ||
| 274 | /// | ||
| 275 | /// @note You can use the above as keywords for arguments. | ||
| 276 | /// | ||
| 277 | void SetPath(const std::string& path) | ||
| 278 | { | ||
| 279 | m_interface->kodi_gui->listItem->set_path(m_interface->kodiBase, m_controlHandle, path.c_str()); | ||
| 280 | } | ||
| 281 | //-------------------------------------------------------------------------- | ||
| 282 | |||
| 283 | //========================================================================== | ||
| 284 | /// | ||
| 285 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 286 | /// @brief Sets a listitem property, similar to an infolabel. | ||
| 287 | /// | ||
| 288 | /// @param[in] key string - property name. | ||
| 289 | /// @param[in] value string or unicode - value of property. | ||
| 290 | /// | ||
| 291 | /// @note Key is NOT case sensitive. | ||
| 292 | /// You can use the above as keywords for arguments and skip certain\n | ||
| 293 | /// optional arguments.\n | ||
| 294 | /// Once you use a keyword, all following arguments require the | ||
| 295 | /// keyword. | ||
| 296 | /// | ||
| 297 | /// Some of these are treated internally by Kodi, such as the | ||
| 298 | /// <b>'StartOffset'</b> property, which is the offset in seconds at which to | ||
| 299 | /// start playback of an item. Others may be used in the skin to add | ||
| 300 | /// extra information, such as <b>'WatchedCount'</b> for tvshow items | ||
| 301 | /// | ||
| 302 | void SetProperty(const std::string& key, const std::string& value) | ||
| 303 | { | ||
| 304 | m_interface->kodi_gui->listItem->set_property(m_interface->kodiBase, m_controlHandle, key.c_str(), value.c_str()); | ||
| 305 | } | ||
| 306 | //-------------------------------------------------------------------------- | ||
| 307 | |||
| 308 | //========================================================================== | ||
| 309 | /// | ||
| 310 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 311 | /// @brief Returns a listitem property as a string, similar to an infolabel. | ||
| 312 | /// | ||
| 313 | /// @param[in] key string - property name. | ||
| 314 | /// @return string - List item property | ||
| 315 | /// | ||
| 316 | /// @note Key is NOT case sensitive.\n | ||
| 317 | /// You can use the above as keywords for arguments and skip certain | ||
| 318 | /// optional arguments.\n | ||
| 319 | /// Once you use a keyword, all following arguments require the | ||
| 320 | /// keyword. | ||
| 321 | /// | ||
| 322 | std::string GetProperty(const std::string& key) | ||
| 323 | { | ||
| 324 | std::string label; | ||
| 325 | char* ret = m_interface->kodi_gui->listItem->get_property(m_interface->kodiBase, m_controlHandle, key.c_str()); | ||
| 326 | if (ret != nullptr) | ||
| 327 | { | ||
| 328 | if (std::strlen(ret)) | ||
| 329 | label = ret; | ||
| 330 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 331 | } | ||
| 332 | return label; | ||
| 333 | } | ||
| 334 | //-------------------------------------------------------------------------- | ||
| 335 | |||
| 336 | //========================================================================== | ||
| 337 | /// | ||
| 338 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 339 | /// @brief To control selection of item in list (also multiple selection, | ||
| 340 | /// in list on serveral items possible). | ||
| 341 | /// | ||
| 342 | /// @param[in] selected if true becomes set as selected | ||
| 343 | /// | ||
| 344 | void Select(bool selected) | ||
| 345 | { | ||
| 346 | m_interface->kodi_gui->listItem->select(m_interface->kodiBase, m_controlHandle, selected); | ||
| 347 | } | ||
| 348 | //-------------------------------------------------------------------------- | ||
| 349 | |||
| 350 | //========================================================================== | ||
| 351 | /// | ||
| 352 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 353 | /// @brief Returns the listitem's selected status. | ||
| 354 | /// | ||
| 355 | /// @return true if selected, otherwise false | ||
| 356 | /// | ||
| 357 | bool IsSelected() | ||
| 358 | { | ||
| 359 | return m_interface->kodi_gui->listItem->is_selected(m_interface->kodiBase, m_controlHandle); | ||
| 360 | } | ||
| 361 | //-------------------------------------------------------------------------- | ||
| 362 | |||
| 363 | }; | ||
| 364 | |||
| 365 | } /* namespace gui */ | ||
| 366 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h deleted file mode 100644 index 5011374..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h +++ /dev/null | |||
| @@ -1,909 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | #include "ListItem.h" | ||
| 13 | |||
| 14 | #ifdef BUILD_KODI_ADDON | ||
| 15 | #include "../ActionIDs.h" | ||
| 16 | #else | ||
| 17 | #include "input/actions/ActionIDs.h" | ||
| 18 | #endif | ||
| 19 | |||
| 20 | namespace kodi | ||
| 21 | { | ||
| 22 | namespace gui | ||
| 23 | { | ||
| 24 | |||
| 25 | class CListItem; | ||
| 26 | |||
| 27 | //============================================================================ | ||
| 28 | /// | ||
| 29 | /// \defgroup cpp_kodi_gui_CWindow Window | ||
| 30 | /// \ingroup cpp_kodi_gui | ||
| 31 | /// @brief \cpp_class{ kodi::gui::CWindow } | ||
| 32 | /// **Main window control class** | ||
| 33 | /// | ||
| 34 | /// The with \ref Window.h "#include <kodi/gui/Window.h>" | ||
| 35 | /// included file brings support to create a window or dialog on Kodi. | ||
| 36 | /// | ||
| 37 | /// -------------------------------------------------------------------------- | ||
| 38 | /// | ||
| 39 | /// On functions defined input variable <b><tt>controlId</tt> (GUI control identifier)</b> | ||
| 40 | /// is the on window.xml defined value behind type added with <tt><b>id="..."</b></tt> and | ||
| 41 | /// used to identify for changes there and on callbacks. | ||
| 42 | /// | ||
| 43 | /// ~~~~~~~~~~~~~{.xml} | ||
| 44 | /// <control type="label" id="31"> | ||
| 45 | /// <description>Title Label</description> | ||
| 46 | /// ... | ||
| 47 | /// </control> | ||
| 48 | /// <control type="progress" id="32"> | ||
| 49 | /// <description>progress control</description> | ||
| 50 | /// ... | ||
| 51 | /// </control> | ||
| 52 | /// ~~~~~~~~~~~~~ | ||
| 53 | /// | ||
| 54 | /// | ||
| 55 | |||
| 56 | //============================================================================ | ||
| 57 | /// | ||
| 58 | /// \defgroup cpp_kodi_gui_CWindow_Defs Definitions, structures and enumerators | ||
| 59 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 60 | /// @brief <b>Library definition values</b> | ||
| 61 | /// | ||
| 62 | |||
| 63 | class ATTRIBUTE_HIDDEN CWindow : public CAddonGUIControlBase | ||
| 64 | { | ||
| 65 | public: | ||
| 66 | //========================================================================== | ||
| 67 | /// | ||
| 68 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 69 | /// @brief Class constructor with needed values for window / dialog. | ||
| 70 | /// | ||
| 71 | /// Creates a new Window class. | ||
| 72 | /// | ||
| 73 | /// @param[in] xmlFilename XML file for the skin | ||
| 74 | /// @param[in] defaultSkin default skin to use if needed not available | ||
| 75 | /// @param[in] asDialog Use window as dialog if set | ||
| 76 | /// @param[in] isMedia [opt] bool - if False, create a regular window. | ||
| 77 | /// if True, create a mediawindow. | ||
| 78 | /// (default=false) | ||
| 79 | /// @note only usable for windows not for dialogs. | ||
| 80 | /// | ||
| 81 | /// | ||
| 82 | CWindow(const std::string& xmlFilename, const std::string& defaultSkin, bool asDialog, bool isMedia = false) | ||
| 83 | : CAddonGUIControlBase(nullptr) | ||
| 84 | { | ||
| 85 | m_controlHandle = m_interface->kodi_gui->window->create(m_interface->kodiBase, xmlFilename.c_str(), | ||
| 86 | defaultSkin.c_str(), asDialog, isMedia); | ||
| 87 | if (!m_controlHandle) | ||
| 88 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CWindow can't create window class from Kodi !!!"); | ||
| 89 | m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, this, | ||
| 90 | CBOnInit, CBOnFocus, CBOnClick, CBOnAction, | ||
| 91 | CBGetContextButtons, CBOnContextButton); | ||
| 92 | } | ||
| 93 | //-------------------------------------------------------------------------- | ||
| 94 | |||
| 95 | //========================================================================== | ||
| 96 | /// | ||
| 97 | /// \ingroup CWindow | ||
| 98 | /// @brief Class destructor | ||
| 99 | /// | ||
| 100 | /// | ||
| 101 | /// | ||
| 102 | ~CWindow() override | ||
| 103 | { | ||
| 104 | if (m_controlHandle) | ||
| 105 | m_interface->kodi_gui->window->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 106 | } | ||
| 107 | //-------------------------------------------------------------------------- | ||
| 108 | |||
| 109 | //========================================================================== | ||
| 110 | /// | ||
| 111 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 112 | /// @brief Show this window. | ||
| 113 | /// | ||
| 114 | /// Shows this window by activating it, calling close() after it wil activate the | ||
| 115 | /// current window again. | ||
| 116 | /// | ||
| 117 | /// @note If your Add-On ends this window will be closed to. To show it forever, | ||
| 118 | /// make a loop at the end of your Add-On or use doModal() instead. | ||
| 119 | /// | ||
| 120 | /// @warning If used must be the class be global present until Kodi becomes | ||
| 121 | /// closed. The creation can be done after before "Show" becomes called, but | ||
| 122 | /// not delete class after them. | ||
| 123 | /// | ||
| 124 | /// @return Return true if call and show is successed, | ||
| 125 | /// if false was something failed to get needed | ||
| 126 | /// skin parts. | ||
| 127 | /// | ||
| 128 | bool Show() | ||
| 129 | { | ||
| 130 | return m_interface->kodi_gui->window->show(m_interface->kodiBase, m_controlHandle); | ||
| 131 | } | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 137 | /// @brief Closes this window. | ||
| 138 | /// | ||
| 139 | /// Closes this window by activating the old window. | ||
| 140 | /// @note The window is not deleted with this method. | ||
| 141 | /// | ||
| 142 | void Close() | ||
| 143 | { | ||
| 144 | m_interface->kodi_gui->window->close(m_interface->kodiBase, m_controlHandle); | ||
| 145 | } | ||
| 146 | //-------------------------------------------------------------------------- | ||
| 147 | |||
| 148 | //========================================================================== | ||
| 149 | /// | ||
| 150 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 151 | /// @brief Display this window until close() is called. | ||
| 152 | /// | ||
| 153 | void DoModal() | ||
| 154 | { | ||
| 155 | m_interface->kodi_gui->window->do_modal(m_interface->kodiBase, m_controlHandle); | ||
| 156 | } | ||
| 157 | //-------------------------------------------------------------------------- | ||
| 158 | |||
| 159 | //========================================================================== | ||
| 160 | /// | ||
| 161 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 162 | /// @brief Gives the control with the supplied focus. | ||
| 163 | /// | ||
| 164 | /// @param[in] iControlId On skin defined id of control | ||
| 165 | /// @return Return true if call and focus is successed, | ||
| 166 | /// if false was something failed to get needed | ||
| 167 | /// skin parts. | ||
| 168 | /// | ||
| 169 | /// | ||
| 170 | bool SetFocusId(int iControlId) | ||
| 171 | { | ||
| 172 | return m_interface->kodi_gui->window->set_focus_id(m_interface->kodiBase, m_controlHandle, iControlId); | ||
| 173 | } | ||
| 174 | //-------------------------------------------------------------------------- | ||
| 175 | |||
| 176 | //========================================================================== | ||
| 177 | /// | ||
| 178 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 179 | /// @brief Returns the id of the control which is focused. | ||
| 180 | /// | ||
| 181 | /// @return Focused control id | ||
| 182 | /// | ||
| 183 | /// | ||
| 184 | int GetFocusId() | ||
| 185 | { | ||
| 186 | return m_interface->kodi_gui->window->get_focus_id(m_interface->kodiBase, m_controlHandle); | ||
| 187 | } | ||
| 188 | //-------------------------------------------------------------------------- | ||
| 189 | |||
| 190 | //========================================================================== | ||
| 191 | /// | ||
| 192 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 193 | /// @brief To set the used label on given control id | ||
| 194 | /// | ||
| 195 | /// @param[in] controlId Control id where label need to set | ||
| 196 | /// @param[in] label Label to use | ||
| 197 | /// | ||
| 198 | /// | ||
| 199 | void SetControlLabel(int controlId, const std::string& label) | ||
| 200 | { | ||
| 201 | m_interface->kodi_gui->window->set_control_label(m_interface->kodiBase, m_controlHandle, controlId, label.c_str()); | ||
| 202 | } | ||
| 203 | //-------------------------------------------------------------------------- | ||
| 204 | |||
| 205 | //========================================================================== | ||
| 206 | /// | ||
| 207 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 208 | /// @brief To set the visibility on given control id | ||
| 209 | /// | ||
| 210 | /// @param[in] controlId Control id where visibility is changed | ||
| 211 | /// @param[in] visible Boolean value with `true` for visible, `false` for hidden | ||
| 212 | /// | ||
| 213 | /// | ||
| 214 | void SetControlVisible(int controlId, bool visible) | ||
| 215 | { | ||
| 216 | m_interface->kodi_gui->window->set_control_visible(m_interface->kodiBase, m_controlHandle, controlId, visible); | ||
| 217 | } | ||
| 218 | //-------------------------------------------------------------------------- | ||
| 219 | |||
| 220 | //========================================================================== | ||
| 221 | /// | ||
| 222 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 223 | /// @brief To set the selection on given control id | ||
| 224 | /// | ||
| 225 | /// @param[in] controlId Control id where selection is changed | ||
| 226 | /// @param[in] selected Boolean value with `true` for selected, `false` for not | ||
| 227 | /// | ||
| 228 | /// | ||
| 229 | void SetControlSelected(int controlId, bool selected) | ||
| 230 | { | ||
| 231 | m_interface->kodi_gui->window->set_control_selected(m_interface->kodiBase, m_controlHandle, controlId, selected); | ||
| 232 | } | ||
| 233 | //-------------------------------------------------------------------------- | ||
| 234 | |||
| 235 | //========================================================================== | ||
| 236 | /// | ||
| 237 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 238 | /// @brief Sets a window property, similar to an infolabel. | ||
| 239 | /// | ||
| 240 | /// @param[in] key string - property name. | ||
| 241 | /// @param[in] value string or unicode - value of property. | ||
| 242 | /// | ||
| 243 | /// @note Key is NOT case sensitive. Setting value to an empty string is | ||
| 244 | /// equivalent to clearProperty(key).\n | ||
| 245 | /// You can use the above as keywords for arguments and skip certain | ||
| 246 | /// optional arguments.\n | ||
| 247 | /// Once you use a keyword, all following arguments require the keyword. | ||
| 248 | /// | ||
| 249 | void SetProperty(const std::string& key, const std::string& value) | ||
| 250 | { | ||
| 251 | m_interface->kodi_gui->window->set_property(m_interface->kodiBase, m_controlHandle, key.c_str(), value.c_str()); | ||
| 252 | } | ||
| 253 | //-------------------------------------------------------------------------- | ||
| 254 | |||
| 255 | //========================================================================== | ||
| 256 | /// | ||
| 257 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 258 | /// @brief Returns a window property as a string, similar to an infolabel. | ||
| 259 | /// | ||
| 260 | /// @param[in] key string - property name. | ||
| 261 | /// @return The property as strin (if present) | ||
| 262 | /// | ||
| 263 | /// @note Key is NOT case sensitive. Setting value to an empty string is | ||
| 264 | /// equivalent to clearProperty(key).\n | ||
| 265 | /// You can use the above as keywords for arguments and skip certain | ||
| 266 | /// optional arguments.\n | ||
| 267 | /// Once you use a keyword, all following arguments require the keyword. | ||
| 268 | /// | ||
| 269 | /// | ||
| 270 | std::string GetProperty(const std::string& key) const | ||
| 271 | { | ||
| 272 | std::string label; | ||
| 273 | char* ret = m_interface->kodi_gui->window->get_property(m_interface->kodiBase, m_controlHandle, key.c_str()); | ||
| 274 | if (ret != nullptr) | ||
| 275 | { | ||
| 276 | if (std::strlen(ret)) | ||
| 277 | label = ret; | ||
| 278 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 279 | } | ||
| 280 | return label; | ||
| 281 | } | ||
| 282 | //-------------------------------------------------------------------------- | ||
| 283 | |||
| 284 | //========================================================================== | ||
| 285 | /// | ||
| 286 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 287 | /// @brief Sets a window property with integer value | ||
| 288 | /// | ||
| 289 | /// @param[in] key string - property name. | ||
| 290 | /// @param[in] value integer value to set | ||
| 291 | /// | ||
| 292 | /// | ||
| 293 | void SetPropertyInt(const std::string& key, int value) | ||
| 294 | { | ||
| 295 | m_interface->kodi_gui->window->set_property_int(m_interface->kodiBase, m_controlHandle, key.c_str(), value); | ||
| 296 | } | ||
| 297 | //-------------------------------------------------------------------------- | ||
| 298 | |||
| 299 | //========================================================================== | ||
| 300 | /// | ||
| 301 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 302 | /// @brief Returns a window property with integer value | ||
| 303 | /// | ||
| 304 | /// @param[in] key string - property name. | ||
| 305 | /// @return integer value of property | ||
| 306 | /// | ||
| 307 | int GetPropertyInt(const std::string& key) const | ||
| 308 | { | ||
| 309 | return m_interface->kodi_gui->window->get_property_int(m_interface->kodiBase, m_controlHandle, key.c_str()); | ||
| 310 | } | ||
| 311 | //-------------------------------------------------------------------------- | ||
| 312 | |||
| 313 | //========================================================================== | ||
| 314 | /// | ||
| 315 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 316 | /// @brief Sets a window property with boolean value | ||
| 317 | /// | ||
| 318 | /// @param[in] key string - property name. | ||
| 319 | /// @param[in] value boolean value to set | ||
| 320 | /// | ||
| 321 | /// | ||
| 322 | void SetPropertyBool(const std::string& key, bool value) | ||
| 323 | { | ||
| 324 | m_interface->kodi_gui->window->set_property_bool(m_interface->kodiBase, m_controlHandle, key.c_str(), value); | ||
| 325 | } | ||
| 326 | //-------------------------------------------------------------------------- | ||
| 327 | |||
| 328 | //========================================================================== | ||
| 329 | /// | ||
| 330 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 331 | /// @brief Returns a window property with boolean value | ||
| 332 | /// | ||
| 333 | /// @param[in] key string - property name. | ||
| 334 | /// @return boolean value of property | ||
| 335 | /// | ||
| 336 | bool GetPropertyBool(const std::string& key) const | ||
| 337 | { | ||
| 338 | return m_interface->kodi_gui->window->get_property_bool(m_interface->kodiBase, m_controlHandle, key.c_str()); | ||
| 339 | } | ||
| 340 | //-------------------------------------------------------------------------- | ||
| 341 | |||
| 342 | //========================================================================== | ||
| 343 | /// | ||
| 344 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 345 | /// @brief Sets a window property with double value | ||
| 346 | /// | ||
| 347 | /// @param[in] key string - property name. | ||
| 348 | /// @param[in] value double value to set | ||
| 349 | /// | ||
| 350 | /// | ||
| 351 | void SetPropertyDouble(const std::string& key, double value) | ||
| 352 | { | ||
| 353 | m_interface->kodi_gui->window->set_property_double(m_interface->kodiBase, m_controlHandle, key.c_str(), value); | ||
| 354 | } | ||
| 355 | //-------------------------------------------------------------------------- | ||
| 356 | |||
| 357 | //========================================================================== | ||
| 358 | /// | ||
| 359 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 360 | /// @brief Returns a window property with double value | ||
| 361 | /// | ||
| 362 | /// @param[in] key string - property name. | ||
| 363 | /// @return double value of property | ||
| 364 | /// | ||
| 365 | /// | ||
| 366 | double GetPropertyDouble(const std::string& key) const | ||
| 367 | { | ||
| 368 | return m_interface->kodi_gui->window->get_property_double(m_interface->kodiBase, m_controlHandle, key.c_str()); | ||
| 369 | } | ||
| 370 | //-------------------------------------------------------------------------- | ||
| 371 | |||
| 372 | //========================================================================== | ||
| 373 | /// | ||
| 374 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 375 | /// @brief Remove all present properties from window | ||
| 376 | /// | ||
| 377 | /// | ||
| 378 | /// | ||
| 379 | void ClearProperties() | ||
| 380 | { | ||
| 381 | m_interface->kodi_gui->window->clear_properties(m_interface->kodiBase, m_controlHandle); | ||
| 382 | } | ||
| 383 | //-------------------------------------------------------------------------- | ||
| 384 | |||
| 385 | //========================================================================== | ||
| 386 | /// | ||
| 387 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 388 | /// @brief Clears the specific window property. | ||
| 389 | /// | ||
| 390 | /// @param[in] key string - property name. | ||
| 391 | /// | ||
| 392 | /// @note Key is NOT case sensitive. Equivalent to SetProperty(key, "") | ||
| 393 | /// You can use the above as keywords for arguments and skip certain | ||
| 394 | /// optional arguments. | ||
| 395 | /// Once you use a keyword, all following arguments require the | ||
| 396 | /// keyword. | ||
| 397 | /// | ||
| 398 | /// | ||
| 399 | ///----------------------------------------------------------------------- | ||
| 400 | /// | ||
| 401 | /// **Example:** | ||
| 402 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 403 | /// .. | ||
| 404 | /// ClearProperty('Category') | ||
| 405 | /// .. | ||
| 406 | /// ~~~~~~~~~~~~~ | ||
| 407 | /// | ||
| 408 | void ClearProperty(const std::string& key) | ||
| 409 | { | ||
| 410 | m_interface->kodi_gui->window->clear_property(m_interface->kodiBase, m_controlHandle, key.c_str()); | ||
| 411 | } | ||
| 412 | //-------------------------------------------------------------------------- | ||
| 413 | |||
| 414 | //@{ | ||
| 415 | //========================================================================== | ||
| 416 | /// | ||
| 417 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 418 | /// @brief Function delete all entries in integrated list. | ||
| 419 | /// | ||
| 420 | /// | ||
| 421 | /// | ||
| 422 | void ClearList() | ||
| 423 | { | ||
| 424 | m_interface->kodi_gui->window->clear_item_list(m_interface->kodiBase, m_controlHandle); | ||
| 425 | } | ||
| 426 | //-------------------------------------------------------------------------- | ||
| 427 | |||
| 428 | //========================================================================== | ||
| 429 | /// | ||
| 430 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 431 | /// @brief To add a list item in the on window integrated list. | ||
| 432 | /// | ||
| 433 | /// @param[in] item List item to add | ||
| 434 | /// @param[in] itemPosition [opt] The position for item, default is on end | ||
| 435 | /// | ||
| 436 | /// | ||
| 437 | void AddListItem(ListItemPtr item, int itemPosition = -1) | ||
| 438 | { | ||
| 439 | m_interface->kodi_gui->window->add_list_item(m_interface->kodiBase, m_controlHandle, item->m_controlHandle, itemPosition); | ||
| 440 | } | ||
| 441 | //-------------------------------------------------------------------------- | ||
| 442 | |||
| 443 | //========================================================================== | ||
| 444 | /// | ||
| 445 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 446 | /// @brief To add a list item based upon string in the on window integrated list. | ||
| 447 | /// | ||
| 448 | /// @param[in] item List item to add | ||
| 449 | /// @param[in] itemPosition [opt] The position for item, default is on end | ||
| 450 | /// | ||
| 451 | /// | ||
| 452 | void AddListItem(const std::string item, int itemPosition = -1) | ||
| 453 | { | ||
| 454 | m_interface->kodi_gui->window->add_list_item(m_interface->kodiBase, m_controlHandle, std::make_shared<kodi::gui::CListItem>(item)->m_controlHandle, itemPosition); | ||
| 455 | } | ||
| 456 | //-------------------------------------------------------------------------- | ||
| 457 | |||
| 458 | //========================================================================== | ||
| 459 | /// | ||
| 460 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 461 | /// @brief Remove list item on position. | ||
| 462 | /// | ||
| 463 | /// @param[in] itemPosition List position to remove | ||
| 464 | /// | ||
| 465 | /// | ||
| 466 | void RemoveListItem(int itemPosition) | ||
| 467 | { | ||
| 468 | m_interface->kodi_gui->window->remove_list_item_from_position(m_interface->kodiBase, m_controlHandle, itemPosition); | ||
| 469 | } | ||
| 470 | //-------------------------------------------------------------------------- | ||
| 471 | |||
| 472 | //========================================================================== | ||
| 473 | /// | ||
| 474 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 475 | /// @brief Remove item with given control class from list. | ||
| 476 | /// | ||
| 477 | /// @param[in] item List item control class to remove | ||
| 478 | /// | ||
| 479 | /// | ||
| 480 | void RemoveListItem(ListItemPtr item) | ||
| 481 | { | ||
| 482 | m_interface->kodi_gui->window->remove_list_item(m_interface->kodiBase, m_controlHandle, item->m_controlHandle); | ||
| 483 | } | ||
| 484 | //-------------------------------------------------------------------------- | ||
| 485 | |||
| 486 | //========================================================================== | ||
| 487 | /// | ||
| 488 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 489 | /// @brief To get list item control class on wanted position. | ||
| 490 | /// | ||
| 491 | /// @param[in] listPos Position from where control is needed | ||
| 492 | /// @return The list item control class or null if not found | ||
| 493 | /// | ||
| 494 | /// @warning Function returns a new generated **CListItem** class! | ||
| 495 | /// | ||
| 496 | ListItemPtr GetListItem(int listPos) | ||
| 497 | { | ||
| 498 | GUIHANDLE handle = m_interface->kodi_gui->window->get_list_item(m_interface->kodiBase, m_controlHandle, listPos); | ||
| 499 | if (!handle) | ||
| 500 | return ListItemPtr(); | ||
| 501 | |||
| 502 | return std::make_shared<kodi::gui::CListItem>(handle); | ||
| 503 | } | ||
| 504 | //-------------------------------------------------------------------------- | ||
| 505 | |||
| 506 | //========================================================================== | ||
| 507 | /// | ||
| 508 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 509 | /// @brief To set position of selected part in list. | ||
| 510 | /// | ||
| 511 | /// @param[in] listPos Position to use | ||
| 512 | /// | ||
| 513 | /// | ||
| 514 | void SetCurrentListPosition(int listPos) | ||
| 515 | { | ||
| 516 | m_interface->kodi_gui->window->set_current_list_position(m_interface->kodiBase, m_controlHandle, listPos); | ||
| 517 | } | ||
| 518 | //-------------------------------------------------------------------------- | ||
| 519 | |||
| 520 | //========================================================================== | ||
| 521 | /// | ||
| 522 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 523 | /// @brief To get current selected position in list | ||
| 524 | /// | ||
| 525 | /// @return Current list position | ||
| 526 | /// | ||
| 527 | /// | ||
| 528 | int GetCurrentListPosition() | ||
| 529 | { | ||
| 530 | return m_interface->kodi_gui->window->get_current_list_position(m_interface->kodiBase, m_controlHandle); | ||
| 531 | } | ||
| 532 | //-------------------------------------------------------------------------- | ||
| 533 | |||
| 534 | //========================================================================== | ||
| 535 | /// | ||
| 536 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 537 | /// @brief To get the amount of entries in the list. | ||
| 538 | /// | ||
| 539 | /// @return Size of in window integrated control class | ||
| 540 | /// | ||
| 541 | /// | ||
| 542 | int GetListSize() | ||
| 543 | { | ||
| 544 | return m_interface->kodi_gui->window->get_list_size(m_interface->kodiBase, m_controlHandle); | ||
| 545 | } | ||
| 546 | //-------------------------------------------------------------------------- | ||
| 547 | |||
| 548 | //========================================================================== | ||
| 549 | /// | ||
| 550 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 551 | /// @brief Sets a container property, similar to an infolabel. | ||
| 552 | /// | ||
| 553 | /// @param[in] key string - property name. | ||
| 554 | /// @param[in] value string or unicode - value of property. | ||
| 555 | /// | ||
| 556 | /// @note Key is NOT case sensitive.\n | ||
| 557 | /// You can use the above as keywords for arguments and skip certain | ||
| 558 | /// optional arguments.\n | ||
| 559 | /// Once you use a keyword, all following arguments require the keyword. | ||
| 560 | /// | ||
| 561 | /// | ||
| 562 | void SetContainerProperty(const std::string& key, const std::string& value) | ||
| 563 | { | ||
| 564 | m_interface->kodi_gui->window->set_container_property(m_interface->kodiBase, m_controlHandle, key.c_str(), value.c_str()); | ||
| 565 | } | ||
| 566 | //-------------------------------------------------------------------------- | ||
| 567 | |||
| 568 | //========================================================================== | ||
| 569 | /// | ||
| 570 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 571 | /// @brief Sets the content type of the container. | ||
| 572 | /// | ||
| 573 | /// @param[in] value string or unicode - content value. | ||
| 574 | /// | ||
| 575 | /// __Available content types__ | ||
| 576 | /// | Name | Media | | ||
| 577 | /// |:-----------:|:-----------------------------------------| | ||
| 578 | /// | actors | Videos | ||
| 579 | /// | addons | Addons, Music, Pictures, Programs, Videos | ||
| 580 | /// | albums | Music, Videos | ||
| 581 | /// | artists | Music, Videos | ||
| 582 | /// | countries | Music, Videos | ||
| 583 | /// | directors | Videos | ||
| 584 | /// | files | Music, Videos | ||
| 585 | /// | games | Games | ||
| 586 | /// | genres | Music, Videos | ||
| 587 | /// | images | Pictures | ||
| 588 | /// | mixed | Music, Videos | ||
| 589 | /// | movies | Videos | ||
| 590 | /// | Musicvideos | Music, Videos | ||
| 591 | /// | playlists | Music, Videos | ||
| 592 | /// | seasons | Videos | ||
| 593 | /// | sets | Videos | ||
| 594 | /// | songs | Music | ||
| 595 | /// | studios | Music, Videos | ||
| 596 | /// | tags | Music, Videos | ||
| 597 | /// | tvshows | Videos | ||
| 598 | /// | videos | Videos | ||
| 599 | /// | years | Music, Videos | ||
| 600 | /// | ||
| 601 | /// | ||
| 602 | void SetContainerContent(const std::string& value) | ||
| 603 | { | ||
| 604 | m_interface->kodi_gui->window->set_container_content(m_interface->kodiBase, m_controlHandle, value.c_str()); | ||
| 605 | } | ||
| 606 | //-------------------------------------------------------------------------- | ||
| 607 | |||
| 608 | //========================================================================== | ||
| 609 | /// | ||
| 610 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 611 | /// @brief Get the id of the currently visible container. | ||
| 612 | /// | ||
| 613 | /// @return currently visible container id | ||
| 614 | /// | ||
| 615 | /// | ||
| 616 | int GetCurrentContainerId() | ||
| 617 | { | ||
| 618 | return m_interface->kodi_gui->window->get_current_container_id(m_interface->kodiBase, m_controlHandle); | ||
| 619 | } | ||
| 620 | //-------------------------------------------------------------------------- | ||
| 621 | //@} | ||
| 622 | |||
| 623 | //========================================================================== | ||
| 624 | /// | ||
| 625 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 626 | /// @brief To inform Kodi that it need to render region new. | ||
| 627 | /// | ||
| 628 | /// | ||
| 629 | void MarkDirtyRegion() | ||
| 630 | { | ||
| 631 | return m_interface->kodi_gui->window->mark_dirty_region(m_interface->kodiBase, m_controlHandle); | ||
| 632 | } | ||
| 633 | //-------------------------------------------------------------------------- | ||
| 634 | |||
| 635 | //========================================================================== | ||
| 636 | // | ||
| 637 | /// @defgroup cpp_kodi_gui_CWindow_callbacks Callback functions from Kodi to add-on | ||
| 638 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 639 | //@{ | ||
| 640 | /// @brief <b>GUI window callback functions.</b> | ||
| 641 | /// | ||
| 642 | /// Functions to handle control callbacks from Kodi | ||
| 643 | /// | ||
| 644 | /// ------------------------------------------------------------------------ | ||
| 645 | /// | ||
| 646 | /// @link cpp_kodi_gui_CWindow Go back to normal functions from CWindow@endlink | ||
| 647 | // | ||
| 648 | |||
| 649 | //========================================================================== | ||
| 650 | /// | ||
| 651 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 652 | /// @brief OnInit method. | ||
| 653 | /// | ||
| 654 | /// @return Return true if initialize was done successful | ||
| 655 | /// | ||
| 656 | /// | ||
| 657 | virtual bool OnInit() { return false; } | ||
| 658 | //-------------------------------------------------------------------------- | ||
| 659 | |||
| 660 | //========================================================================== | ||
| 661 | /// | ||
| 662 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 663 | /// @brief OnFocus method. | ||
| 664 | /// | ||
| 665 | /// @param[in] controlId GUI control identifier | ||
| 666 | /// @return Return true if focus condition was handled there or false to handle them by Kodi itself | ||
| 667 | /// | ||
| 668 | /// | ||
| 669 | virtual bool OnFocus(int controlId) { return false; } | ||
| 670 | //-------------------------------------------------------------------------- | ||
| 671 | |||
| 672 | //========================================================================== | ||
| 673 | /// | ||
| 674 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 675 | /// @brief OnClick method. | ||
| 676 | /// | ||
| 677 | /// @param[in] controlId GUI control identifier | ||
| 678 | /// @return Return true if click was handled there | ||
| 679 | /// or false to handle them by Kodi itself | ||
| 680 | /// | ||
| 681 | /// | ||
| 682 | virtual bool OnClick(int controlId) { return false; } | ||
| 683 | //-------------------------------------------------------------------------- | ||
| 684 | |||
| 685 | //========================================================================== | ||
| 686 | /// | ||
| 687 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 688 | /// @brief OnAction method. | ||
| 689 | /// | ||
| 690 | /// @param[in] actionId The action id to perform, see | ||
| 691 | /// \ref kodi_key_action_ids to get list of | ||
| 692 | /// them | ||
| 693 | /// @return Return true if action was handled there | ||
| 694 | /// or false to handle them by Kodi itself | ||
| 695 | /// | ||
| 696 | /// | ||
| 697 | /// This method will receive all actions that the main program will send | ||
| 698 | /// to this window. | ||
| 699 | /// | ||
| 700 | /// @note | ||
| 701 | /// - By default, only the \c PREVIOUS_MENU and \c NAV_BACK actions are handled. | ||
| 702 | /// - Overwrite this method to let your code handle all actions. | ||
| 703 | /// - Don't forget to capture \c ACTION_PREVIOUS_MENU or \c ACTION_NAV_BACK, else the user can't close this window. | ||
| 704 | /// | ||
| 705 | /// | ||
| 706 | ///-------------------------------------------------------------------------- | ||
| 707 | /// | ||
| 708 | /// **Example:** | ||
| 709 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 710 | /// .. | ||
| 711 | /// /* Window used with parent / child way */ | ||
| 712 | /// bool cYOUR_CLASS::OnAction(int actionId) | ||
| 713 | /// { | ||
| 714 | /// switch (action) | ||
| 715 | /// { | ||
| 716 | /// case ACTION_PREVIOUS_MENU: | ||
| 717 | /// case ACTION_NAV_BACK: | ||
| 718 | /// printf("action recieved: previous"); | ||
| 719 | /// Close(); | ||
| 720 | /// return true; | ||
| 721 | /// case ACTION_SHOW_INFO: | ||
| 722 | /// printf("action recieved: show info"); | ||
| 723 | /// break; | ||
| 724 | /// case ACTION_STOP: | ||
| 725 | /// printf("action recieved: stop"); | ||
| 726 | /// break; | ||
| 727 | /// case ACTION_PAUSE: | ||
| 728 | /// printf("action recieved: pause"); | ||
| 729 | /// break; | ||
| 730 | /// default: | ||
| 731 | /// break; | ||
| 732 | /// } | ||
| 733 | /// return false; | ||
| 734 | /// } | ||
| 735 | /// .. | ||
| 736 | /// ~~~~~~~~~~~~~ | ||
| 737 | /// | ||
| 738 | virtual bool OnAction(int actionId, uint32_t buttoncode, wchar_t unicode) | ||
| 739 | { | ||
| 740 | switch (actionId) | ||
| 741 | { | ||
| 742 | case ACTION_PREVIOUS_MENU: | ||
| 743 | case ACTION_NAV_BACK: | ||
| 744 | Close(); | ||
| 745 | return true; | ||
| 746 | default: | ||
| 747 | break; | ||
| 748 | } | ||
| 749 | return false; | ||
| 750 | } | ||
| 751 | //-------------------------------------------------------------------------- | ||
| 752 | |||
| 753 | //========================================================================== | ||
| 754 | /// | ||
| 755 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 756 | /// @brief Get context menu buttons for list entry | ||
| 757 | /// | ||
| 758 | /// @param[in] itemNumber selected list item entry | ||
| 759 | /// @param[in] buttons list where context menus becomes added with his | ||
| 760 | /// identifier and name. | ||
| 761 | /// | ||
| 762 | virtual void GetContextButtons(int itemNumber, std::vector< std::pair<unsigned int, std::string> > &buttons) | ||
| 763 | { | ||
| 764 | } | ||
| 765 | //-------------------------------------------------------------------------- | ||
| 766 | |||
| 767 | //========================================================================== | ||
| 768 | /// | ||
| 769 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 770 | /// @brief Called after selection in context menu | ||
| 771 | /// | ||
| 772 | /// @param[in] itemNumber selected list item entry | ||
| 773 | /// @param[in] button the pressed button id | ||
| 774 | /// @return true if handled, otherwise false | ||
| 775 | /// | ||
| 776 | virtual bool OnContextButton(int itemNumber, unsigned int button) | ||
| 777 | { | ||
| 778 | return false; | ||
| 779 | } | ||
| 780 | //-------------------------------------------------------------------------- | ||
| 781 | |||
| 782 | //========================================================================== | ||
| 783 | /// | ||
| 784 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 785 | /// @brief **Set independent callbacks** | ||
| 786 | /// | ||
| 787 | /// If the class is used independent (with "new CWindow") and | ||
| 788 | /// not as parent (with "cCLASS_own : CWindow") from own must be the | ||
| 789 | /// callback from Kodi to add-on overdriven with own functions! | ||
| 790 | /// | ||
| 791 | /// @param[in] cbhdl The pointer to own handle data | ||
| 792 | /// structure / class | ||
| 793 | /// @param[in] CBOnInit Own defined window init function | ||
| 794 | /// @param[in] CBOnFocus Own defined focus function | ||
| 795 | /// @param[in] CBOnClick Own defined click function | ||
| 796 | /// @param[in] CBOnAction Own defined action function | ||
| 797 | /// @param[in] CBGetContextButtons [opt] To get context menu entries for | ||
| 798 | /// lists function | ||
| 799 | /// @param[in] CBOnContextButton [opt] Used context menu entry function | ||
| 800 | /// | ||
| 801 | /// | ||
| 802 | ///-------------------------------------------------------------------------- | ||
| 803 | /// | ||
| 804 | /// **Example:** | ||
| 805 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 806 | /// ... | ||
| 807 | /// | ||
| 808 | /// bool OnInit(GUIHANDLE cbhdl) | ||
| 809 | /// { | ||
| 810 | /// ... | ||
| 811 | /// return true; | ||
| 812 | /// } | ||
| 813 | /// | ||
| 814 | /// bool OnFocus(GUIHANDLE cbhdl, int controlId) | ||
| 815 | /// { | ||
| 816 | /// ... | ||
| 817 | /// return true; | ||
| 818 | /// } | ||
| 819 | /// | ||
| 820 | /// bool OnClick(GUIHANDLE cbhdl, int controlId) | ||
| 821 | /// { | ||
| 822 | /// ... | ||
| 823 | /// return true; | ||
| 824 | /// } | ||
| 825 | /// | ||
| 826 | /// bool OnAction(GUIHANDLE cbhdl, int actionId) | ||
| 827 | /// { | ||
| 828 | /// ... | ||
| 829 | /// return true; | ||
| 830 | /// } | ||
| 831 | /// | ||
| 832 | /// ... | ||
| 833 | /// /* Somewhere where you create the window */ | ||
| 834 | /// CWindow myWindow = new CWindow; | ||
| 835 | /// myWindow->SetIndependentCallbacks(myWindow, OnInit, OnFocus, OnClick, OnAction); | ||
| 836 | /// ... | ||
| 837 | /// ~~~~~~~~~~~~~ | ||
| 838 | /// | ||
| 839 | void SetIndependentCallbacks( | ||
| 840 | GUIHANDLE cbhdl, | ||
| 841 | bool (*CBOnInit) (GUIHANDLE cbhdl), | ||
| 842 | bool (*CBOnFocus) (GUIHANDLE cbhdl, int controlId), | ||
| 843 | bool (*CBOnClick) (GUIHANDLE cbhdl, int controlId), | ||
| 844 | bool (*CBOnAction) (GUIHANDLE cbhdl, int actionId, uint32_t buttoncode, wchar_t unicode), | ||
| 845 | void (*CBGetContextButtons) (GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) = nullptr, | ||
| 846 | bool (*CBOnContextButton) (GUIHANDLE cbhdl, int itemNumber, unsigned int button) = nullptr) | ||
| 847 | { | ||
| 848 | if (!cbhdl || | ||
| 849 | !CBOnInit || !CBOnFocus || !CBOnClick || !CBOnAction) | ||
| 850 | { | ||
| 851 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CWindow::%s called with nullptr !!!", __FUNCTION__); | ||
| 852 | return; | ||
| 853 | } | ||
| 854 | |||
| 855 | m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, cbhdl, | ||
| 856 | CBOnInit, CBOnFocus, CBOnClick, CBOnAction, | ||
| 857 | CBGetContextButtons, CBOnContextButton); | ||
| 858 | } | ||
| 859 | //-------------------------------------------------------------------------- | ||
| 860 | //@} | ||
| 861 | |||
| 862 | private: | ||
| 863 | static bool CBOnInit(GUIHANDLE cbhdl) | ||
| 864 | { | ||
| 865 | return static_cast<CWindow*>(cbhdl)->OnInit(); | ||
| 866 | } | ||
| 867 | |||
| 868 | static bool CBOnFocus(GUIHANDLE cbhdl, int controlId) | ||
| 869 | { | ||
| 870 | return static_cast<CWindow*>(cbhdl)->OnFocus(controlId); | ||
| 871 | } | ||
| 872 | |||
| 873 | static bool CBOnClick(GUIHANDLE cbhdl, int controlId) | ||
| 874 | { | ||
| 875 | return static_cast<CWindow*>(cbhdl)->OnClick(controlId); | ||
| 876 | } | ||
| 877 | |||
| 878 | static bool CBOnAction(GUIHANDLE cbhdl, int actionId, uint32_t buttoncode, wchar_t unicode) | ||
| 879 | { | ||
| 880 | return static_cast<CWindow*>(cbhdl)->OnAction(actionId, buttoncode, unicode); | ||
| 881 | } | ||
| 882 | |||
| 883 | static void CBGetContextButtons(GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) | ||
| 884 | { | ||
| 885 | std::vector< std::pair<unsigned int, std::string> > buttonList; | ||
| 886 | static_cast<CWindow*>(cbhdl)->GetContextButtons(itemNumber, buttonList); | ||
| 887 | if (!buttonList.empty()) | ||
| 888 | { | ||
| 889 | unsigned int presentSize = static_cast<unsigned int>(buttonList.size()); | ||
| 890 | if (presentSize > *size) | ||
| 891 | kodi::Log(ADDON_LOG_WARNING, "GetContextButtons: More as allowed '%i' entries present!", *size); | ||
| 892 | else | ||
| 893 | *size = presentSize; | ||
| 894 | for (unsigned int i = 0; i < *size; ++i) | ||
| 895 | { | ||
| 896 | buttons[i].id = buttonList[i].first; | ||
| 897 | strncpy(buttons[i].name, buttonList[i].second.c_str(), ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH); | ||
| 898 | } | ||
| 899 | } | ||
| 900 | } | ||
| 901 | |||
| 902 | static bool CBOnContextButton(GUIHANDLE cbhdl, int itemNumber, unsigned int button) | ||
| 903 | { | ||
| 904 | return static_cast<CWindow*>(cbhdl)->OnContextButton(itemNumber, button); | ||
| 905 | } | ||
| 906 | }; | ||
| 907 | |||
| 908 | } /* namespace gui */ | ||
| 909 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h deleted file mode 100644 index 7cc9b24..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h +++ /dev/null | |||
| @@ -1,205 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../AddonBase.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | #include "../renderHelper.h" | ||
| 14 | |||
| 15 | namespace kodi | ||
| 16 | { | ||
| 17 | namespace gui | ||
| 18 | { | ||
| 19 | namespace controls | ||
| 20 | { | ||
| 21 | |||
| 22 | //============================================================================ | ||
| 23 | /// | ||
| 24 | /// \defgroup cpp_kodi_gui_controls_CRendering Control Rendering | ||
| 25 | /// \ingroup cpp_kodi_gui | ||
| 26 | /// @brief \cpp_class{ kodi::gui::controls::CRendering } | ||
| 27 | /// **Window control for rendering own parts** | ||
| 28 | /// | ||
| 29 | /// This rendering control is used when own parts are needed. You have the | ||
| 30 | /// control over them to render direct OpenGL or DirectX content to the | ||
| 31 | /// screen set by the size of them. | ||
| 32 | /// | ||
| 33 | /// Alternative can be the virtual functions from t his been ignored if the | ||
| 34 | /// callbacks are defined by the \ref CRendering_SetIndependentCallbacks function and | ||
| 35 | /// class is used as single and not as a parent class. | ||
| 36 | /// | ||
| 37 | /// It has the header \ref Rendering.h "#include <kodi/gui/controls/Rendering.h>" | ||
| 38 | /// be included to enjoy it. | ||
| 39 | /// | ||
| 40 | /// Here you find the needed skin part for a \ref Addon_Rendering_control "rendering control" | ||
| 41 | /// | ||
| 42 | /// @note The call of the control is only possible from the corresponding | ||
| 43 | /// window as its class and identification number is required. | ||
| 44 | /// | ||
| 45 | |||
| 46 | //============================================================================ | ||
| 47 | /// | ||
| 48 | /// \defgroup cpp_kodi_gui_controls_CRendering_Defs Definitions, structures and enumerators | ||
| 49 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 50 | /// @brief **Library definition values** | ||
| 51 | /// | ||
| 52 | |||
| 53 | class ATTRIBUTE_HIDDEN CRendering : public CAddonGUIControlBase | ||
| 54 | { | ||
| 55 | public: | ||
| 56 | //========================================================================== | ||
| 57 | /// | ||
| 58 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 59 | /// @brief Construct a new control | ||
| 60 | /// | ||
| 61 | /// @param[in] window related window control class | ||
| 62 | /// @param[in] controlId Used skin xml control id | ||
| 63 | /// | ||
| 64 | CRendering(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 65 | { | ||
| 66 | m_controlHandle = m_interface->kodi_gui->window->get_control_render_addon( | ||
| 67 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 68 | if (m_controlHandle) | ||
| 69 | m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, | ||
| 70 | m_controlHandle, this, OnCreateCB, | ||
| 71 | OnRenderCB, OnStopCB, OnDirtyCB); | ||
| 72 | else | ||
| 73 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::%s can't create control class from Kodi !!!", | ||
| 74 | __FUNCTION__); | ||
| 75 | } | ||
| 76 | //-------------------------------------------------------------------------- | ||
| 77 | |||
| 78 | //========================================================================== | ||
| 79 | /// | ||
| 80 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 81 | /// @brief Destructor | ||
| 82 | /// | ||
| 83 | ~CRendering() override | ||
| 84 | { | ||
| 85 | m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 86 | } | ||
| 87 | //-------------------------------------------------------------------------- | ||
| 88 | |||
| 89 | //========================================================================== | ||
| 90 | /// | ||
| 91 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 92 | /// @brief To create rendering control on Add-on | ||
| 93 | /// | ||
| 94 | /// Function creates the needed rendering control for Kodi which becomes | ||
| 95 | /// handled and processed from Add-on | ||
| 96 | /// | ||
| 97 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 98 | /// for calls from add-on to this function. | ||
| 99 | /// | ||
| 100 | /// @param[in] x Horizontal position | ||
| 101 | /// @param[in] y Vertical position | ||
| 102 | /// @param[in] w Width of control | ||
| 103 | /// @param[in] h Height of control | ||
| 104 | /// @param[in] device The device to use. For OpenGL is empty | ||
| 105 | /// on Direct X is the needed device send. | ||
| 106 | /// @return Add-on needs to return true if successed, | ||
| 107 | /// otherwise false. | ||
| 108 | /// | ||
| 109 | virtual bool Create(int x, int y, int w, int h, void* device) { return false; } | ||
| 110 | //-------------------------------------------------------------------------- | ||
| 111 | |||
| 112 | //========================================================================== | ||
| 113 | /// | ||
| 114 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 115 | /// @brief Render process call from Kodi | ||
| 116 | /// | ||
| 117 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 118 | /// for calls from add-on to this function. | ||
| 119 | /// | ||
| 120 | virtual void Render() {} | ||
| 121 | //-------------------------------------------------------------------------- | ||
| 122 | |||
| 123 | //========================================================================== | ||
| 124 | /// | ||
| 125 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 126 | /// @brief Call from Kodi to stop rendering process | ||
| 127 | /// | ||
| 128 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 129 | /// for calls from add-on to this function. | ||
| 130 | /// | ||
| 131 | virtual void Stop() {} | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 137 | /// @brief Call from Kodi where add-on becomes asked about dirty rendering | ||
| 138 | /// region. | ||
| 139 | /// | ||
| 140 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 141 | /// for calls from add-on to this function. | ||
| 142 | /// | ||
| 143 | virtual bool Dirty() { return false; } | ||
| 144 | //-------------------------------------------------------------------------- | ||
| 145 | |||
| 146 | //========================================================================== | ||
| 147 | /// | ||
| 148 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 149 | /// \anchor CRendering_SetIndependentCallbacks | ||
| 150 | /// @brief If the class is used independent (with "new CRendering") | ||
| 151 | /// and not as parent (with "cCLASS_own : CRendering") from own must | ||
| 152 | /// be the callback from Kodi to add-on overdriven with own functions! | ||
| 153 | /// | ||
| 154 | void SetIndependentCallbacks( | ||
| 155 | GUIHANDLE cbhdl, | ||
| 156 | bool (*CBCreate)(GUIHANDLE cbhdl, int x, int y, int w, int h, void* device), | ||
| 157 | void (*CBRender)(GUIHANDLE cbhdl), | ||
| 158 | void (*CBStop)(GUIHANDLE cbhdl), | ||
| 159 | bool (*CBDirty)(GUIHANDLE cbhdl)) | ||
| 160 | { | ||
| 161 | if (!cbhdl || !CBCreate || !CBRender || !CBStop || !CBDirty) | ||
| 162 | { | ||
| 163 | kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__); | ||
| 164 | return; | ||
| 165 | } | ||
| 166 | |||
| 167 | m_interface->kodi_gui->control_rendering->set_callbacks( | ||
| 168 | m_interface->kodiBase, m_controlHandle, cbhdl, CBCreate, CBRender, CBStop, CBDirty); | ||
| 169 | } | ||
| 170 | //-------------------------------------------------------------------------- | ||
| 171 | |||
| 172 | private: | ||
| 173 | /* | ||
| 174 | * Defined callback functions from Kodi to add-on, for use in parent / child system | ||
| 175 | * (is private)! | ||
| 176 | */ | ||
| 177 | static bool OnCreateCB(void* cbhdl, int x, int y, int w, int h, void* device) | ||
| 178 | { | ||
| 179 | static_cast<CRendering*>(cbhdl)->m_renderHelper = kodi::gui::GetRenderHelper(); | ||
| 180 | return static_cast<CRendering*>(cbhdl)->Create(x, y, w, h, device); | ||
| 181 | } | ||
| 182 | |||
| 183 | static void OnRenderCB(void* cbhdl) | ||
| 184 | { | ||
| 185 | if (!static_cast<CRendering*>(cbhdl)->m_renderHelper) | ||
| 186 | return; | ||
| 187 | static_cast<CRendering*>(cbhdl)->m_renderHelper->Begin(); | ||
| 188 | static_cast<CRendering*>(cbhdl)->Render(); | ||
| 189 | static_cast<CRendering*>(cbhdl)->m_renderHelper->End(); | ||
| 190 | } | ||
| 191 | |||
| 192 | static void OnStopCB(void* cbhdl) | ||
| 193 | { | ||
| 194 | static_cast<CRendering*>(cbhdl)->Stop(); | ||
| 195 | static_cast<CRendering*>(cbhdl)->m_renderHelper = nullptr; | ||
| 196 | } | ||
| 197 | |||
| 198 | static bool OnDirtyCB(void* cbhdl) { return static_cast<CRendering*>(cbhdl)->Dirty(); } | ||
| 199 | |||
| 200 | std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper; | ||
| 201 | }; | ||
| 202 | |||
| 203 | } /* namespace controls */ | ||
| 204 | } /* namespace gui */ | ||
| 205 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h deleted file mode 100644 index db8d491..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h +++ /dev/null | |||
| @@ -1,365 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../AddonBase.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace controls | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CSpin Control Spin | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CSpin } | ||
| 26 | /// **Window control used for cycling up/down controls** | ||
| 27 | /// | ||
| 28 | /// The settings spin control is used in the settings screens for when a list | ||
| 29 | /// of options can be chosen from using up/down arrows. You can choose the | ||
| 30 | /// position, size, and look of the spin control. It is basically a cross | ||
| 31 | /// between the button control and a spin control. It has a label and focus | ||
| 32 | /// and non focus textures, as well as a spin control on the right. | ||
| 33 | /// | ||
| 34 | /// It has the header \ref Spin.h "#include <kodi/gui/controls/Spin.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | /// Here you find the needed skin part for a \ref Spin_Control "spin control" | ||
| 38 | /// | ||
| 39 | /// @note The call of the control is only possible from the corresponding | ||
| 40 | /// window as its class and identification number is required. | ||
| 41 | /// | ||
| 42 | |||
| 43 | |||
| 44 | //============================================================================ | ||
| 45 | /// | ||
| 46 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 47 | /// @anchor AddonGUISpinControlType | ||
| 48 | /// @brief The values here defines the used value format for steps on | ||
| 49 | /// spin control. | ||
| 50 | /// | ||
| 51 | typedef enum AddonGUISpinControlType | ||
| 52 | { | ||
| 53 | /// One spin step interpreted as integer | ||
| 54 | ADDON_SPIN_CONTROL_TYPE_INT = 1, | ||
| 55 | /// One spin step interpreted as floating point value | ||
| 56 | ADDON_SPIN_CONTROL_TYPE_FLOAT = 2, | ||
| 57 | /// One spin step interpreted as text string | ||
| 58 | ADDON_SPIN_CONTROL_TYPE_TEXT = 3, | ||
| 59 | /// One spin step interpreted as a page change value | ||
| 60 | ADDON_SPIN_CONTROL_TYPE_PAGE = 4 | ||
| 61 | } AddonGUISpinControlType; | ||
| 62 | //---------------------------------------------------------------------------- | ||
| 63 | |||
| 64 | class ATTRIBUTE_HIDDEN CSpin : public CAddonGUIControlBase | ||
| 65 | { | ||
| 66 | public: | ||
| 67 | //========================================================================== | ||
| 68 | /// | ||
| 69 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 70 | /// @brief Construct a new control | ||
| 71 | /// | ||
| 72 | /// @param[in] window related window control class | ||
| 73 | /// @param[in] controlId Used skin xml control id | ||
| 74 | /// | ||
| 75 | CSpin(CWindow* window, int controlId) | ||
| 76 | : CAddonGUIControlBase(window) | ||
| 77 | { | ||
| 78 | m_controlHandle = m_interface->kodi_gui->window->get_control_spin(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 79 | if (!m_controlHandle) | ||
| 80 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CSpin can't create control class from Kodi !!!"); | ||
| 81 | } | ||
| 82 | //-------------------------------------------------------------------------- | ||
| 83 | |||
| 84 | //========================================================================== | ||
| 85 | /// | ||
| 86 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 87 | /// @brief Destructor | ||
| 88 | /// | ||
| 89 | ~CSpin() override = default; | ||
| 90 | //-------------------------------------------------------------------------- | ||
| 91 | |||
| 92 | //========================================================================== | ||
| 93 | /// | ||
| 94 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 95 | /// @brief Set the control on window to visible | ||
| 96 | /// | ||
| 97 | /// @param[in] visible If true visible, otherwise hidden | ||
| 98 | /// | ||
| 99 | void SetVisible(bool visible) | ||
| 100 | { | ||
| 101 | m_interface->kodi_gui->control_spin->set_visible(m_interface->kodiBase, m_controlHandle, visible); | ||
| 102 | } | ||
| 103 | //-------------------------------------------------------------------------- | ||
| 104 | |||
| 105 | //========================================================================== | ||
| 106 | /// | ||
| 107 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 108 | /// @brief Set's the control's enabled/disabled state | ||
| 109 | /// | ||
| 110 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 111 | /// | ||
| 112 | void SetEnabled(bool enabled) | ||
| 113 | { | ||
| 114 | m_interface->kodi_gui->control_spin->set_enabled(m_interface->kodiBase, m_controlHandle, enabled); | ||
| 115 | } | ||
| 116 | //-------------------------------------------------------------------------- | ||
| 117 | |||
| 118 | //========================================================================== | ||
| 119 | /// | ||
| 120 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 121 | /// @brief To set the text string on spin control | ||
| 122 | /// | ||
| 123 | /// @param[in] text Text to show as name for spin | ||
| 124 | /// | ||
| 125 | void SetText(const std::string& text) | ||
| 126 | { | ||
| 127 | m_interface->kodi_gui->control_spin->set_text(m_interface->kodiBase, m_controlHandle, text.c_str()); | ||
| 128 | } | ||
| 129 | //-------------------------------------------------------------------------- | ||
| 130 | |||
| 131 | //========================================================================== | ||
| 132 | /// | ||
| 133 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 134 | /// @brief To reset spin control to defaults | ||
| 135 | /// | ||
| 136 | void Reset() | ||
| 137 | { | ||
| 138 | m_interface->kodi_gui->control_spin->reset(m_interface->kodiBase, m_controlHandle); | ||
| 139 | } | ||
| 140 | //-------------------------------------------------------------------------- | ||
| 141 | |||
| 142 | //========================================================================== | ||
| 143 | /// | ||
| 144 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 145 | /// @brief To set the with SpinControlType defined types of spin. | ||
| 146 | /// | ||
| 147 | /// @param[in] type The type to use | ||
| 148 | /// | ||
| 149 | /// @note See description of \ref AddonGUISpinControlType for available types. | ||
| 150 | /// | ||
| 151 | void SetType(AddonGUISpinControlType type) | ||
| 152 | { | ||
| 153 | m_interface->kodi_gui->control_spin->set_type(m_interface->kodiBase, m_controlHandle, (int)type); | ||
| 154 | } | ||
| 155 | //-------------------------------------------------------------------------- | ||
| 156 | |||
| 157 | //========================================================================== | ||
| 158 | /// | ||
| 159 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 160 | /// @brief To add a label entry in spin defined with a value as string. | ||
| 161 | /// | ||
| 162 | /// Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 163 | /// | ||
| 164 | /// @param[in] label Label string to view on skin | ||
| 165 | /// @param[in] value String value to use for selection | ||
| 166 | /// of them. | ||
| 167 | /// | ||
| 168 | void AddLabel(const std::string& label, const std::string& value) | ||
| 169 | { | ||
| 170 | m_interface->kodi_gui->control_spin->add_string_label(m_interface->kodiBase, m_controlHandle, label.c_str(), value.c_str()); | ||
| 171 | } | ||
| 172 | //-------------------------------------------------------------------------- | ||
| 173 | |||
| 174 | //========================================================================== | ||
| 175 | /// | ||
| 176 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 177 | /// @brief To add a label entry in spin defined with a value as integer. | ||
| 178 | /// | ||
| 179 | /// Format must be set to ADDON_SPIN_CONTROL_TYPE_INT to use this function. | ||
| 180 | /// | ||
| 181 | /// @param[in] label Label string to view on skin | ||
| 182 | /// @param[in] value Integer value to use for selection | ||
| 183 | /// of them. | ||
| 184 | /// | ||
| 185 | void AddLabel(const std::string& label, int value) | ||
| 186 | { | ||
| 187 | m_interface->kodi_gui->control_spin->add_int_label(m_interface->kodiBase, m_controlHandle, label.c_str(), value); | ||
| 188 | } | ||
| 189 | //-------------------------------------------------------------------------- | ||
| 190 | |||
| 191 | //========================================================================== | ||
| 192 | /// | ||
| 193 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 194 | /// @brief To change the spin to position with them string as value. | ||
| 195 | /// | ||
| 196 | /// Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 197 | /// | ||
| 198 | /// @param[in] value String value to change to | ||
| 199 | /// | ||
| 200 | void SetStringValue(const std::string& value) | ||
| 201 | { | ||
| 202 | m_interface->kodi_gui->control_spin->set_string_value(m_interface->kodiBase, m_controlHandle, value.c_str()); | ||
| 203 | } | ||
| 204 | //-------------------------------------------------------------------------- | ||
| 205 | |||
| 206 | //========================================================================== | ||
| 207 | /// | ||
| 208 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 209 | /// @brief To get the current spin control position with text string value. | ||
| 210 | /// | ||
| 211 | /// Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 212 | /// | ||
| 213 | /// @return Currently selected string value | ||
| 214 | /// | ||
| 215 | std::string GetStringValue() const | ||
| 216 | { | ||
| 217 | std::string value; | ||
| 218 | char* ret = m_interface->kodi_gui->control_spin->get_string_value(m_interface->kodiBase, m_controlHandle); | ||
| 219 | if (ret != nullptr) | ||
| 220 | { | ||
| 221 | if (std::strlen(ret)) | ||
| 222 | value = ret; | ||
| 223 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 224 | } | ||
| 225 | return value; | ||
| 226 | } | ||
| 227 | //-------------------------------------------------------------------------- | ||
| 228 | |||
| 229 | //========================================================================== | ||
| 230 | /// | ||
| 231 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 232 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | ||
| 233 | /// start and e.g. +10 is the from here defined position where it reach the | ||
| 234 | /// end. | ||
| 235 | /// | ||
| 236 | /// Ad default is the range from 0 to 100. | ||
| 237 | /// | ||
| 238 | /// @param[in] start Integer start value | ||
| 239 | /// @param[in] end Integer end value | ||
| 240 | /// | ||
| 241 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 242 | /// these different values can be not together and can, therefore, only | ||
| 243 | /// one each can be used and must be defined with \ref SetType before. | ||
| 244 | /// | ||
| 245 | void SetIntRange(int start, int end) | ||
| 246 | { | ||
| 247 | m_interface->kodi_gui->control_spin->set_int_range(m_interface->kodiBase, m_controlHandle, start, end); | ||
| 248 | } | ||
| 249 | //-------------------------------------------------------------------------- | ||
| 250 | |||
| 251 | //========================================================================== | ||
| 252 | /// | ||
| 253 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 254 | /// @brief Set the slider position with the given integer value. The Range | ||
| 255 | /// must be defined with a call from \ref SetIntRange before. | ||
| 256 | /// | ||
| 257 | /// @param[in] value Position in range to set with integer | ||
| 258 | /// | ||
| 259 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 260 | /// these different values can be not together and can, therefore, only | ||
| 261 | /// one each can be used and must be defined with \ref SetType before. | ||
| 262 | /// | ||
| 263 | void SetIntValue(int value) | ||
| 264 | { | ||
| 265 | m_interface->kodi_gui->control_spin->set_int_value(m_interface->kodiBase, m_controlHandle, value); | ||
| 266 | } | ||
| 267 | //-------------------------------------------------------------------------- | ||
| 268 | |||
| 269 | //========================================================================== | ||
| 270 | /// | ||
| 271 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 272 | /// @brief To get the current position as integer value. | ||
| 273 | /// | ||
| 274 | /// @return The position as integer | ||
| 275 | /// | ||
| 276 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 277 | /// these different values can be not together and can, therefore, only | ||
| 278 | /// one each can be used and must be defined with \ref SetType before. | ||
| 279 | /// | ||
| 280 | int GetIntValue() const | ||
| 281 | { | ||
| 282 | return m_interface->kodi_gui->control_spin->get_int_value(m_interface->kodiBase, m_controlHandle); | ||
| 283 | } | ||
| 284 | //-------------------------------------------------------------------------- | ||
| 285 | |||
| 286 | //========================================================================== | ||
| 287 | /// | ||
| 288 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 289 | /// @brief To set the the range as float of spin, e.g. -25.0 is the spin | ||
| 290 | /// start and e.g. +25.0 is the from here defined position where it reach | ||
| 291 | /// the end. | ||
| 292 | /// | ||
| 293 | /// As default is the range 0.0 to 1.0. | ||
| 294 | /// | ||
| 295 | /// The float interval is as default 0.1 and can be changed with | ||
| 296 | /// @ref SetFloatInterval. | ||
| 297 | /// | ||
| 298 | /// @param[in] start Integer start value | ||
| 299 | /// @param[in] end Integer end value | ||
| 300 | /// | ||
| 301 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 302 | /// these different values can be not together and can, therefore, only | ||
| 303 | /// one each can be used and must be defined with \ref SetType before. | ||
| 304 | /// | ||
| 305 | void SetFloatRange(float start, float end) | ||
| 306 | { | ||
| 307 | m_interface->kodi_gui->control_spin->set_float_range(m_interface->kodiBase, m_controlHandle, start, end); | ||
| 308 | } | ||
| 309 | //-------------------------------------------------------------------------- | ||
| 310 | |||
| 311 | //========================================================================== | ||
| 312 | /// | ||
| 313 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 314 | /// @brief Set the spin position with the given float value. The Range | ||
| 315 | /// can be defined with a call from \ref SetIntRange before, as default it | ||
| 316 | /// is 0.0 to 1.0. | ||
| 317 | /// | ||
| 318 | /// @param[in] value Position in range to set with float | ||
| 319 | /// | ||
| 320 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 321 | /// these different values can be not together and can, therefore, only | ||
| 322 | /// one each can be used and must be defined with \ref SetType before. | ||
| 323 | /// | ||
| 324 | void SetFloatValue(float value) | ||
| 325 | { | ||
| 326 | m_interface->kodi_gui->control_spin->set_float_value(m_interface->kodiBase, m_controlHandle, value); | ||
| 327 | } | ||
| 328 | //-------------------------------------------------------------------------- | ||
| 329 | |||
| 330 | //========================================================================== | ||
| 331 | /// | ||
| 332 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 333 | /// @brief To get the current position as float value. | ||
| 334 | /// | ||
| 335 | /// @return The position as float | ||
| 336 | /// | ||
| 337 | float GetFloatValue() const | ||
| 338 | { | ||
| 339 | return m_interface->kodi_gui->control_spin->get_float_value(m_interface->kodiBase, m_controlHandle); | ||
| 340 | } | ||
| 341 | //-------------------------------------------------------------------------- | ||
| 342 | |||
| 343 | //========================================================================== | ||
| 344 | /// | ||
| 345 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 346 | /// @brief To set the interval steps of spin, as default is it 0.1 If it | ||
| 347 | /// becomes changed with this function will a step of the user with the | ||
| 348 | /// value fixed here be executed. | ||
| 349 | /// | ||
| 350 | /// @param[in] interval Intervall step to set. | ||
| 351 | /// | ||
| 352 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 353 | /// these different values can be not together and can, therefore, only | ||
| 354 | /// one each can be used and must be defined with \ref SetType before. | ||
| 355 | /// | ||
| 356 | void SetFloatInterval(float interval) | ||
| 357 | { | ||
| 358 | m_interface->kodi_gui->control_spin->set_float_interval(m_interface->kodiBase, m_controlHandle, interval); | ||
| 359 | } | ||
| 360 | //-------------------------------------------------------------------------- | ||
| 361 | }; | ||
| 362 | |||
| 363 | } /* namespace controls */ | ||
| 364 | } /* namespace gui */ | ||
| 365 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h deleted file mode 100644 index 4eb64c7..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h +++ /dev/null | |||
| @@ -1,433 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include <string> | ||
| 12 | #include <time.h> | ||
| 13 | |||
| 14 | /* | ||
| 15 | * Internal Structures to have "C"-Style data transfer | ||
| 16 | */ | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | |||
| 20 | typedef struct AddonToKodiFuncTable_kodi_gui_general | ||
| 21 | { | ||
| 22 | void (*lock)(); | ||
| 23 | void (*unlock)(); | ||
| 24 | int (*get_screen_height)(void* kodiBase); | ||
| 25 | int (*get_screen_width)(void* kodiBase); | ||
| 26 | int (*get_video_resolution)(void* kodiBase); | ||
| 27 | int (*get_current_window_dialog_id)(void* kodiBase); | ||
| 28 | int (*get_current_window_id)(void* kodiBase); | ||
| 29 | void* (*get_hw_context)(void* kodiBase); | ||
| 30 | } AddonToKodiFuncTable_kodi_gui_general; | ||
| 31 | |||
| 32 | typedef struct AddonToKodiFuncTable_kodi_gui_control_button | ||
| 33 | { | ||
| 34 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 35 | void (*set_enabled)(void* kodiBase, void* handle, bool enabled); | ||
| 36 | void (*set_label)(void* kodiBase, void* handle, const char* label); | ||
| 37 | char* (*get_label)(void* kodiBase, void* handle); | ||
| 38 | void (*set_label2)(void* kodiBase, void* handle, const char *label); | ||
| 39 | char* (*get_label2)(void* kodiBase, void* handle); | ||
| 40 | } AddonToKodiFuncTable_kodi_gui_control_button; | ||
| 41 | |||
| 42 | typedef struct AddonToKodiFuncTable_kodi_gui_control_edit | ||
| 43 | { | ||
| 44 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 45 | void (*set_enabled)(void* kodiBase, void* handle, bool enabled); | ||
| 46 | void (*set_label)(void* kodiBase, void* handle, const char* label); | ||
| 47 | char* (*get_label)(void* kodiBase, void* handle); | ||
| 48 | void (*set_text)(void* kodiBase, void* handle, const char* text); | ||
| 49 | char* (*get_text)(void* kodiBase, void* handle); | ||
| 50 | void (*set_cursor_position)(void* kodiBase, void* handle, unsigned int position); | ||
| 51 | unsigned int (*get_cursor_position)(void* kodiBase, void* handle); | ||
| 52 | void (*set_input_type)(void* kodiBase, void* handle, int type, const char* heading); | ||
| 53 | } AddonToKodiFuncTable_kodi_gui_control_edit; | ||
| 54 | |||
| 55 | typedef struct AddonToKodiFuncTable_kodi_gui_control_fade_label | ||
| 56 | { | ||
| 57 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 58 | void (*add_label)(void* kodiBase, void* handle, const char* text); | ||
| 59 | char* (*get_label)(void* kodiBase, void* handle); | ||
| 60 | void (*set_scrolling)(void* kodiBase, void* handle, bool scroll); | ||
| 61 | void (*reset)(void* kodiBase, void* handle); | ||
| 62 | } AddonToKodiFuncTable_kodi_gui_control_fade_label; | ||
| 63 | |||
| 64 | typedef struct AddonToKodiFuncTable_kodi_gui_control_image | ||
| 65 | { | ||
| 66 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 67 | void (*set_filename)(void* kodiBase, void* handle, const char* filename, bool use_cache); | ||
| 68 | void (*set_color_diffuse)(void* kodiBase, void* handle, uint32_t color_diffuse); | ||
| 69 | } AddonToKodiFuncTable_kodi_gui_control_image; | ||
| 70 | |||
| 71 | typedef struct AddonToKodiFuncTable_kodi_gui_control_label | ||
| 72 | { | ||
| 73 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 74 | void (*set_label)(void* kodiBase, void* handle, const char* text); | ||
| 75 | char* (*get_label)(void* kodiBase, void* handle); | ||
| 76 | } AddonToKodiFuncTable_kodi_gui_control_label; | ||
| 77 | |||
| 78 | typedef struct AddonToKodiFuncTable_kodi_gui_control_progress | ||
| 79 | { | ||
| 80 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 81 | void (*set_percentage)(void* kodiBase, void* handle, float percent); | ||
| 82 | float (*get_percentage)(void* kodiBase, void* handle); | ||
| 83 | } AddonToKodiFuncTable_kodi_gui_control_progress; | ||
| 84 | |||
| 85 | typedef struct AddonToKodiFuncTable_kodi_gui_control_radio_button | ||
| 86 | { | ||
| 87 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 88 | void (*set_enabled)(void* kodiBase, void* handle, bool enabled); | ||
| 89 | void (*set_label)(void* kodiBase, void* handle, const char* text); | ||
| 90 | char* (*get_label)(void* kodiBase, void* handle); | ||
| 91 | void (*set_selected)(void* kodiBase, void* handle, bool selected); | ||
| 92 | bool (*is_selected)(void* kodiBase, void* handle); | ||
| 93 | } AddonToKodiFuncTable_kodi_gui_control_radio_button; | ||
| 94 | |||
| 95 | typedef struct AddonToKodiFuncTable_kodi_gui_control_rendering | ||
| 96 | { | ||
| 97 | void (*set_callbacks)(void* kodiBase, void* handle, void* clienthandle, | ||
| 98 | bool (*createCB)(void*,int,int,int,int,void*), | ||
| 99 | void (*renderCB)(void*), | ||
| 100 | void (*stopCB)(void*), | ||
| 101 | bool (*dirtyCB)(void*)); | ||
| 102 | void (*destroy)(void *kodiBase, void* handle); | ||
| 103 | } AddonToKodiFuncTable_kodi_gui_control_rendering; | ||
| 104 | |||
| 105 | typedef struct AddonToKodiFuncTable_kodi_gui_control_settings_slider | ||
| 106 | { | ||
| 107 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 108 | void (*set_enabled)(void* kodiBase, void* handle, bool enabled); | ||
| 109 | void (*set_text)(void* kodiBase, void* handle, const char* label); | ||
| 110 | void (*reset)(void* kodiBase, void* handle); | ||
| 111 | void (*set_int_range)(void* kodiBase, void* handle, int start, int end); | ||
| 112 | void (*set_int_value)(void* kodiBase, void* handle, int value); | ||
| 113 | int (*get_int_value)(void* kodiBase, void* handle); | ||
| 114 | void (*set_int_interval)(void* kodiBase, void* handle, int interval); | ||
| 115 | void (*set_percentage)(void* kodiBase, void* handle, float percent); | ||
| 116 | float (*get_percentage)(void* kodiBase, void* handle); | ||
| 117 | void (*set_float_range)(void* kodiBase, void* handle, float start, float end); | ||
| 118 | void (*set_float_value)(void* kodiBase, void* handle, float value); | ||
| 119 | float (*get_float_value)(void* kodiBase, void* handle); | ||
| 120 | void (*set_float_interval)(void* kodiBase, void* handle, float interval); | ||
| 121 | } AddonToKodiFuncTable_kodi_gui_control_settings_slider; | ||
| 122 | |||
| 123 | typedef struct AddonToKodiFuncTable_kodi_gui_control_slider | ||
| 124 | { | ||
| 125 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 126 | void (*set_enabled)(void* kodiBase, void* handle, bool enabled); | ||
| 127 | void (*reset)(void* kodiBase, void* handle); | ||
| 128 | char* (*get_description)(void* kodiBase, void* handle); | ||
| 129 | void (*set_int_range)(void* kodiBase, void* handle, int start, int end); | ||
| 130 | void (*set_int_value)(void* kodiBase, void* handle, int value); | ||
| 131 | int (*get_int_value)(void* kodiBase, void* handle); | ||
| 132 | void (*set_int_interval)(void* kodiBase, void* handle, int interval); | ||
| 133 | void (*set_percentage)(void* kodiBase, void* handle, float percent); | ||
| 134 | float (*get_percentage)(void* kodiBase, void* handle); | ||
| 135 | void (*set_float_range)(void* kodiBase, void* handle, float start, float end); | ||
| 136 | void (*set_float_value)(void* kodiBase, void* handle, float value); | ||
| 137 | float (*get_float_value)(void* kodiBase, void* handle); | ||
| 138 | void (*set_float_interval)(void* kodiBase, void* handle, float interval); | ||
| 139 | } AddonToKodiFuncTable_kodi_gui_control_slider; | ||
| 140 | |||
| 141 | typedef struct AddonToKodiFuncTable_kodi_gui_control_spin | ||
| 142 | { | ||
| 143 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 144 | void (*set_enabled)(void* kodiBase, void* handle, bool enabled); | ||
| 145 | void (*set_text)(void* kodiBase, void* handle, const char* text); | ||
| 146 | void (*reset)(void* kodiBase, void* handle); | ||
| 147 | void (*set_type)(void* kodiBase, void* handle, int type); | ||
| 148 | void (*add_string_label)(void* kodiBase, void* handle, const char* label, const char* value); | ||
| 149 | void (*set_string_value)(void* kodiBase, void* handle, const char* value); | ||
| 150 | char* (*get_string_value)(void* kodiBase, void* handle); | ||
| 151 | void (*add_int_label)(void* kodiBase, void* handle, const char* label, int value); | ||
| 152 | void (*set_int_range)(void* kodiBase, void* handle, int start, int end); | ||
| 153 | void (*set_int_value)(void* kodiBase, void* handle, int value); | ||
| 154 | int (*get_int_value)(void* kodiBase, void* handle); | ||
| 155 | void (*set_float_range)(void* kodiBase, void* handle, float start, float end); | ||
| 156 | void (*set_float_value)(void* kodiBase, void* handle, float value); | ||
| 157 | float (*get_float_value)(void* kodiBase, void* handle); | ||
| 158 | void (*set_float_interval)(void* kodiBase, void* handle, float interval); | ||
| 159 | } AddonToKodiFuncTable_kodi_gui_control_spin; | ||
| 160 | |||
| 161 | typedef struct AddonToKodiFuncTable_kodi_gui_control_text_box | ||
| 162 | { | ||
| 163 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 164 | void (*reset)(void* kodiBase, void* handle); | ||
| 165 | void (*set_text)(void* kodiBase, void* handle, const char* text); | ||
| 166 | char* (*get_text)(void* kodiBase, void* handle); | ||
| 167 | void (*scroll)(void* kodiBase, void* handle, unsigned int scroll); | ||
| 168 | void (*set_auto_scrolling)(void* kodiBase, void* handle, int delay, int time, int repeat); | ||
| 169 | } AddonToKodiFuncTable_kodi_gui_control_text_box; | ||
| 170 | |||
| 171 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogContextMenu | ||
| 172 | { | ||
| 173 | int (*open)(void* kodiBase, const char *heading, const char *entries[], unsigned int size); | ||
| 174 | } AddonToKodiFuncTable_kodi_gui_dialogContextMenu; | ||
| 175 | |||
| 176 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress | ||
| 177 | { | ||
| 178 | void* (*new_dialog)(void* kodiBase, const char *title); | ||
| 179 | void (*delete_dialog)(void* kodiBase, void* handle); | ||
| 180 | char* (*get_title)(void* kodiBase, void* handle); | ||
| 181 | void (*set_title)(void* kodiBase, void* handle, const char *title); | ||
| 182 | char* (*get_text)(void* kodiBase, void* handle); | ||
| 183 | void (*set_text)(void* kodiBase, void* handle, const char *text); | ||
| 184 | bool (*is_finished)(void* kodiBase, void* handle); | ||
| 185 | void (*mark_finished)(void* kodiBase, void* handle); | ||
| 186 | float (*get_percentage)(void* kodiBase, void* handle); | ||
| 187 | void (*set_percentage)(void* kodiBase, void* handle, float percentage); | ||
| 188 | void (*set_progress)(void* kodiBase, void* handle, int currentItem, int itemCount); | ||
| 189 | } AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress; | ||
| 190 | |||
| 191 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogFileBrowser | ||
| 192 | { | ||
| 193 | bool (*show_and_get_directory)(void* kodiBase, const char* shares, const char* heading, const char* path_in, char** path_out, bool writeOnly); | ||
| 194 | bool (*show_and_get_file)(void* kodiBase, const char* shares, const char* mask, const char* heading, const char* path_in, char** path_out, bool use_thumbs, bool use_file_directories); | ||
| 195 | bool (*show_and_get_file_from_dir)(void* kodiBase, const char* directory, const char* mask, const char* heading, const char* path_in, char** path_out, bool use_thumbs, bool use_file_directories, bool singleList); | ||
| 196 | bool (*show_and_get_file_list)(void* kodiBase, const char* shares, const char* mask, const char* heading, char*** file_list, unsigned int* entries, bool use_thumbs, bool use_file_directories); | ||
| 197 | bool (*show_and_get_source)(void* kodiBase, const char* path_in, char** path_out, bool allow_network_shares, const char* additional_share, const char* type); | ||
| 198 | bool (*show_and_get_image)(void* kodiBase, const char* shares, const char* heading, const char* path_in, char** path_out); | ||
| 199 | bool (*show_and_get_image_list)(void* kodiBase, const char* shares, const char* heading, char*** file_list, unsigned int* entries); | ||
| 200 | void (*clear_file_list)(void* kodiBase, char*** file_list, unsigned int entries); | ||
| 201 | } AddonToKodiFuncTable_kodi_gui_dialogFileBrowser; | ||
| 202 | |||
| 203 | // typedef void (*char_callback_t) (CGUIKeyboard *ref, const std::string &typedString); | ||
| 204 | |||
| 205 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogKeyboard | ||
| 206 | { | ||
| 207 | bool (*show_and_get_input_with_head)(void* kodiBase, const char* text_in, char** text_out, const char* heading, bool allow_empty_result, bool hiddenInput, unsigned int auto_close_ms); | ||
| 208 | bool (*show_and_get_input)(void* kodiBase, const char* text_in, char** text_out, bool allow_empty_result, unsigned int auto_close_ms); | ||
| 209 | bool (*show_and_get_new_password_with_head)(void* kodiBase, const char* password_in, char** password_out, const char* heading, bool allow_empty_result, unsigned int auto_close_ms); | ||
| 210 | bool (*show_and_get_new_password)(void* kodiBase, const char* password_in, char** password_out, unsigned int auto_close_ms); | ||
| 211 | bool (*show_and_verify_new_password_with_head)(void* kodiBase, char** password_out, const char* heading, bool allow_empty_result, unsigned int auto_close_ms); | ||
| 212 | bool (*show_and_verify_new_password)(void* kodiBase, char** password_out, unsigned int auto_close_ms); | ||
| 213 | int (*show_and_verify_password)(void* kodiBase, const char* password_in, char** password_out, const char* heading, int retries, unsigned int auto_close_ms); | ||
| 214 | bool (*show_and_get_filter)(void* kodiBase, const char* text_in, char** text_out, bool searching, unsigned int auto_close_ms); | ||
| 215 | bool (*send_text_to_active_keyboard)(void* kodiBase, const char* text, bool close_keyboard); | ||
| 216 | bool (*is_keyboard_activated)(void* kodiBase); | ||
| 217 | } AddonToKodiFuncTable_kodi_gui_dialogKeyboard; | ||
| 218 | |||
| 219 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogNumeric | ||
| 220 | { | ||
| 221 | bool (*show_and_verify_new_password)(void* kodiBase, char** password); | ||
| 222 | int (*show_and_verify_password)(void* kodiBase, const char* password, const char *heading, int retries); | ||
| 223 | bool (*show_and_verify_input)(void* kodiBase, const char* verify_in, char** verify_out, const char* heading, bool verify_input); | ||
| 224 | bool (*show_and_get_time)(void* kodiBase, tm *time, const char *heading); | ||
| 225 | bool (*show_and_get_date)(void* kodiBase, tm *date, const char *heading); | ||
| 226 | bool (*show_and_get_ip_address)(void* kodiBase, const char* ip_address_in, char** ip_address_out, const char *heading); | ||
| 227 | bool (*show_and_get_number)(void* kodiBase, const char* input_in, char** input_out, const char *heading, unsigned int auto_close_ms); | ||
| 228 | bool (*show_and_get_seconds)(void* kodiBase, const char* time_in, char** time_out, const char *heading); | ||
| 229 | } AddonToKodiFuncTable_kodi_gui_dialogNumeric; | ||
| 230 | |||
| 231 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogOK | ||
| 232 | { | ||
| 233 | void (*show_and_get_input_single_text)(void* kodiBase, const char *heading, const char *text); | ||
| 234 | void (*show_and_get_input_line_text)(void* kodiBase, const char *heading, const char *line0, const char *line1, const char *line2); | ||
| 235 | } AddonToKodiFuncTable_kodi_gui_dialogOK; | ||
| 236 | |||
| 237 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogProgress | ||
| 238 | { | ||
| 239 | void* (*new_dialog)(void* kodiBase); | ||
| 240 | void (*delete_dialog)(void* kodiBase, void* handle); | ||
| 241 | void (*open)(void* kodiBase, void* handle); | ||
| 242 | void (*set_heading)(void* kodiBase, void* handle, const char* heading); | ||
| 243 | void (*set_line)(void* kodiBase, void* handle, unsigned int lineNo, const char* line); | ||
| 244 | void (*set_can_cancel)(void* kodiBase, void* handle, bool canCancel); | ||
| 245 | bool (*is_canceled)(void* kodiBase, void* handle); | ||
| 246 | void (*set_percentage)(void* kodiBase, void* handle, int percentage); | ||
| 247 | int (*get_percentage)(void* kodiBase, void* handle); | ||
| 248 | void (*show_progress_bar)(void* kodiBase, void* handle, bool pnOff); | ||
| 249 | void (*set_progress_max)(void* kodiBase, void* handle, int max); | ||
| 250 | void (*set_progress_advance)(void* kodiBase, void* handle, int nSteps); | ||
| 251 | bool (*abort)(void* kodiBase, void* handle); | ||
| 252 | } AddonToKodiFuncTable_kodi_gui_dialogProgress; | ||
| 253 | |||
| 254 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogSelect | ||
| 255 | { | ||
| 256 | int (*open)(void* kodiBase, const char *heading, const char *entries[], unsigned int size, int selected, unsigned int autoclose); | ||
| 257 | bool (*open_multi_select)(void* kodiBase, const char* heading, const char* entryIDs[], const char* entryNames[], | ||
| 258 | bool entriesSelected[], unsigned int size, unsigned int autoclose); | ||
| 259 | } AddonToKodiFuncTable_kodi_gui_dialogSelect; | ||
| 260 | |||
| 261 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogTextViewer | ||
| 262 | { | ||
| 263 | void (*open)(void* kodiBase, const char *heading, const char *text); | ||
| 264 | } AddonToKodiFuncTable_kodi_gui_dialogTextViewer; | ||
| 265 | |||
| 266 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogYesNo | ||
| 267 | { | ||
| 268 | bool (*show_and_get_input_single_text)(void* kodiBase, const char *heading, const char *text, bool *canceled, const char *noLabel, const char *yesLabel); | ||
| 269 | bool (*show_and_get_input_line_text)(void* kodiBase, const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel); | ||
| 270 | bool (*show_and_get_input_line_button_text)(void* kodiBase, const char *heading, const char *line0, const char *line1, const char *line2, bool *canceled, const char *noLabel, const char *yesLabel); | ||
| 271 | } AddonToKodiFuncTable_kodi_gui_dialogYesNo; | ||
| 272 | |||
| 273 | typedef struct AddonToKodiFuncTable_kodi_gui_listItem | ||
| 274 | { | ||
| 275 | void* (*create)(void* kodiBase, const char* label, const char* label2, const char* icon_image, const char* path); | ||
| 276 | void (*destroy)(void* kodiBase, void* handle); | ||
| 277 | char* (*get_label)(void* kodiBase, void* handle); | ||
| 278 | void (*set_label)(void* kodiBase, void* handle, const char* label); | ||
| 279 | char* (*get_label2)(void* kodiBase, void* handle); | ||
| 280 | void (*set_label2)(void* kodiBase, void* handle, const char* label); | ||
| 281 | char* (*get_art)(void* kodiBase, void* handle, const char* type); | ||
| 282 | void (*set_art)(void* kodiBase, void* handle, const char* type, const char* image); | ||
| 283 | char* (*get_path)(void* kodiBase, void* handle); | ||
| 284 | void (*set_path)(void* kodiBase, void* handle, const char* path); | ||
| 285 | char* (*get_property)(void* kodiBase, void* handle, const char* key); | ||
| 286 | void (*set_property)(void* kodiBase, void* handle, const char* key, const char* value); | ||
| 287 | void (*select)(void* kodiBase, void* handle, bool select); | ||
| 288 | bool (*is_selected)(void* kodiBase, void* handle); | ||
| 289 | } AddonToKodiFuncTable_kodi_gui_listItem; | ||
| 290 | |||
| 291 | #define ADDON_MAX_CONTEXT_ENTRIES 20 | ||
| 292 | #define ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH 80 | ||
| 293 | typedef struct gui_context_menu_pair | ||
| 294 | { | ||
| 295 | unsigned int id; | ||
| 296 | char name[ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH]; | ||
| 297 | } gui_context_menu_pair; | ||
| 298 | |||
| 299 | typedef struct AddonToKodiFuncTable_kodi_gui_window | ||
| 300 | { | ||
| 301 | /* Window creation functions */ | ||
| 302 | void* (*create)(void* kodiBase, const char* xml_filename, const char* default_skin, bool as_dialog, bool is_media); | ||
| 303 | void (*destroy)(void* kodiBase, void* handle); | ||
| 304 | void (*set_callbacks)(void* kodiBase, void* handle, void* clienthandle, | ||
| 305 | bool (*CBInit)(void*), | ||
| 306 | bool (*CBFocus)(void*, int), | ||
| 307 | bool (*CBClick)(void*, int), | ||
| 308 | bool (*CBOnAction)(void*, int, uint32_t, wchar_t), | ||
| 309 | void (*CBGetContextButtons)(void*, int, gui_context_menu_pair*, unsigned int*), | ||
| 310 | bool (*CBOnContextButton)(void*, int, unsigned int)); | ||
| 311 | bool (*show)(void* kodiBase, void* handle); | ||
| 312 | bool (*close)(void* kodiBase, void* handle); | ||
| 313 | bool (*do_modal)(void* kodiBase, void* handle); | ||
| 314 | |||
| 315 | /* Window control functions */ | ||
| 316 | bool (*set_focus_id)(void* kodiBase, void* handle, int control_id); | ||
| 317 | int (*get_focus_id)(void* kodiBase, void* handle); | ||
| 318 | void (*set_control_label)(void* kodiBase, void* handle, int control_id, const char* label); | ||
| 319 | void (*set_control_visible)(void* kodiBase, void* handle, int control_id, bool visible); | ||
| 320 | void (*set_control_selected)(void* kodiBase, void* handle, int control_id, bool selected); | ||
| 321 | |||
| 322 | /* Window property functions */ | ||
| 323 | void (*set_property)(void* kodiBase, void* handle, const char* key, const char* value); | ||
| 324 | void (*set_property_int)(void* kodiBase, void* handle, const char* key, int value); | ||
| 325 | void (*set_property_bool)(void* kodiBase, void* handle, const char* key, bool value); | ||
| 326 | void (*set_property_double)(void* kodiBase, void* handle, const char* key, double value); | ||
| 327 | char* (*get_property)(void* kodiBase, void* handle, const char* key); | ||
| 328 | int (*get_property_int)(void* kodiBase, void* handle, const char* key); | ||
| 329 | bool (*get_property_bool)(void* kodiBase, void* handle, const char* key); | ||
| 330 | double (*get_property_double)(void* kodiBase, void* handle, const char* key); | ||
| 331 | void (*clear_properties)(void* kodiBase, void* handle); | ||
| 332 | void (*clear_property)(void* kodiBase, void* handle, const char* key); | ||
| 333 | |||
| 334 | /* List item functions */ | ||
| 335 | void (*clear_item_list)(void* kodiBase, void* handle); | ||
| 336 | void (*add_list_item)(void* kodiBase, void* handle, void* item, int list_position); | ||
| 337 | void (*remove_list_item_from_position)(void* kodiBase, void* handle, int list_position); | ||
| 338 | void (*remove_list_item)(void* kodiBase, void* handle, void* item); | ||
| 339 | void* (*get_list_item)(void* kodiBase, void* handle, int list_position); | ||
| 340 | void (*set_current_list_position)(void* kodiBase, void* handle, int list_position); | ||
| 341 | int (*get_current_list_position)(void* kodiBase, void* handle); | ||
| 342 | int (*get_list_size)(void* kodiBase, void* handle); | ||
| 343 | void (*set_container_property)(void* kodiBase, void* handle, const char* key, const char* value); | ||
| 344 | void (*set_container_content)(void* kodiBase, void* handle, const char* value); | ||
| 345 | int (*get_current_container_id)(void* kodiBase, void* handle); | ||
| 346 | |||
| 347 | /* Various functions */ | ||
| 348 | void (*mark_dirty_region)(void* kodiBase, void* handle); | ||
| 349 | |||
| 350 | /* GUI control access functions */ | ||
| 351 | void* (*get_control_button)(void* kodiBase, void* handle, int control_id); | ||
| 352 | void* (*get_control_edit)(void* kodiBase, void* handle, int control_id); | ||
| 353 | void* (*get_control_fade_label)(void* kodiBase, void* handle, int control_id); | ||
| 354 | void* (*get_control_image)(void* kodiBase, void* handle, int control_id); | ||
| 355 | void* (*get_control_label)(void* kodiBase, void* handle, int control_id); | ||
| 356 | void* (*get_control_progress)(void* kodiBase, void* handle, int control_id); | ||
| 357 | void* (*get_control_radio_button)(void* kodiBase, void* handle, int control_id); | ||
| 358 | void* (*get_control_render_addon)(void* kodiBase, void* handle, int control_id); | ||
| 359 | void* (*get_control_settings_slider)(void* kodiBase, void* handle, int control_id); | ||
| 360 | void* (*get_control_slider)(void* kodiBase, void* handle, int control_id); | ||
| 361 | void* (*get_control_spin)(void* kodiBase, void* handle, int control_id); | ||
| 362 | void* (*get_control_text_box)(void* kodiBase, void* handle, int control_id); | ||
| 363 | void* (*get_control_dummy1)(void* kodiBase, void* handle, int control_id); | ||
| 364 | void* (*get_control_dummy2)(void* kodiBase, void* handle, int control_id); | ||
| 365 | void* (*get_control_dummy3)(void* kodiBase, void* handle, int control_id); | ||
| 366 | void* (*get_control_dummy4)(void* kodiBase, void* handle, int control_id); | ||
| 367 | void* (*get_control_dummy5)(void* kodiBase, void* handle, int control_id); | ||
| 368 | void* (*get_control_dummy6)(void* kodiBase, void* handle, int control_id); | ||
| 369 | void* (*get_control_dummy7)(void* kodiBase, void* handle, int control_id); | ||
| 370 | void* (*get_control_dummy8)(void* kodiBase, void* handle, int control_id); | ||
| 371 | void* (*get_control_dummy9)(void* kodiBase, void* handle, int control_id); | ||
| 372 | void* (*get_control_dummy10)(void* kodiBase, void* handle, int control_id); /* This and above used to add new get_control_* functions */ | ||
| 373 | } AddonToKodiFuncTable_kodi_gui_window; | ||
| 374 | |||
| 375 | typedef struct AddonToKodiFuncTable_kodi_gui | ||
| 376 | { | ||
| 377 | AddonToKodiFuncTable_kodi_gui_general* general; | ||
| 378 | AddonToKodiFuncTable_kodi_gui_control_button* control_button; | ||
| 379 | AddonToKodiFuncTable_kodi_gui_control_edit* control_edit; | ||
| 380 | AddonToKodiFuncTable_kodi_gui_control_fade_label* control_fade_label; | ||
| 381 | AddonToKodiFuncTable_kodi_gui_control_label* control_label; | ||
| 382 | AddonToKodiFuncTable_kodi_gui_control_image* control_image; | ||
| 383 | AddonToKodiFuncTable_kodi_gui_control_progress* control_progress; | ||
| 384 | AddonToKodiFuncTable_kodi_gui_control_radio_button* control_radio_button; | ||
| 385 | AddonToKodiFuncTable_kodi_gui_control_rendering* control_rendering; | ||
| 386 | AddonToKodiFuncTable_kodi_gui_control_settings_slider* control_settings_slider; | ||
| 387 | AddonToKodiFuncTable_kodi_gui_control_slider* control_slider; | ||
| 388 | AddonToKodiFuncTable_kodi_gui_control_spin* control_spin; | ||
| 389 | AddonToKodiFuncTable_kodi_gui_control_text_box* control_text_box; | ||
| 390 | void* control_dummy1; | ||
| 391 | void* control_dummy2; | ||
| 392 | void* control_dummy3; | ||
| 393 | void* control_dummy4; | ||
| 394 | void* control_dummy5; | ||
| 395 | void* control_dummy6; | ||
| 396 | void* control_dummy7; | ||
| 397 | void* control_dummy8; | ||
| 398 | void* control_dummy9; | ||
| 399 | void* control_dummy10; /* This and above used to add new controls */ | ||
| 400 | AddonToKodiFuncTable_kodi_gui_dialogContextMenu* dialogContextMenu; | ||
| 401 | AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress* dialogExtendedProgress; | ||
| 402 | AddonToKodiFuncTable_kodi_gui_dialogFileBrowser* dialogFileBrowser; | ||
| 403 | AddonToKodiFuncTable_kodi_gui_dialogKeyboard* dialogKeyboard; | ||
| 404 | AddonToKodiFuncTable_kodi_gui_dialogNumeric* dialogNumeric; | ||
| 405 | AddonToKodiFuncTable_kodi_gui_dialogOK* dialogOK; | ||
| 406 | AddonToKodiFuncTable_kodi_gui_dialogProgress* dialogProgress; | ||
| 407 | AddonToKodiFuncTable_kodi_gui_dialogSelect* dialogSelect; | ||
| 408 | AddonToKodiFuncTable_kodi_gui_dialogTextViewer* dialogTextViewer; | ||
| 409 | AddonToKodiFuncTable_kodi_gui_dialogYesNo* dialogYesNo; | ||
| 410 | void* dialog_dummy1; | ||
| 411 | void* dialog_dummy2; | ||
| 412 | void* dialog_dummy3; | ||
| 413 | void* dialog_dummy4; | ||
| 414 | void* dialog_dummy5; | ||
| 415 | void* dialog_dummy6; | ||
| 416 | void* dialog_dummy7; | ||
| 417 | void* dialog_dummy8; | ||
| 418 | void* dialog_dummy9; | ||
| 419 | void* dialog_dummy10; /* This and above used to add new dialogs */ | ||
| 420 | AddonToKodiFuncTable_kodi_gui_listItem* listItem; | ||
| 421 | AddonToKodiFuncTable_kodi_gui_window* window; | ||
| 422 | } AddonToKodiFuncTable_kodi_gui; | ||
| 423 | |||
| 424 | } /* extern "C" */ | ||
| 425 | |||
| 426 | //============================================================================ | ||
| 427 | /// | ||
| 428 | /// \ingroup cpp_kodi_gui_CControlRendering_Defs cpp_kodi_gui_CWindow_Defs | ||
| 429 | /// @{ | ||
| 430 | /// @brief Handle to use as independent pointer for GUI | ||
| 431 | typedef void* GUIHANDLE; | ||
| 432 | /// @} | ||
| 433 | //---------------------------------------------------------------------------- | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h deleted file mode 100644 index d545030..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h +++ /dev/null | |||
| @@ -1,185 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_ContextMenu Dialog Context Menu | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_namespace{ kodi::gui::dialogs::ContextMenu } | ||
| 26 | /// **Context menu dialog** | ||
| 27 | /// | ||
| 28 | /// The function listed below permits the call of a dialogue as context menu to | ||
| 29 | /// select of an entry as a key | ||
| 30 | /// | ||
| 31 | /// It has the header \ref ContextMenu.h "#include <kodi/gui/dialogs/ContextMenu.h>" | ||
| 32 | /// be included to enjoy it. | ||
| 33 | /// | ||
| 34 | /// | ||
| 35 | namespace ContextMenu | ||
| 36 | { | ||
| 37 | //========================================================================== | ||
| 38 | /// | ||
| 39 | /// \ingroup cpp_kodi_gui_dialogs_ContextMenu | ||
| 40 | /// @brief Show a context menu dialog about given parts. | ||
| 41 | /// | ||
| 42 | /// @param[in] heading Dialog heading name | ||
| 43 | /// @param[in] entries String list about entries | ||
| 44 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled | ||
| 45 | /// | ||
| 46 | /// | ||
| 47 | ///------------------------------------------------------------------------- | ||
| 48 | /// | ||
| 49 | /// **Example:** | ||
| 50 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 51 | /// #include <kodi/gui/dialogs/ContextMenu.h> | ||
| 52 | /// | ||
| 53 | /// const std::vector<std::string> entries | ||
| 54 | /// { | ||
| 55 | /// "Test 1", | ||
| 56 | /// "Test 2", | ||
| 57 | /// "Test 3", | ||
| 58 | /// "Test 4", | ||
| 59 | /// "Test 5" | ||
| 60 | /// }; | ||
| 61 | /// | ||
| 62 | /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries); | ||
| 63 | /// if (selected < 0) | ||
| 64 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 65 | /// else | ||
| 66 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 67 | /// ~~~~~~~~~~~~~ | ||
| 68 | /// | ||
| 69 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 70 | const std::vector<std::string>& entries) | ||
| 71 | { | ||
| 72 | using namespace ::kodi::addon; | ||
| 73 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 74 | const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char**))); | ||
| 75 | for (unsigned int i = 0; i < size; ++i) | ||
| 76 | { | ||
| 77 | cEntries[i] = entries[i].c_str(); | ||
| 78 | } | ||
| 79 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open( | ||
| 80 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 81 | free(cEntries); | ||
| 82 | return ret; | ||
| 83 | } | ||
| 84 | //-------------------------------------------------------------------------- | ||
| 85 | |||
| 86 | //========================================================================== | ||
| 87 | /// | ||
| 88 | /// \ingroup cpp_kodi_gui_dialogs_ContextMenu | ||
| 89 | /// @brief Show a context menu dialog about given parts. | ||
| 90 | /// | ||
| 91 | /// @param[in] heading Dialog heading name | ||
| 92 | /// @param[in] entries String list about entries | ||
| 93 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled | ||
| 94 | /// | ||
| 95 | /// | ||
| 96 | ///------------------------------------------------------------------------- | ||
| 97 | /// | ||
| 98 | /// **Example:** | ||
| 99 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 100 | /// #include <kodi/gui/dialogs/ContextMenu.h> | ||
| 101 | /// | ||
| 102 | /// const std::vector<std::pair<std::string, std::string>> entries | ||
| 103 | /// { | ||
| 104 | /// { "ID 1", "Test 1" }, | ||
| 105 | /// { "ID 2", "Test 2" }, | ||
| 106 | /// { "ID 3", "Test 3" }, | ||
| 107 | /// { "ID 4", "Test 4" }, | ||
| 108 | /// { "ID 5", "Test 5" } | ||
| 109 | /// }; | ||
| 110 | /// | ||
| 111 | /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries); | ||
| 112 | /// if (selected < 0) | ||
| 113 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 114 | /// else | ||
| 115 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 116 | /// ~~~~~~~~~~~~~ | ||
| 117 | /// | ||
| 118 | inline int ATTRIBUTE_HIDDEN Show( | ||
| 119 | const std::string& heading, const std::vector<std::pair<std::string, std::string>>& entries) | ||
| 120 | { | ||
| 121 | using namespace ::kodi::addon; | ||
| 122 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 123 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**))); | ||
| 124 | for (unsigned int i = 0; i < size; ++i) | ||
| 125 | { | ||
| 126 | cEntries[i] = entries[i].second.c_str(); | ||
| 127 | } | ||
| 128 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 129 | free(cEntries); | ||
| 130 | return ret; | ||
| 131 | } | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_dialogs_ContextMenu | ||
| 137 | /// @brief Show a context menu dialog about given parts. | ||
| 138 | /// | ||
| 139 | /// @param[in] heading Dialog heading name | ||
| 140 | /// @param[in] entries String list about entries | ||
| 141 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled | ||
| 142 | /// | ||
| 143 | /// | ||
| 144 | ///------------------------------------------------------------------------- | ||
| 145 | /// | ||
| 146 | /// **Example:** | ||
| 147 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 148 | /// #include <kodi/gui/dialogs/ContextMenu.h> | ||
| 149 | /// | ||
| 150 | /// const std::vector<std::pair<int, std::string>> entries | ||
| 151 | /// { | ||
| 152 | /// { 1, "Test 1" }, | ||
| 153 | /// { 2, "Test 2" }, | ||
| 154 | /// { 3, "Test 3" }, | ||
| 155 | /// { 4, "Test 4" }, | ||
| 156 | /// { 5, "Test 5" } | ||
| 157 | /// }; | ||
| 158 | /// | ||
| 159 | /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries); | ||
| 160 | /// if (selected < 0) | ||
| 161 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 162 | /// else | ||
| 163 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 164 | /// ~~~~~~~~~~~~~ | ||
| 165 | /// | ||
| 166 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 167 | const std::vector<std::pair<int, std::string>>& entries) | ||
| 168 | { | ||
| 169 | using namespace ::kodi::addon; | ||
| 170 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 171 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**))); | ||
| 172 | for (unsigned int i = 0; i < size; ++i) | ||
| 173 | { | ||
| 174 | cEntries[i] = entries[i].second.c_str(); | ||
| 175 | } | ||
| 176 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 177 | free(cEntries); | ||
| 178 | return ret; | ||
| 179 | } | ||
| 180 | //-------------------------------------------------------------------------- | ||
| 181 | }; | ||
| 182 | |||
| 183 | } /* namespace dialogs */ | ||
| 184 | } /* namespace gui */ | ||
| 185 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h deleted file mode 100644 index 90da063..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h +++ /dev/null | |||
| @@ -1,310 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_FileBrowser Dialog File Browser | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_namespace{ kodi::gui::dialogs::FileBrowser } | ||
| 26 | /// **File browser dialog** | ||
| 27 | /// | ||
| 28 | /// The functions listed below of the class "FileBrowser" offer | ||
| 29 | /// the possibility to select to a file by the user of the add-on. | ||
| 30 | /// | ||
| 31 | /// It allows all the options that are possible in Kodi itself and offers all | ||
| 32 | /// support file types. | ||
| 33 | /// | ||
| 34 | /// It has the header \ref FileBrowser.h "#include <kodi/gui/dialogs/FileBrowser.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | namespace FileBrowser | ||
| 38 | { | ||
| 39 | //========================================================================== | ||
| 40 | /// | ||
| 41 | /// \ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 42 | /// @brief Directory selection dialog | ||
| 43 | /// | ||
| 44 | /// @param[in] shares With Shares becomes the available start folders | ||
| 45 | /// be set. | ||
| 46 | /// @param[in] heading Dialog header name | ||
| 47 | /// @param[in,out] path As in the path to start and return value about | ||
| 48 | /// selected directory | ||
| 49 | /// @param[in] writeOnly If set only writeable folders are shown. | ||
| 50 | /// @return False if selection becomes canceled. | ||
| 51 | /// | ||
| 52 | /// **Example:** | ||
| 53 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 54 | /// #include <kodi/gui/dialogs/FileBrowser.h> | ||
| 55 | /// | ||
| 56 | /// /* | ||
| 57 | /// * Example show directory selection dialog with on 'share' (first value) | ||
| 58 | /// * defined directory types. | ||
| 59 | /// * | ||
| 60 | /// * If this becomes leaved empty and 'directory' is empty goes it to the | ||
| 61 | /// * base path of the hard disk. | ||
| 62 | /// * | ||
| 63 | /// * Also can be with path written to 'directory' before the dialog forced | ||
| 64 | /// * to a start place. | ||
| 65 | /// */ | ||
| 66 | /// std::string directory; | ||
| 67 | /// bool ret = kodi::gui::dialogs::FileBrowser::ShowAndGetDirectory("local|network|removable", | ||
| 68 | /// "Test directory selection", | ||
| 69 | /// directory, | ||
| 70 | /// false); | ||
| 71 | /// fprintf(stderr, "Selected directory is : %s and was %s\n", directory.c_str(), ret ? "OK" : "Canceled"); | ||
| 72 | /// ~~~~~~~~~~~~~ | ||
| 73 | /// | ||
| 74 | inline bool ATTRIBUTE_HIDDEN ShowAndGetDirectory(const std::string& shares, | ||
| 75 | const std::string& heading, | ||
| 76 | std::string& path, | ||
| 77 | bool writeOnly = false) | ||
| 78 | { | ||
| 79 | using namespace ::kodi::addon; | ||
| 80 | char* retString = nullptr; | ||
| 81 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_directory( | ||
| 82 | CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), path.c_str(), | ||
| 83 | &retString, writeOnly); | ||
| 84 | if (retString != nullptr) | ||
| 85 | { | ||
| 86 | if (std::strlen(retString)) | ||
| 87 | path = retString; | ||
| 88 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 89 | retString); | ||
| 90 | } | ||
| 91 | return ret; | ||
| 92 | } | ||
| 93 | //-------------------------------------------------------------------------- | ||
| 94 | |||
| 95 | //========================================================================== | ||
| 96 | /// | ||
| 97 | /// \ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 98 | /// @brief File selection dialog | ||
| 99 | /// | ||
| 100 | /// @param[in] shares With Shares becomes the available start | ||
| 101 | /// folders be set. | ||
| 102 | /// @param[in] mask The mask to filter visible files, e.g. | ||
| 103 | /// ".m3u|.pls|.b4s|.wpl". | ||
| 104 | /// @param[in] heading Dialog header name | ||
| 105 | /// @param[in,out] path As in the path to start and Return value | ||
| 106 | /// about selected file | ||
| 107 | /// @param[in] useThumbs If set show thumbs if possible on dialog. | ||
| 108 | /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are | ||
| 109 | /// handled as directories. | ||
| 110 | /// @return False if selection becomes canceled. | ||
| 111 | /// | ||
| 112 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFile(const std::string& shares, | ||
| 113 | const std::string& mask, | ||
| 114 | const std::string& heading, | ||
| 115 | std::string& path, | ||
| 116 | bool useThumbs = false, | ||
| 117 | bool useFileDirectories = false) | ||
| 118 | { | ||
| 119 | using namespace ::kodi::addon; | ||
| 120 | char* retString = nullptr; | ||
| 121 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 122 | shares.c_str(), mask.c_str(), heading.c_str(), path.c_str(), &retString, | ||
| 123 | useThumbs, useFileDirectories); | ||
| 124 | if (retString != nullptr) | ||
| 125 | { | ||
| 126 | if (std::strlen(retString)) | ||
| 127 | path = retString; | ||
| 128 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 129 | } | ||
| 130 | return ret; | ||
| 131 | } | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 137 | /// @brief File selection from a directory | ||
| 138 | /// | ||
| 139 | /// @param[in] directory The directory name where the dialog | ||
| 140 | /// start, possible are normal names and | ||
| 141 | /// kodi's special names. | ||
| 142 | /// @param[in] mask The mask to filter visible files, e.g. | ||
| 143 | /// ".m3u|.pls|.b4s|.wpl". | ||
| 144 | /// @param[in] heading Dialog header name | ||
| 145 | /// @param[in,out] path As in the path to start and Return value | ||
| 146 | /// about selected file | ||
| 147 | /// @param[in] useThumbs If set show thumbs if possible on dialog. | ||
| 148 | /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are | ||
| 149 | /// handled as directories. | ||
| 150 | /// @param[in] singleList | ||
| 151 | /// @return False if selection becomes canceled. | ||
| 152 | /// | ||
| 153 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFileFromDir(const std::string& directory, | ||
| 154 | const std::string& mask, | ||
| 155 | const std::string& heading, | ||
| 156 | std::string& path, | ||
| 157 | bool useThumbs = false, | ||
| 158 | bool useFileDirectories = false, | ||
| 159 | bool singleList = false) | ||
| 160 | { | ||
| 161 | using namespace ::kodi::addon; | ||
| 162 | char* retString = nullptr; | ||
| 163 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_from_dir(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 164 | directory.c_str(), mask.c_str(), heading.c_str(), | ||
| 165 | path.c_str(), &retString, useThumbs, | ||
| 166 | useFileDirectories, singleList); | ||
| 167 | if (retString != nullptr) | ||
| 168 | { | ||
| 169 | if (std::strlen(retString)) | ||
| 170 | path = retString; | ||
| 171 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 172 | } | ||
| 173 | return ret; | ||
| 174 | } | ||
| 175 | //-------------------------------------------------------------------------- | ||
| 176 | |||
| 177 | //========================================================================== | ||
| 178 | /// | ||
| 179 | /// \ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 180 | /// @brief File selection dialog to get several in to a list | ||
| 181 | /// | ||
| 182 | /// @param[in] shares With Shares becomes the available start | ||
| 183 | /// folders be set. | ||
| 184 | /// @param[in] mask The mask to filter visible files, e.g. | ||
| 185 | /// ".m3u|.pls|.b4s|.wpl". | ||
| 186 | /// @param[in] heading Dialog header name | ||
| 187 | /// @param[out] fileList Return value about selected files | ||
| 188 | /// @param[in] useThumbs If set show thumbs if possible on dialog. | ||
| 189 | /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are | ||
| 190 | /// handled as directories. | ||
| 191 | /// @return False if selection becomes canceled. | ||
| 192 | /// | ||
| 193 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFileList(const std::string& shares, | ||
| 194 | const std::string& mask, | ||
| 195 | const std::string& heading, | ||
| 196 | std::vector<std::string>& fileList, | ||
| 197 | bool useThumbs = false, | ||
| 198 | bool useFileDirectories = false) | ||
| 199 | { | ||
| 200 | using namespace ::kodi::addon; | ||
| 201 | char** list = nullptr; | ||
| 202 | unsigned int listSize = 0; | ||
| 203 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_list(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 204 | shares.c_str(), mask.c_str(), heading.c_str(), &list, &listSize, | ||
| 205 | useThumbs, useFileDirectories); | ||
| 206 | if (ret) | ||
| 207 | { | ||
| 208 | for (unsigned int i = 0; i < listSize; ++i) | ||
| 209 | fileList.emplace_back(list[i]); | ||
| 210 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); | ||
| 211 | } | ||
| 212 | return ret; | ||
| 213 | } | ||
| 214 | //-------------------------------------------------------------------------- | ||
| 215 | |||
| 216 | //========================================================================== | ||
| 217 | /// | ||
| 218 | /// \ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 219 | /// @brief Source selection dialog | ||
| 220 | /// | ||
| 221 | /// @param[in,out] path As in the path to start and Return value | ||
| 222 | /// about selected source | ||
| 223 | /// @param[in] allowNetworkShares Allow also access to network | ||
| 224 | /// @param[in] additionalShare With additionalShare becomes the available | ||
| 225 | /// start folders be set (optional). | ||
| 226 | /// @param[in] type | ||
| 227 | /// @return False if selection becomes canceled. | ||
| 228 | /// | ||
| 229 | inline bool ATTRIBUTE_HIDDEN ShowAndGetSource(std::string& path, | ||
| 230 | bool allowNetworkShares, | ||
| 231 | const std::string& additionalShare = "", | ||
| 232 | const std::string& type = "") | ||
| 233 | { | ||
| 234 | using namespace ::kodi::addon; | ||
| 235 | char* retString = nullptr; | ||
| 236 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_source(CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), &retString, | ||
| 237 | allowNetworkShares, additionalShare.c_str(), type.c_str()); | ||
| 238 | if (retString != nullptr) | ||
| 239 | { | ||
| 240 | if (std::strlen(retString)) | ||
| 241 | path = retString; | ||
| 242 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 243 | } | ||
| 244 | return ret; | ||
| 245 | } | ||
| 246 | //-------------------------------------------------------------------------- | ||
| 247 | |||
| 248 | //========================================================================== | ||
| 249 | /// | ||
| 250 | /// \ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 251 | /// @brief Image selection dialog | ||
| 252 | /// | ||
| 253 | /// @param[in] shares With Shares becomes the available start folders be | ||
| 254 | /// set. | ||
| 255 | /// @param[in] heading Dialog header name | ||
| 256 | /// @param[out] path Return value about selected image | ||
| 257 | /// @return False if selection becomes canceled. | ||
| 258 | /// | ||
| 259 | inline bool ATTRIBUTE_HIDDEN ShowAndGetImage(const std::string& shares, | ||
| 260 | const std::string& heading, | ||
| 261 | std::string& path) | ||
| 262 | { | ||
| 263 | using namespace ::kodi::addon; | ||
| 264 | char* retString = nullptr; | ||
| 265 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 266 | shares.c_str(), heading.c_str(), path.c_str(), &retString); | ||
| 267 | if (retString != nullptr) | ||
| 268 | { | ||
| 269 | if (std::strlen(retString)) | ||
| 270 | path = retString; | ||
| 271 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 272 | } | ||
| 273 | return ret; | ||
| 274 | } | ||
| 275 | //-------------------------------------------------------------------------- | ||
| 276 | |||
| 277 | //========================================================================== | ||
| 278 | /// | ||
| 279 | /// \ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 280 | /// @brief Image selection dialog to get several in to a list | ||
| 281 | /// | ||
| 282 | /// @param[in] shares With Shares becomes the available start folders | ||
| 283 | /// be set. | ||
| 284 | /// @param[in] heading Dialog header name | ||
| 285 | /// @param[out] file_list Return value about selected images | ||
| 286 | /// @return False if selection becomes canceled. | ||
| 287 | /// | ||
| 288 | inline bool ATTRIBUTE_HIDDEN ShowAndGetImageList(const std::string& shares, | ||
| 289 | const std::string& heading, | ||
| 290 | std::vector<std::string>& file_list) | ||
| 291 | { | ||
| 292 | using namespace ::kodi::addon; | ||
| 293 | char** list = nullptr; | ||
| 294 | unsigned int listSize = 0; | ||
| 295 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image_list(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 296 | shares.c_str(), heading.c_str(), &list, &listSize); | ||
| 297 | if (ret) | ||
| 298 | { | ||
| 299 | for (unsigned int i = 0; i < listSize; ++i) | ||
| 300 | file_list.emplace_back(list[i]); | ||
| 301 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); | ||
| 302 | } | ||
| 303 | return ret; | ||
| 304 | } | ||
| 305 | //-------------------------------------------------------------------------- | ||
| 306 | }; | ||
| 307 | |||
| 308 | } /* namespace dialogs */ | ||
| 309 | } /* namespace gui */ | ||
| 310 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h deleted file mode 100644 index 843bdfa..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h +++ /dev/null | |||
| @@ -1,422 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_Keyboard Dialog Keyboard | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_namespace{ kodi::gui::dialogs::Keyboard } | ||
| 26 | /// **Keyboard dialogs** | ||
| 27 | /// | ||
| 28 | /// The functions listed below have to be permitted by the user for the | ||
| 29 | /// representation of a keyboard around an input. | ||
| 30 | /// | ||
| 31 | /// The class supports several kinds, from an easy text choice up to the | ||
| 32 | /// passport Word production and their confirmation for add-on. | ||
| 33 | /// | ||
| 34 | /// It has the header \ref Keyboard.h "#include <kodi/gui/dialogs/Keyboard.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | namespace Keyboard | ||
| 38 | { | ||
| 39 | //========================================================================== | ||
| 40 | /// | ||
| 41 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 42 | /// @brief Show keyboard with initial value `text` and replace with result | ||
| 43 | /// string. | ||
| 44 | /// | ||
| 45 | /// @param[in,out] text Overwritten with user input if return=true. | ||
| 46 | /// @param[in] heading String shown on dialog title. | ||
| 47 | /// @param[in] allowEmptyResult Whether a blank password is valid or not. | ||
| 48 | /// @param[in] hiddenInput The inserted input is not shown as text. | ||
| 49 | /// @param[in] autoCloseMs To close the dialog after a specified | ||
| 50 | /// time, in milliseconds, default is 0 which | ||
| 51 | /// keeps the dialog open indefinitely. | ||
| 52 | /// @return true if successful display and user input. | ||
| 53 | /// false if unsuccessful display, no user | ||
| 54 | /// input, or canceled editing. | ||
| 55 | /// | ||
| 56 | /// | ||
| 57 | ///------------------------------------------------------------------------- | ||
| 58 | /// | ||
| 59 | /// **Example:** | ||
| 60 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 61 | /// #include <kodi/gui/dialogs/Keyboard.h> | ||
| 62 | /// | ||
| 63 | /// /* | ||
| 64 | /// * The example shows the display of keyboard call dialog at Kodi from the add-on. | ||
| 65 | /// * Below all values are set, however, can last two (hidden input = false and autoCloseMs = 0) | ||
| 66 | /// * to be released if not needed. | ||
| 67 | /// */ | ||
| 68 | /// std::string text = "Please change me to them want you want"; /*< It can be leaved empty or a | ||
| 69 | /// entry text added */ | ||
| 70 | /// bool bRet = ::kodi::gui::dialogs::Keyboard::ShowAndGetInput(text, | ||
| 71 | /// "Demonstration text entry", | ||
| 72 | /// true, | ||
| 73 | /// false, | ||
| 74 | /// 0); | ||
| 75 | /// fprintf(stderr, "Written keyboard input is : '%s' and was %s\n", | ||
| 76 | /// text.c_str(), bRet ? "OK" : "Canceled"); | ||
| 77 | /// ~~~~~~~~~~~~~ | ||
| 78 | /// | ||
| 79 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(std::string& text, | ||
| 80 | const std::string& heading, | ||
| 81 | bool allowEmptyResult, | ||
| 82 | bool hiddenInput = false, | ||
| 83 | unsigned int autoCloseMs = 0) | ||
| 84 | { | ||
| 85 | using namespace ::kodi::addon; | ||
| 86 | char* retString = nullptr; | ||
| 87 | bool ret = | ||
| 88 | CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input_with_head( | ||
| 89 | CAddonBase::m_interface->toKodi->kodiBase, text.c_str(), &retString, heading.c_str(), | ||
| 90 | allowEmptyResult, hiddenInput, autoCloseMs); | ||
| 91 | if (retString != nullptr) | ||
| 92 | { | ||
| 93 | text = retString; | ||
| 94 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 95 | retString); | ||
| 96 | } | ||
| 97 | return ret; | ||
| 98 | } | ||
| 99 | //-------------------------------------------------------------------------- | ||
| 100 | |||
| 101 | //========================================================================== | ||
| 102 | /// | ||
| 103 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 104 | /// @brief The example shows the display of keyboard call dialog at Kodi | ||
| 105 | /// from the add-on. | ||
| 106 | /// | ||
| 107 | /// @param[out] text Overwritten with user input if return=true. | ||
| 108 | /// @param[in] allowEmptyResult If set to true keyboard can also exited | ||
| 109 | /// without entered text. | ||
| 110 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 111 | /// in milliseconds, default is 0 which keeps | ||
| 112 | /// the dialog open indefinitely. | ||
| 113 | /// @return true if successful display and user input. | ||
| 114 | /// false if unsuccessful display, no user | ||
| 115 | /// input, or canceled editing. | ||
| 116 | /// | ||
| 117 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(std::string& text, | ||
| 118 | bool allowEmptyResult, | ||
| 119 | unsigned int autoCloseMs = 0) | ||
| 120 | { | ||
| 121 | using namespace ::kodi::addon; | ||
| 122 | char* retString = nullptr; | ||
| 123 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 124 | text.c_str(), &retString, | ||
| 125 | allowEmptyResult, autoCloseMs); | ||
| 126 | if (retString != nullptr) | ||
| 127 | { | ||
| 128 | text = retString; | ||
| 129 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 130 | } | ||
| 131 | return ret; | ||
| 132 | } | ||
| 133 | //-------------------------------------------------------------------------- | ||
| 134 | |||
| 135 | //========================================================================== | ||
| 136 | /// | ||
| 137 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 138 | /// @brief Shows keyboard and prompts for a password. Differs from | ||
| 139 | /// `ShowAndVerifyNewPassword()` in that no second verification | ||
| 140 | /// | ||
| 141 | /// @param[in,out] newPassword Overwritten with user input if return=true. | ||
| 142 | /// @param[in] heading String shown on dialog title. | ||
| 143 | /// @param[in] allowEmptyResult Whether a blank password is valid or not. | ||
| 144 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 145 | /// in milliseconds, default is 0 which keeps | ||
| 146 | /// the dialog open indefinitely. | ||
| 147 | /// @return true if successful display and user input. | ||
| 148 | /// false if unsuccessful display, no user | ||
| 149 | /// input, or canceled editing. | ||
| 150 | /// | ||
| 151 | inline bool ATTRIBUTE_HIDDEN ShowAndGetNewPassword(std::string& newPassword, | ||
| 152 | const std::string& heading, | ||
| 153 | bool allowEmptyResult, | ||
| 154 | unsigned int autoCloseMs = 0) | ||
| 155 | { | ||
| 156 | using namespace ::kodi::addon; | ||
| 157 | char* retString = nullptr; | ||
| 158 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 159 | newPassword.c_str(), &retString, heading.c_str(), | ||
| 160 | allowEmptyResult, autoCloseMs); | ||
| 161 | if (retString != nullptr) | ||
| 162 | { | ||
| 163 | newPassword = retString; | ||
| 164 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 165 | } | ||
| 166 | return ret; | ||
| 167 | } | ||
| 168 | //-------------------------------------------------------------------------- | ||
| 169 | |||
| 170 | //========================================================================== | ||
| 171 | /// | ||
| 172 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 173 | /// @brief Shows keyboard and prompts for a password. Differs from | ||
| 174 | /// `ShowAndVerifyNewPassword()` in that no second verification | ||
| 175 | /// | ||
| 176 | /// @param[in,out] newPassword Overwritten with user input if return=true. | ||
| 177 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 178 | /// in milliseconds, default is 0 which keeps | ||
| 179 | /// the dialog open indefinitely. | ||
| 180 | /// @return true if successful display and user input. | ||
| 181 | /// false if unsuccessful display, no user | ||
| 182 | /// input, or canceled editing. | ||
| 183 | /// | ||
| 184 | inline bool ATTRIBUTE_HIDDEN ShowAndGetNewPassword(std::string& newPassword, | ||
| 185 | unsigned int autoCloseMs = 0) | ||
| 186 | { | ||
| 187 | using namespace ::kodi::addon; | ||
| 188 | char* retString = nullptr; | ||
| 189 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 190 | newPassword.c_str(), &retString, autoCloseMs); | ||
| 191 | if (retString != nullptr) | ||
| 192 | { | ||
| 193 | newPassword = retString; | ||
| 194 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 195 | } | ||
| 196 | return ret; | ||
| 197 | } | ||
| 198 | //-------------------------------------------------------------------------- | ||
| 199 | |||
| 200 | //========================================================================== | ||
| 201 | /// | ||
| 202 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 203 | /// @brief Show keyboard twice to get and confirm a user-entered password | ||
| 204 | /// string. | ||
| 205 | /// | ||
| 206 | /// @param[out] newPassword Overwritten with user input if return=true. | ||
| 207 | /// @param[in] heading String shown on dialog title. | ||
| 208 | /// @param[in] allowEmptyResult | ||
| 209 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 210 | /// in milliseconds, default is 0 which keeps | ||
| 211 | /// the dialog open indefinitely. | ||
| 212 | /// @return true if successful display and user input. | ||
| 213 | /// false if unsuccessful display, no user | ||
| 214 | /// input, or canceled editing. | ||
| 215 | /// | ||
| 216 | /// | ||
| 217 | ///------------------------------------------------------------------------- | ||
| 218 | /// | ||
| 219 | /// **Example:** | ||
| 220 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 221 | /// #include <kodi/General.h> | ||
| 222 | /// #include <kodi/gui/dialogs/Keyboard.h> | ||
| 223 | /// | ||
| 224 | /// /* | ||
| 225 | /// * The example below shows the complete use of keyboard dialog for password | ||
| 226 | /// * check. If only one check from add-on needed can be function with retries | ||
| 227 | /// * set to '0' called alone. | ||
| 228 | /// * | ||
| 229 | /// * The use of MD5 translated password is always required for the check on Kodi! | ||
| 230 | /// */ | ||
| 231 | /// | ||
| 232 | /// int maxretries = 3; | ||
| 233 | /// /* | ||
| 234 | /// * Password names need to be send as md5 sum to kodi. | ||
| 235 | /// */ | ||
| 236 | /// std::string password; | ||
| 237 | /// kodi::GetMD5("kodi", password); | ||
| 238 | /// | ||
| 239 | /// /* | ||
| 240 | /// * To the loop about password checks. | ||
| 241 | /// */ | ||
| 242 | /// int ret; | ||
| 243 | /// for (unsigned int i = 0; i < maxretries; i++) | ||
| 244 | /// { | ||
| 245 | /// /* | ||
| 246 | /// * Ask the user about the password. | ||
| 247 | /// */ | ||
| 248 | /// ret = ::kodi::gui::dialogs::Keyboard::ShowAndVerifyPassword(password, "Demo password call for PW 'kodi'", i, 0); | ||
| 249 | /// if (ret == 0) | ||
| 250 | /// { | ||
| 251 | /// fprintf(stderr, "Password successfull confirmed after '%i' tries\n", i+1); | ||
| 252 | /// break; | ||
| 253 | /// } | ||
| 254 | /// else if (ret < 0) | ||
| 255 | /// { | ||
| 256 | /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); | ||
| 257 | /// break; | ||
| 258 | /// } | ||
| 259 | /// else /* if (ret > 0) */ | ||
| 260 | /// { | ||
| 261 | /// fprintf(stderr, "Wrong password entered on try '%i'\n", i+1); | ||
| 262 | /// } | ||
| 263 | /// } | ||
| 264 | /// ~~~~~~~~~~~~~ | ||
| 265 | /// | ||
| 266 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword, | ||
| 267 | const std::string& heading, | ||
| 268 | bool allowEmptyResult, | ||
| 269 | unsigned int autoCloseMs = 0) | ||
| 270 | { | ||
| 271 | using namespace ::kodi::addon; | ||
| 272 | char* retString = nullptr; | ||
| 273 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 274 | &retString, heading.c_str(), allowEmptyResult, | ||
| 275 | autoCloseMs); | ||
| 276 | if (retString != nullptr) | ||
| 277 | { | ||
| 278 | newPassword = retString; | ||
| 279 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 280 | } | ||
| 281 | return ret; | ||
| 282 | } | ||
| 283 | //-------------------------------------------------------------------------- | ||
| 284 | |||
| 285 | //========================================================================== | ||
| 286 | /// | ||
| 287 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 288 | /// @brief Show keyboard twice to get and confirm a user-entered password | ||
| 289 | /// string. | ||
| 290 | /// | ||
| 291 | /// @param[out] newPassword Overwritten with user input if return=true. | ||
| 292 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 293 | /// in milliseconds, default is 0 which keeps | ||
| 294 | /// the dialog open indefinitely. | ||
| 295 | /// @return true if successful display and user input. | ||
| 296 | /// false if unsuccessful display, no user | ||
| 297 | /// input, or canceled editing. | ||
| 298 | /// | ||
| 299 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword, | ||
| 300 | unsigned int autoCloseMs = 0) | ||
| 301 | { | ||
| 302 | using namespace ::kodi::addon; | ||
| 303 | char* retString = nullptr; | ||
| 304 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 305 | &retString, autoCloseMs); | ||
| 306 | if (retString != nullptr) | ||
| 307 | { | ||
| 308 | newPassword = retString; | ||
| 309 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 310 | } | ||
| 311 | return ret; | ||
| 312 | } | ||
| 313 | //-------------------------------------------------------------------------- | ||
| 314 | |||
| 315 | //========================================================================== | ||
| 316 | /// | ||
| 317 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 318 | /// @brief Show keyboard and verify user input against `password`. | ||
| 319 | /// | ||
| 320 | /// @param[in,out] password Value to compare against user input. | ||
| 321 | /// @param[in] heading String shown on dialog title. | ||
| 322 | /// @param[in] retries If greater than 0, shows "Incorrect | ||
| 323 | /// password, %d retries left" on dialog line 2, | ||
| 324 | /// else line 2 is blank. | ||
| 325 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 326 | /// in milliseconds, default is 0 which keeps | ||
| 327 | /// the dialog open indefinitely. | ||
| 328 | /// @return 0 if successful display and user input. 1 if | ||
| 329 | /// unsuccessful input. -1 if no user input or | ||
| 330 | /// canceled editing. | ||
| 331 | /// | ||
| 332 | inline int ATTRIBUTE_HIDDEN ShowAndVerifyPassword(std::string& password, | ||
| 333 | const std::string& heading, | ||
| 334 | int retries, | ||
| 335 | unsigned int autoCloseMs = 0) | ||
| 336 | { | ||
| 337 | using namespace ::kodi::addon; | ||
| 338 | char* retString = nullptr; | ||
| 339 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 340 | password.c_str(), &retString, heading.c_str(), | ||
| 341 | retries, autoCloseMs); | ||
| 342 | if (retString != nullptr) | ||
| 343 | { | ||
| 344 | password = retString; | ||
| 345 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 346 | } | ||
| 347 | return ret; | ||
| 348 | } | ||
| 349 | //-------------------------------------------------------------------------- | ||
| 350 | |||
| 351 | //========================================================================== | ||
| 352 | /// | ||
| 353 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 354 | /// @brief Shows a filter related keyboard | ||
| 355 | /// | ||
| 356 | /// @param[in,out] text Overwritten with user input if return=true. | ||
| 357 | /// @param[in] searching Use dialog for search and send our search | ||
| 358 | /// message in safe way (only the active window | ||
| 359 | /// needs it) | ||
| 360 | /// - header name if true is "Enter search string" | ||
| 361 | /// - header name if false is "Enter value" | ||
| 362 | /// @param autoCloseMs To close the dialog after a specified time, | ||
| 363 | /// in milliseconds, default is 0 which keeps | ||
| 364 | /// the dialog open indefinitely. | ||
| 365 | /// @return true if successful display and user input. | ||
| 366 | /// false if unsuccessful display, no user | ||
| 367 | /// input, or canceled editing. | ||
| 368 | /// | ||
| 369 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFilter(std::string& text, | ||
| 370 | bool searching, | ||
| 371 | unsigned int autoCloseMs = 0) | ||
| 372 | { | ||
| 373 | using namespace ::kodi::addon; | ||
| 374 | char* retString = nullptr; | ||
| 375 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_filter(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 376 | text.c_str(), &retString, searching, autoCloseMs); | ||
| 377 | if (retString != nullptr) | ||
| 378 | { | ||
| 379 | text = retString; | ||
| 380 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 381 | } | ||
| 382 | return ret; | ||
| 383 | } | ||
| 384 | //-------------------------------------------------------------------------- | ||
| 385 | |||
| 386 | //========================================================================== | ||
| 387 | /// | ||
| 388 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 389 | /// @brief Send a text to a visible keyboard | ||
| 390 | /// | ||
| 391 | /// @param[in] text Overwritten with user input if return=true. | ||
| 392 | /// @param[in] closeKeyboard The open dialog is if also closed on 'true'. | ||
| 393 | /// @return true if successful done, false if | ||
| 394 | /// unsuccessful or keyboard not present. | ||
| 395 | /// | ||
| 396 | inline bool ATTRIBUTE_HIDDEN SendTextToActiveKeyboard(const std::string& text, | ||
| 397 | bool closeKeyboard = false) | ||
| 398 | { | ||
| 399 | using namespace ::kodi::addon; | ||
| 400 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->send_text_to_active_keyboard(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 401 | text.c_str(), closeKeyboard); | ||
| 402 | } | ||
| 403 | //-------------------------------------------------------------------------- | ||
| 404 | |||
| 405 | //========================================================================== | ||
| 406 | /// | ||
| 407 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 408 | /// @brief Check for visible keyboard on GUI | ||
| 409 | /// | ||
| 410 | /// @return true if keyboard present, false if not present | ||
| 411 | /// | ||
| 412 | inline bool ATTRIBUTE_HIDDEN IsKeyboardActivated() | ||
| 413 | { | ||
| 414 | using namespace ::kodi::addon; | ||
| 415 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->is_keyboard_activated(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 416 | } | ||
| 417 | //-------------------------------------------------------------------------- | ||
| 418 | }; | ||
| 419 | |||
| 420 | } /* namespace dialogs */ | ||
| 421 | } /* namespace gui */ | ||
| 422 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h deleted file mode 100644 index bff7683..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h +++ /dev/null | |||
| @@ -1,362 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_Numeric Dialog Numeric | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @{ | ||
| 26 | /// @brief \cpp_namespace{ kodi::gui::dialogs::Numeric } | ||
| 27 | /// **Numeric dialogs** | ||
| 28 | /// | ||
| 29 | /// The functions listed below have to be permitted by the user for the | ||
| 30 | /// representation of a numeric keyboard around an input. | ||
| 31 | /// | ||
| 32 | /// The class supports several kinds, from an easy number choice up to the | ||
| 33 | /// passport Word production and their confirmation for add-on. | ||
| 34 | /// | ||
| 35 | /// It has the header \ref Numeric.h "#include <kodi/gui/dialogs/Numeric.h>" | ||
| 36 | /// be included to enjoy it. | ||
| 37 | /// | ||
| 38 | namespace Numeric | ||
| 39 | { | ||
| 40 | //========================================================================== | ||
| 41 | /// | ||
| 42 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 43 | /// @brief Use dialog to get numeric new password | ||
| 44 | /// | ||
| 45 | /// @param[out] newPassword String to preload into the keyboard | ||
| 46 | /// accumulator. Overwritten with user input | ||
| 47 | /// if return=true. Returned in MD5 format. | ||
| 48 | /// @return true if successful display and user | ||
| 49 | /// input entry/re-entry. | ||
| 50 | /// false if unsuccessful display, no user | ||
| 51 | /// input, or canceled editing. | ||
| 52 | /// | ||
| 53 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword) | ||
| 54 | { | ||
| 55 | using namespace ::kodi::addon; | ||
| 56 | char* pw = nullptr; | ||
| 57 | bool ret = | ||
| 58 | CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_new_password( | ||
| 59 | CAddonBase::m_interface->toKodi->kodiBase, &pw); | ||
| 60 | if (pw != nullptr) | ||
| 61 | { | ||
| 62 | newPassword = pw; | ||
| 63 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, pw); | ||
| 64 | } | ||
| 65 | return ret; | ||
| 66 | } | ||
| 67 | //-------------------------------------------------------------------------- | ||
| 68 | |||
| 69 | //========================================================================== | ||
| 70 | /// | ||
| 71 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 72 | /// @brief Use dialog to verify numeric password. | ||
| 73 | /// | ||
| 74 | /// @param[in] password Password to compare with user input, need | ||
| 75 | /// in MD5 format. | ||
| 76 | /// @param[in] heading Heading to display | ||
| 77 | /// @param[in] retries If greater than 0, shows "Incorrect | ||
| 78 | /// password, %d retries left" on dialog | ||
| 79 | /// line 2, else line 2 is blank. | ||
| 80 | /// @return Possible values: | ||
| 81 | /// - 0 if successful display and user input. | ||
| 82 | /// - 1 if unsuccessful input. | ||
| 83 | /// - -1 if no user input or canceled editing. | ||
| 84 | /// | ||
| 85 | /// | ||
| 86 | ///------------------------------------------------------------------------- | ||
| 87 | /// | ||
| 88 | /// **Example:** | ||
| 89 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 90 | /// #include <stdio.h> /* fprintf */ | ||
| 91 | /// #include <kodi/General.h> | ||
| 92 | /// #include <kodi/gui/dialogs/Numeric.h> | ||
| 93 | /// | ||
| 94 | /// /* | ||
| 95 | /// * The example below shows the complete use of keyboard dialog for password | ||
| 96 | /// * check. If only one check from add-on needed can be function with retries | ||
| 97 | /// * set to '0' called alone. | ||
| 98 | /// * | ||
| 99 | /// * The use of MD5 translated password is always required for the check on Kodi! | ||
| 100 | /// */ | ||
| 101 | /// | ||
| 102 | /// int maxretries = 3; | ||
| 103 | /// | ||
| 104 | /// /* | ||
| 105 | /// * Password names need to be send as md5 sum to kodi. | ||
| 106 | /// */ | ||
| 107 | /// std::string password = kodi::GetMD5("1234"); | ||
| 108 | /// | ||
| 109 | /// /* | ||
| 110 | /// * To the loop about password checks. | ||
| 111 | /// */ | ||
| 112 | /// int ret; | ||
| 113 | /// for (unsigned int i = 0; i < maxretries; i++) | ||
| 114 | /// { | ||
| 115 | /// /* | ||
| 116 | /// * Ask the user about the password. | ||
| 117 | /// */ | ||
| 118 | /// ret = kodi::gui::dialogs::Numeric::ShowAndVerifyPassword(password, "Demo numeric password call for PW '1234'", i); | ||
| 119 | /// if (ret == 0) | ||
| 120 | /// { | ||
| 121 | /// fprintf(stderr, "Numeric password successfull confirmed after '%i' tries\n", i+1); | ||
| 122 | /// break; | ||
| 123 | /// } | ||
| 124 | /// else if (ret < 0) | ||
| 125 | /// { | ||
| 126 | /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); | ||
| 127 | /// break; | ||
| 128 | /// } | ||
| 129 | /// else /* if (ret > 0) */ | ||
| 130 | /// { | ||
| 131 | /// fprintf(stderr, "Wrong numeric password entered on try '%i'\n", i+1); | ||
| 132 | /// } | ||
| 133 | /// } | ||
| 134 | /// ~~~~~~~~~~~~~ | ||
| 135 | /// | ||
| 136 | inline int ATTRIBUTE_HIDDEN ShowAndVerifyPassword(const std::string& password, | ||
| 137 | const std::string& heading, | ||
| 138 | int retries) | ||
| 139 | { | ||
| 140 | using namespace ::kodi::addon; | ||
| 141 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 142 | password.c_str(), heading.c_str(), retries); | ||
| 143 | } | ||
| 144 | //-------------------------------------------------------------------------- | ||
| 145 | |||
| 146 | //========================================================================== | ||
| 147 | /// | ||
| 148 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 149 | /// @brief Use dialog to verify numeric password | ||
| 150 | /// | ||
| 151 | /// @param[in,out] toVerify Value to compare against user input. | ||
| 152 | /// @param[in] heading Heading to display | ||
| 153 | /// @param[in] verifyInput If set as true we verify the users input | ||
| 154 | /// versus toVerify. | ||
| 155 | /// @return true if successful display and user | ||
| 156 | /// input. false if unsuccessful display, no | ||
| 157 | /// user input, or canceled editing. | ||
| 158 | /// | ||
| 159 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyInput(std::string& toVerify, | ||
| 160 | const std::string& heading, | ||
| 161 | bool verifyInput) | ||
| 162 | { | ||
| 163 | using namespace ::kodi::addon; | ||
| 164 | char* retString = nullptr; | ||
| 165 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_input(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 166 | toVerify.c_str(), &retString, heading.c_str(), verifyInput); | ||
| 167 | if (retString != nullptr) | ||
| 168 | { | ||
| 169 | toVerify = retString; | ||
| 170 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 171 | } | ||
| 172 | return ret; | ||
| 173 | } | ||
| 174 | //-------------------------------------------------------------------------- | ||
| 175 | |||
| 176 | //========================================================================== | ||
| 177 | /// | ||
| 178 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 179 | /// @brief Use dialog to get time value. | ||
| 180 | /// | ||
| 181 | /// @param[out] time Overwritten with user input if | ||
| 182 | /// return=true and time inserted. | ||
| 183 | /// @param[in] heading Heading to display. | ||
| 184 | /// @return true if successful display and user | ||
| 185 | /// input. false if unsuccessful display, no | ||
| 186 | /// user input, or canceled editing. | ||
| 187 | /// | ||
| 188 | /// | ||
| 189 | ///------------------------------------------------------------------------- | ||
| 190 | /// | ||
| 191 | /// **Example:** | ||
| 192 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 193 | /// #include <stdio.h> /* printf */ | ||
| 194 | /// #include <time.h> /* time_t, struct tm, time, localtime, strftime */ | ||
| 195 | /// #include <kodi/gui/dialogs/Numeric.h> | ||
| 196 | /// | ||
| 197 | /// time_t rawtime; | ||
| 198 | /// struct tm * timeinfo; | ||
| 199 | /// char buffer [10]; | ||
| 200 | /// | ||
| 201 | /// time (&rawtime); | ||
| 202 | /// timeinfo = localtime(&rawtime); | ||
| 203 | /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetTime(*timeinfo, "Selected time test call"); | ||
| 204 | /// strftime(buffer, sizeof(buffer), "%H:%M.", timeinfo); | ||
| 205 | /// printf("Selected time it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); | ||
| 206 | /// ~~~~~~~~~~~~~ | ||
| 207 | /// | ||
| 208 | inline bool ATTRIBUTE_HIDDEN ShowAndGetTime(tm& time, const std::string& heading) | ||
| 209 | { | ||
| 210 | using namespace ::kodi::addon; | ||
| 211 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_time(CAddonBase::m_interface->toKodi->kodiBase, &time, heading.c_str()); | ||
| 212 | } | ||
| 213 | //-------------------------------------------------------------------------- | ||
| 214 | |||
| 215 | //========================================================================== | ||
| 216 | /// | ||
| 217 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 218 | /// @brief Use dialog to get date value. | ||
| 219 | /// | ||
| 220 | /// @param[in,out] date Overwritten with user input if | ||
| 221 | /// return=true and date inserted. | ||
| 222 | /// @param[in] heading Heading to display | ||
| 223 | /// @return true if successful display and user | ||
| 224 | /// input. false if unsuccessful display, no | ||
| 225 | /// user input, or canceled editing. | ||
| 226 | /// | ||
| 227 | /// | ||
| 228 | ///------------------------------------------------------------------------- | ||
| 229 | /// | ||
| 230 | /// **Example:** | ||
| 231 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 232 | /// #include <stdio.h> /* printf */ | ||
| 233 | /// #include <time.h> /* time_t, struct tm, time, localtime, strftime */ | ||
| 234 | /// #include <kodi/gui/dialogs/Numeric.h> | ||
| 235 | /// | ||
| 236 | /// time_t rawtime; | ||
| 237 | /// struct tm * timeinfo; | ||
| 238 | /// char buffer [20]; | ||
| 239 | /// | ||
| 240 | /// time (&rawtime); | ||
| 241 | /// timeinfo = localtime(&rawtime); | ||
| 242 | /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetDate(*timeinfo, "Selected date test call"); | ||
| 243 | /// strftime(buffer, sizeof(buffer), "%Y-%m-%d", timeinfo); | ||
| 244 | /// printf("Selected date it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); | ||
| 245 | /// ~~~~~~~~~~~~~ | ||
| 246 | /// | ||
| 247 | inline bool ATTRIBUTE_HIDDEN ShowAndGetDate(tm& date, const std::string& heading) | ||
| 248 | { | ||
| 249 | using namespace ::kodi::addon; | ||
| 250 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_date(CAddonBase::m_interface->toKodi->kodiBase, &date, heading.c_str()); | ||
| 251 | } | ||
| 252 | //-------------------------------------------------------------------------- | ||
| 253 | |||
| 254 | //========================================================================== | ||
| 255 | /// | ||
| 256 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 257 | /// @brief Use dialog to get a IP | ||
| 258 | /// | ||
| 259 | /// @param[in,out] ipAddress Overwritten with user input if | ||
| 260 | /// return=true and IP address inserted. | ||
| 261 | /// @param[in] heading Heading to display. | ||
| 262 | /// @return true if successful display and | ||
| 263 | /// user input. false if unsuccessful | ||
| 264 | /// display, no user input, or canceled | ||
| 265 | /// editing. | ||
| 266 | /// | ||
| 267 | inline bool ATTRIBUTE_HIDDEN ShowAndGetIPAddress(std::string& ipAddress, | ||
| 268 | const std::string& heading) | ||
| 269 | { | ||
| 270 | using namespace ::kodi::addon; | ||
| 271 | char* retString = nullptr; | ||
| 272 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_ip_address(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 273 | ipAddress.c_str(), &retString, heading.c_str()); | ||
| 274 | if (retString != nullptr) | ||
| 275 | { | ||
| 276 | ipAddress = retString; | ||
| 277 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 278 | } | ||
| 279 | return ret; | ||
| 280 | } | ||
| 281 | //-------------------------------------------------------------------------- | ||
| 282 | |||
| 283 | //========================================================================== | ||
| 284 | /// | ||
| 285 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 286 | /// @brief Use dialog to get normal number. | ||
| 287 | /// | ||
| 288 | /// @param[in,out] input Overwritten with user input if | ||
| 289 | /// return=true and time in seconds inserted | ||
| 290 | /// @param[in] heading Heading to display | ||
| 291 | /// @param[in] autoCloseTimeoutMs To close the dialog after a specified | ||
| 292 | /// time, in milliseconds, default is 0 | ||
| 293 | /// which keeps the dialog open | ||
| 294 | /// indefinitely. | ||
| 295 | /// @return true if successful display and user | ||
| 296 | /// input. false if unsuccessful display, no | ||
| 297 | /// user input, or canceled editing. | ||
| 298 | /// | ||
| 299 | /// | ||
| 300 | ///------------------------------------------------------------------------- | ||
| 301 | /// | ||
| 302 | /// **Example:** | ||
| 303 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 304 | /// #include <stdio.h> /* printf */ | ||
| 305 | /// #include <stdlib.h> /* strtoull (C++11) */ | ||
| 306 | /// #include <kodi/gui/dialogs/Numeric.h> | ||
| 307 | /// | ||
| 308 | /// std::string number; | ||
| 309 | /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetNumber(number, "Number test call"); | ||
| 310 | /// printf("Written number input is : %llu and was %s\n", | ||
| 311 | /// strtoull(number.c_str(), nullptr, 0), bRet ? "OK" : "Canceled"); | ||
| 312 | /// ~~~~~~~~~~~~~ | ||
| 313 | /// | ||
| 314 | inline bool ATTRIBUTE_HIDDEN ShowAndGetNumber(std::string& input, | ||
| 315 | const std::string& heading, | ||
| 316 | unsigned int autoCloseTimeoutMs = 0) | ||
| 317 | { | ||
| 318 | using namespace ::kodi::addon; | ||
| 319 | char* retString = nullptr; | ||
| 320 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_number(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 321 | input.c_str(), &retString, heading.c_str(), autoCloseTimeoutMs); | ||
| 322 | if (retString != nullptr) | ||
| 323 | { | ||
| 324 | input = retString; | ||
| 325 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 326 | } | ||
| 327 | return ret; | ||
| 328 | } | ||
| 329 | //-------------------------------------------------------------------------- | ||
| 330 | |||
| 331 | //========================================================================== | ||
| 332 | /// | ||
| 333 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 334 | /// @brief Show numeric keypad to get seconds. | ||
| 335 | /// | ||
| 336 | /// @param[in,out] time Overwritten with user input if return=true and | ||
| 337 | /// time in seconds inserted. | ||
| 338 | /// @param[in] heading Heading to display | ||
| 339 | /// @return true if successful display and user input. false | ||
| 340 | /// if unsuccessful display, no user input, or | ||
| 341 | /// canceled editing. | ||
| 342 | /// | ||
| 343 | inline bool ATTRIBUTE_HIDDEN ShowAndGetSeconds(std::string& time, const std::string& heading) | ||
| 344 | { | ||
| 345 | using namespace ::kodi::addon; | ||
| 346 | char* retString = nullptr; | ||
| 347 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_seconds(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 348 | time.c_str(), &retString, heading.c_str()); | ||
| 349 | if (retString != nullptr) | ||
| 350 | { | ||
| 351 | time = retString; | ||
| 352 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 353 | } | ||
| 354 | return ret; | ||
| 355 | } | ||
| 356 | //-------------------------------------------------------------------------- | ||
| 357 | }; | ||
| 358 | /// @} | ||
| 359 | |||
| 360 | } /* namespace dialogs */ | ||
| 361 | } /* namespace gui */ | ||
| 362 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h deleted file mode 100644 index b9a3a0d..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h +++ /dev/null | |||
| @@ -1,99 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../AddonBase.h" | ||
| 12 | #include "../definitions.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_OK Dialog OK | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @{ | ||
| 26 | /// @brief \cpp_namespace{ kodi::gui::dialogs::OK } | ||
| 27 | /// **OK dialog** | ||
| 28 | /// | ||
| 29 | /// The functions listed below permit the call of a dialogue of information, a | ||
| 30 | /// confirmation of the user by press from OK required. | ||
| 31 | /// | ||
| 32 | /// It has the header \ref OK.h "#include <kodi/gui/dialogs/OK.h>" | ||
| 33 | /// be included to enjoy it. | ||
| 34 | /// | ||
| 35 | namespace OK | ||
| 36 | { | ||
| 37 | //========================================================================== | ||
| 38 | /// | ||
| 39 | /// \ingroup cpp_kodi_gui_dialogs_OK | ||
| 40 | /// @brief Use dialog to inform user with text and confirmation with OK with continued string. | ||
| 41 | /// | ||
| 42 | /// @param[in] heading Dialog heading. | ||
| 43 | /// @param[in] text Multi-line text. | ||
| 44 | /// | ||
| 45 | /// | ||
| 46 | ///------------------------------------------------------------------------- | ||
| 47 | /// | ||
| 48 | /// **Example:** | ||
| 49 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 50 | /// #include <kodi/gui/dialogs/OK.h> | ||
| 51 | /// ... | ||
| 52 | /// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!\nI'm a call from add-on\n :) :D"); | ||
| 53 | /// ~~~~~~~~~~~~~ | ||
| 54 | /// | ||
| 55 | inline void ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, const std::string& text) | ||
| 56 | { | ||
| 57 | using namespace ::kodi::addon; | ||
| 58 | CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_single_text( | ||
| 59 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); | ||
| 60 | } | ||
| 61 | //-------------------------------------------------------------------------- | ||
| 62 | |||
| 63 | //========================================================================== | ||
| 64 | /// | ||
| 65 | /// \ingroup cpp_kodi_gui_dialogs_OK | ||
| 66 | /// @brief Use dialog to inform user with text and confirmation with OK with strings separated to the lines. | ||
| 67 | /// | ||
| 68 | /// @param[in] heading Dialog heading. | ||
| 69 | /// @param[in] line0 Line #1 text. | ||
| 70 | /// @param[in] line1 Line #2 text. | ||
| 71 | /// @param[in] line2 Line #3 text. | ||
| 72 | /// | ||
| 73 | /// | ||
| 74 | ///------------------------------------------------------------------------- | ||
| 75 | /// | ||
| 76 | /// **Example:** | ||
| 77 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 78 | /// #include <kodi/gui/dialogs/OK.h> | ||
| 79 | /// ... | ||
| 80 | /// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!", "I'm a call from add-on", " :) :D"); | ||
| 81 | /// ~~~~~~~~~~~~~ | ||
| 82 | /// | ||
| 83 | inline void ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, | ||
| 84 | const std::string& line0, | ||
| 85 | const std::string& line1, | ||
| 86 | const std::string& line2) | ||
| 87 | { | ||
| 88 | using namespace ::kodi::addon; | ||
| 89 | CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 90 | heading.c_str(), line0.c_str(), line1.c_str(), | ||
| 91 | line2.c_str()); | ||
| 92 | } | ||
| 93 | //-------------------------------------------------------------------------- | ||
| 94 | } | ||
| 95 | /// @} | ||
| 96 | |||
| 97 | } /* namespace dialogs */ | ||
| 98 | } /* namespace gui */ | ||
| 99 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h deleted file mode 100644 index 39a98fe..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h +++ /dev/null | |||
| @@ -1,269 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | //============================================================================== | ||
| 15 | /// \defgroup cpp_kodi_vfs_Defs Definitions, structures and enumerators | ||
| 16 | /// \ingroup cpp_kodi_gui_dialogs_Select | ||
| 17 | /// @brief **Dialog Select definition values** | ||
| 18 | //------------------------------------------------------------------------------ | ||
| 19 | |||
| 20 | //============================================================================== | ||
| 21 | /// \ingroup cpp_kodi_vfs_Defs | ||
| 22 | /// @brief **Selection entry structure** | ||
| 23 | /// | ||
| 24 | typedef struct SSelectionEntry | ||
| 25 | { | ||
| 26 | //============================================================================ | ||
| 27 | /// Structure constructor | ||
| 28 | /// | ||
| 29 | /// There becomes selected always set to false. | ||
| 30 | /// | ||
| 31 | SSelectionEntry() = default; | ||
| 32 | //---------------------------------------------------------------------------- | ||
| 33 | |||
| 34 | /// Entry identfication string | ||
| 35 | std::string id; | ||
| 36 | |||
| 37 | /// Entry name to show on GUI dialog | ||
| 38 | std::string name; | ||
| 39 | |||
| 40 | /// Place where entry can be preselected and after return the from user | ||
| 41 | /// selected is set. | ||
| 42 | bool selected = false; | ||
| 43 | } SSelectionEntry; | ||
| 44 | //------------------------------------------------------------------------------ | ||
| 45 | |||
| 46 | namespace kodi | ||
| 47 | { | ||
| 48 | namespace gui | ||
| 49 | { | ||
| 50 | namespace dialogs | ||
| 51 | { | ||
| 52 | |||
| 53 | //============================================================================ | ||
| 54 | /// | ||
| 55 | /// \defgroup cpp_kodi_gui_dialogs_Select Dialog Select | ||
| 56 | /// \ingroup cpp_kodi_gui | ||
| 57 | /// @{ | ||
| 58 | /// @brief \cpp_namespace{ kodi::gui::dialogs::Select } | ||
| 59 | /// **Selection dialog** | ||
| 60 | /// | ||
| 61 | /// The function listed below permits the call of a dialogue to select of an | ||
| 62 | /// entry as a key | ||
| 63 | /// | ||
| 64 | /// It has the header \ref Select.h "#include <kodi/gui/dialogs/Select.h>" | ||
| 65 | /// be included to enjoy it. | ||
| 66 | /// | ||
| 67 | /// | ||
| 68 | namespace Select | ||
| 69 | { | ||
| 70 | //========================================================================== | ||
| 71 | /// | ||
| 72 | /// \ingroup cpp_kodi_gui_dialogs_Select | ||
| 73 | /// @brief Show a selection dialog about given parts. | ||
| 74 | /// | ||
| 75 | /// @param[in] heading Dialog heading name | ||
| 76 | /// @param[in] entries String list about entries | ||
| 77 | /// @param[in] selected [opt] Predefined selection (default is | ||
| 78 | /// <tt>-1</tt> for the first) | ||
| 79 | /// @param[in] autoclose [opt] To close dialog automatic after the given | ||
| 80 | /// time in ms. As '0' it stays open. | ||
| 81 | /// @return The selected entry, if return <tt>-1</tt> was | ||
| 82 | /// nothing selected or canceled | ||
| 83 | /// | ||
| 84 | /// | ||
| 85 | ///------------------------------------------------------------------------- | ||
| 86 | /// | ||
| 87 | /// **Example:** | ||
| 88 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 89 | /// #include <kodi/gui/dialogs/Select.h> | ||
| 90 | /// | ||
| 91 | /// const std::vector<std::string> entries | ||
| 92 | /// { | ||
| 93 | /// "Test 1", | ||
| 94 | /// "Test 2", | ||
| 95 | /// "Test 3", | ||
| 96 | /// "Test 4", | ||
| 97 | /// "Test 5" | ||
| 98 | /// }; | ||
| 99 | /// | ||
| 100 | /// int selected = kodi::gui::dialogs::Select::Show("Test selection", entries, -1); | ||
| 101 | /// if (selected < 0) | ||
| 102 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 103 | /// else | ||
| 104 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 105 | /// ~~~~~~~~~~~~~ | ||
| 106 | /// | ||
| 107 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 108 | const std::vector<std::string>& entries, | ||
| 109 | int selected = -1, | ||
| 110 | unsigned int autoclose = 0) | ||
| 111 | { | ||
| 112 | using namespace ::kodi::addon; | ||
| 113 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 114 | const char** cEntries = (const char**)malloc(size * sizeof(const char**)); | ||
| 115 | for (unsigned int i = 0; i < size; ++i) | ||
| 116 | { | ||
| 117 | cEntries[i] = entries[i].c_str(); | ||
| 118 | } | ||
| 119 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open( | ||
| 120 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected, | ||
| 121 | autoclose); | ||
| 122 | free(cEntries); | ||
| 123 | return ret; | ||
| 124 | } | ||
| 125 | //-------------------------------------------------------------------------- | ||
| 126 | |||
| 127 | //========================================================================== | ||
| 128 | /// | ||
| 129 | /// \ingroup cpp_kodi_gui_dialogs_Select | ||
| 130 | /// @brief Show a selection dialog about given parts. | ||
| 131 | /// | ||
| 132 | /// This function is mostly equal to the other, only becomes the string list | ||
| 133 | /// here done by a SSelectionEntry, where a ID string can be defined. | ||
| 134 | /// | ||
| 135 | /// @param[in] heading Dialog heading name | ||
| 136 | /// @param[in] entries SSelectionEntry list about entries | ||
| 137 | /// @param[in] selected [opt] Predefined selection (default is | ||
| 138 | /// <tt>-1</tt> for the first) | ||
| 139 | /// @param[in] autoclose [opt] To close dialog automatic after the given | ||
| 140 | /// time in ms. As '0' it stays open. | ||
| 141 | /// @return The selected entry, if return <tt>-1</tt> was | ||
| 142 | /// nothing selected or canceled | ||
| 143 | /// | ||
| 144 | /// | ||
| 145 | ///------------------------------------------------------------------------- | ||
| 146 | /// | ||
| 147 | /// **Example:** | ||
| 148 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 149 | /// #include <kodi/gui/dialogs/Select.h> | ||
| 150 | /// | ||
| 151 | /// std::vector<SSelectionEntry> entries | ||
| 152 | /// { | ||
| 153 | /// { "ID 1", "Test 1", false }, | ||
| 154 | /// { "ID 2", "Test 2", false }, | ||
| 155 | /// { "ID 3", "Test 3", false }, | ||
| 156 | /// { "ID 4", "Test 4", false }, | ||
| 157 | /// { "ID 5", "Test 5", false } | ||
| 158 | /// }; | ||
| 159 | /// | ||
| 160 | /// int selected = kodi::gui::dialogs::Select::Show("Test selection", entries, -1); | ||
| 161 | /// if (selected < 0) | ||
| 162 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 163 | /// else | ||
| 164 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 165 | /// ~~~~~~~~~~~~~ | ||
| 166 | /// | ||
| 167 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 168 | std::vector<SSelectionEntry>& entries, | ||
| 169 | int selected = -1, | ||
| 170 | unsigned int autoclose = 0) | ||
| 171 | { | ||
| 172 | using namespace ::kodi::addon; | ||
| 173 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 174 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char*))); | ||
| 175 | for (unsigned int i = 0; i < size; ++i) | ||
| 176 | { | ||
| 177 | cEntries[i] = entries[i].name.c_str(); | ||
| 178 | if (selected == -1 && entries[i].selected) | ||
| 179 | selected = i; | ||
| 180 | } | ||
| 181 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), | ||
| 182 | cEntries, size, selected, autoclose); | ||
| 183 | if (ret >= 0) | ||
| 184 | { | ||
| 185 | entries[ret].selected = true; | ||
| 186 | } | ||
| 187 | free(cEntries); | ||
| 188 | return ret; | ||
| 189 | } | ||
| 190 | //-------------------------------------------------------------------------- | ||
| 191 | |||
| 192 | //========================================================================== | ||
| 193 | /// | ||
| 194 | /// \ingroup cpp_kodi_gui_dialogs_Select | ||
| 195 | /// @brief Show a multiple selection dialog about given parts. | ||
| 196 | /// | ||
| 197 | /// @param[in] heading Dialog heading name | ||
| 198 | /// @param[in] entries SSelectionEntry list about entries | ||
| 199 | /// @param[in] autoclose [opt] To close dialog automatic after the given | ||
| 200 | /// time in ms. As '0' it stays open. | ||
| 201 | /// @return The selected entries, if return <tt>empty</tt> was | ||
| 202 | /// nothing selected or canceled | ||
| 203 | /// | ||
| 204 | /// With selected on SSelectionEntry can be a pre selection defined. | ||
| 205 | /// | ||
| 206 | ///------------------------------------------------------------------------- | ||
| 207 | /// | ||
| 208 | /// **Example:** | ||
| 209 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 210 | /// #include <kodi/gui/dialogs/Select.h> | ||
| 211 | /// | ||
| 212 | /// std::vector<SSelectionEntry> entries | ||
| 213 | /// { | ||
| 214 | /// { "ID 1", "Test 1", false }, | ||
| 215 | /// { "ID 2", "Test 2", false }, | ||
| 216 | /// { "ID 3", "Test 3", false }, | ||
| 217 | /// { "ID 4", "Test 4", false }, | ||
| 218 | /// { "ID 5", "Test 5", false } | ||
| 219 | /// }; | ||
| 220 | /// | ||
| 221 | /// bool ret = kodi::gui::dialogs::Select::ShowMultiSelect("Test selection", entries); | ||
| 222 | /// if (!ret) | ||
| 223 | /// fprintf(stderr, "Selection canceled\n"); | ||
| 224 | /// else | ||
| 225 | /// { | ||
| 226 | /// fprintf(stderr, "Selected items:\n"); | ||
| 227 | /// for (const auto& entry : entries) | ||
| 228 | /// { | ||
| 229 | /// if (entry.selected) | ||
| 230 | /// fprintf(stderr, " - %s\n", entry.selected.id.c_str()); | ||
| 231 | /// } | ||
| 232 | /// } | ||
| 233 | /// ~~~~~~~~~~~~~ | ||
| 234 | /// | ||
| 235 | inline bool ATTRIBUTE_HIDDEN ShowMultiSelect(const std::string& heading, | ||
| 236 | std::vector<SSelectionEntry>& entries, | ||
| 237 | int autoclose = 0) | ||
| 238 | { | ||
| 239 | using namespace ::kodi::addon; | ||
| 240 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 241 | const char** cEntryIDs = static_cast<const char**>(malloc(size*sizeof(const char*))); | ||
| 242 | const char** cEntryNames = static_cast<const char**>(malloc(size*sizeof(const char*))); | ||
| 243 | bool* cEntriesSelected = static_cast<bool*>(malloc(size*sizeof(bool))); | ||
| 244 | for (unsigned int i = 0; i < size; ++i) | ||
| 245 | { | ||
| 246 | cEntryIDs[i] = entries[i].id.c_str(); | ||
| 247 | cEntryNames[i] = entries[i].name.c_str(); | ||
| 248 | cEntriesSelected[i] = entries[i].selected; | ||
| 249 | } | ||
| 250 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open_multi_select(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 251 | heading.c_str(), cEntryIDs, cEntryNames, | ||
| 252 | cEntriesSelected, size, autoclose); | ||
| 253 | if (ret) | ||
| 254 | { | ||
| 255 | for (unsigned int i = 0; i < size; ++i) | ||
| 256 | entries[i].selected = cEntriesSelected[i]; | ||
| 257 | } | ||
| 258 | free(cEntryNames); | ||
| 259 | free(cEntryIDs); | ||
| 260 | free(cEntriesSelected); | ||
| 261 | return ret; | ||
| 262 | } | ||
| 263 | //-------------------------------------------------------------------------- | ||
| 264 | }; | ||
| 265 | /// @} | ||
| 266 | |||
| 267 | } /* namespace dialogs */ | ||
| 268 | } /* namespace gui */ | ||
| 269 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h deleted file mode 100644 index 5c81837..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h +++ /dev/null | |||
| @@ -1,108 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2015-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_TextViewer Dialog Text Viewer | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @{ | ||
| 26 | /// @brief \cpp_namespace{ kodi::gui::dialogs::TextViewer } | ||
| 27 | /// **Text viewer dialog** | ||
| 28 | /// | ||
| 29 | /// The text viewer dialog can be used to display descriptions, help texts or | ||
| 30 | /// other larger texts. | ||
| 31 | /// | ||
| 32 | /// In order to achieve a line break is a <b>\\n</b> directly in the text or | ||
| 33 | /// in the <em>"./resources/language/resource.language.??_??/strings.po"</em> | ||
| 34 | /// to call with <b>std::string kodi::general::GetLocalizedString(...);</b>. | ||
| 35 | /// | ||
| 36 | /// It has the header \ref TextViewer.h "#include <kodi/gui/dialogs/TextViewer.h>" | ||
| 37 | /// be included to enjoy it. | ||
| 38 | /// | ||
| 39 | namespace TextViewer | ||
| 40 | { | ||
| 41 | //========================================================================== | ||
| 42 | /// | ||
| 43 | /// \ingroup cpp_kodi_gui_dialogs_TextViewer | ||
| 44 | /// @brief Show info text dialog | ||
| 45 | /// | ||
| 46 | /// @param[in] heading Small heading text | ||
| 47 | /// @param[in] text Showed text on dialog | ||
| 48 | /// | ||
| 49 | /// | ||
| 50 | ///------------------------------------------------------------------------- | ||
| 51 | /// | ||
| 52 | /// **Example:** | ||
| 53 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 54 | /// #include <kodi/gui/dialogs/TextViewer.h> | ||
| 55 | /// | ||
| 56 | /// kodi::gui::dialogs::TextViewer::Show("The Wizard of Oz (1939 film)", | ||
| 57 | /// "The Wizard of Oz is a 1939 American musical comedy-drama fantasy film " | ||
| 58 | /// "produced by Metro-Goldwyn-Mayer, and the most well-known and commercially " | ||
| 59 | /// "successful adaptation based on the 1900 novel The Wonderful Wizard of Oz " | ||
| 60 | /// "by L. Frank Baum. The film stars Judy Garland as Dorothy Gale. The film" | ||
| 61 | /// "co-stars Terry the dog, billed as Toto; Ray Bolger, Jack Haley, Bert Lahr, " | ||
| 62 | /// "Frank Morgan, Billie Burke, Margaret Hamilton, with Charley Grapewin and " | ||
| 63 | /// "Clara Blandick, and the Singer Midgets as the Munchkins.\n" | ||
| 64 | /// "\n" | ||
| 65 | /// "Notable for its use of Technicolor, fantasy storytelling, musical score and " | ||
| 66 | /// "unusual characters, over the years it has become an icon of American popular " | ||
| 67 | /// "culture. It was nominated for six Academy Awards, including Best Picture but " | ||
| 68 | /// "lost to Gone with the Wind. It did win in two other categories including Best " | ||
| 69 | /// "Original Song for \"Over the Rainbow\". However, the film was a box office " | ||
| 70 | /// "disappointment on its initial release, earning only $3,017,000 on a $2,777,000 " | ||
| 71 | /// "budget, despite receiving largely positive reviews. It was MGM's most " | ||
| 72 | /// "expensive production at that time, and did not completely recoup the studio's " | ||
| 73 | /// "investment and turn a profit until theatrical re-releases starting in 1949.\n" | ||
| 74 | /// "\n" | ||
| 75 | /// "The 1956 broadcast television premiere of the film on CBS re-introduced the " | ||
| 76 | /// "film to the wider public and eventually made the presentation an annual " | ||
| 77 | /// "tradition, making it one of the most known films in cinema history. The " | ||
| 78 | /// "film was named the most-viewed motion picture on television syndication by " | ||
| 79 | /// "the Library of Congress who also included the film in its National Film " | ||
| 80 | /// "Registry in its inaugural year in 1989. Designation on the registry calls " | ||
| 81 | /// "for efforts to preserve it for being \"culturally, historically, and " | ||
| 82 | /// "aesthetically significant\". It is also one of the few films on UNESCO's " | ||
| 83 | /// "Memory of the World Register.\n" | ||
| 84 | /// "\n" | ||
| 85 | /// "The Wizard of Oz is often ranked on best-movie lists in critics' and public " | ||
| 86 | /// "polls. It is the source of many quotes referenced in modern popular culture. " | ||
| 87 | /// "It was directed primarily by Victor Fleming (who left production to take " | ||
| 88 | /// "over direction on the troubled Gone with the Wind production). Noel Langley, " | ||
| 89 | /// "Florence Ryerson and Edgar Allan Woolf received credit for the screenplay, " | ||
| 90 | /// "but there were uncredited contributions by others. The songs were written " | ||
| 91 | /// "by Edgar \"Yip\" Harburg (lyrics) and Harold Arlen (music). The incidental " | ||
| 92 | /// "music, based largely on the songs, was composed by Herbert Stothart, with " | ||
| 93 | /// "interspersed renderings from classical composers.\n"); | ||
| 94 | /// ~~~~~~~~~~~~~ | ||
| 95 | /// | ||
| 96 | inline void ATTRIBUTE_HIDDEN Show(const std::string& heading, const std::string& text) | ||
| 97 | { | ||
| 98 | using namespace ::kodi::addon; | ||
| 99 | CAddonBase::m_interface->toKodi->kodi_gui->dialogTextViewer->open( | ||
| 100 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); | ||
| 101 | } | ||
| 102 | //-------------------------------------------------------------------------- | ||
| 103 | }; | ||
| 104 | /// @} | ||
| 105 | |||
| 106 | } /* namespace dialogs */ | ||
| 107 | } /* namespace gui */ | ||
| 108 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h deleted file mode 100644 index 67c2fc4..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h +++ /dev/null | |||
| @@ -1,188 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_YesNo Dialog Yes/No | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @{ | ||
| 26 | /// @brief \cpp_namespace{ kodi::gui::dialogs::YesNo } | ||
| 27 | /// **Yes / No dialog** | ||
| 28 | /// | ||
| 29 | /// The Yes / No dialog can be used to inform the user about questions and get | ||
| 30 | /// the answer. | ||
| 31 | /// | ||
| 32 | /// In order to achieve a line break is a <b>\\n</b> directly in the text or | ||
| 33 | /// in the <em>"./resources/language/resource.language.??_??/strings.po"</em> | ||
| 34 | /// to call with <b>std::string kodi::general::GetLocalizedString(...);</b>. | ||
| 35 | /// | ||
| 36 | /// It has the header \ref YesNo.h "#include <kodi/gui/dialogs/YesNo.h>" | ||
| 37 | /// be included to enjoy it. | ||
| 38 | /// | ||
| 39 | /// | ||
| 40 | namespace YesNo | ||
| 41 | { | ||
| 42 | //========================================================================== | ||
| 43 | /// | ||
| 44 | /// \ingroup cpp_kodi_gui_dialogs_YesNo | ||
| 45 | /// @brief Use dialog to get numeric new password with one text string shown | ||
| 46 | /// everywhere and cancel return field | ||
| 47 | /// | ||
| 48 | /// @param[in] heading Dialog heading | ||
| 49 | /// @param[in] text Multi-line text | ||
| 50 | /// @param[out] canceled Return value about cancel button | ||
| 51 | /// @param[in] noLabel [opt] label to put on the no button | ||
| 52 | /// @param[in] yesLabel [opt] label to put on the yes button | ||
| 53 | /// @return Returns True if 'Yes' was pressed, else False | ||
| 54 | /// | ||
| 55 | /// @note It is preferred to only use this as it is actually a multi-line text. | ||
| 56 | /// | ||
| 57 | /// | ||
| 58 | ///------------------------------------------------------------------------- | ||
| 59 | /// | ||
| 60 | /// **Example:** | ||
| 61 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 62 | /// #include <kodi/gui/dialogs/YesNo.h> | ||
| 63 | /// | ||
| 64 | /// bool canceled; | ||
| 65 | /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( | ||
| 66 | /// "Yes / No test call", /* The Header */ | ||
| 67 | /// "You has opened Yes / No dialog for test\n\nIs this OK for you?", | ||
| 68 | /// canceled, /* return value about cancel button */ | ||
| 69 | /// "Not really", /* No label, is optional and if empty "No" */ | ||
| 70 | /// "Ohhh yes"); /* Yes label, also optional and if empty "Yes" */ | ||
| 71 | /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", | ||
| 72 | /// ret ? "yes" : "no", | ||
| 73 | /// canceled ? "canceled" : "not canceled"); | ||
| 74 | /// ~~~~~~~~~~~~~ | ||
| 75 | /// | ||
| 76 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, | ||
| 77 | const std::string& text, | ||
| 78 | bool& canceled, | ||
| 79 | const std::string& noLabel = "", | ||
| 80 | const std::string& yesLabel = "") | ||
| 81 | { | ||
| 82 | using namespace ::kodi::addon; | ||
| 83 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_single_text( | ||
| 84 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str(), &canceled, | ||
| 85 | noLabel.c_str(), yesLabel.c_str()); | ||
| 86 | } | ||
| 87 | //-------------------------------------------------------------------------- | ||
| 88 | |||
| 89 | //========================================================================== | ||
| 90 | /// | ||
| 91 | /// \ingroup cpp_kodi_gui_dialogs_YesNo | ||
| 92 | /// @brief Use dialog to get numeric new password with separated line strings | ||
| 93 | /// | ||
| 94 | /// @param[in] heading Dialog heading | ||
| 95 | /// @param[in] line0 Line #0 text | ||
| 96 | /// @param[in] line1 Line #1 text | ||
| 97 | /// @param[in] line2 Line #2 text | ||
| 98 | /// @param[in] noLabel [opt] label to put on the no button. | ||
| 99 | /// @param[in] yesLabel [opt] label to put on the yes button. | ||
| 100 | /// @return Returns True if 'Yes' was pressed, else False. | ||
| 101 | /// | ||
| 102 | /// | ||
| 103 | ///------------------------------------------------------------------------- | ||
| 104 | /// | ||
| 105 | /// **Example:** | ||
| 106 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 107 | /// #include <kodi/gui/dialogs/YesNo.h> | ||
| 108 | /// | ||
| 109 | /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( | ||
| 110 | /// "Yes / No test call", // The Header | ||
| 111 | /// "You has opened Yes / No dialog for test", | ||
| 112 | /// "", | ||
| 113 | /// "Is this OK for you?", | ||
| 114 | /// "Not really", // No label, is optional and if empty "No" | ||
| 115 | /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" | ||
| 116 | /// fprintf(stderr, "You has called Yes/No, returned '%s'\n", | ||
| 117 | /// ret ? "yes" : "no"); | ||
| 118 | /// ~~~~~~~~~~~~~ | ||
| 119 | /// | ||
| 120 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, | ||
| 121 | const std::string& line0, | ||
| 122 | const std::string& line1, | ||
| 123 | const std::string& line2, | ||
| 124 | const std::string& noLabel = "", | ||
| 125 | const std::string& yesLabel = "") | ||
| 126 | { | ||
| 127 | using namespace ::kodi::addon; | ||
| 128 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 129 | heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), | ||
| 130 | noLabel.c_str(), yesLabel.c_str()); | ||
| 131 | } | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_dialogs_YesNo | ||
| 137 | /// @brief Use dialog to get numeric new password with separated line strings and cancel return field | ||
| 138 | /// | ||
| 139 | /// @param[in] heading Dialog heading | ||
| 140 | /// @param[in] line0 Line #0 text | ||
| 141 | /// @param[in] line1 Line #1 text | ||
| 142 | /// @param[in] line2 Line #2 text | ||
| 143 | /// @param[out] canceled Return value about cancel button | ||
| 144 | /// @param[in] noLabel [opt] label to put on the no button | ||
| 145 | /// @param[in] yesLabel [opt] label to put on the yes button | ||
| 146 | /// @return Returns True if 'Yes' was pressed, else False | ||
| 147 | /// | ||
| 148 | /// | ||
| 149 | ///------------------------------------------------------------------------- | ||
| 150 | /// | ||
| 151 | /// **Example:** | ||
| 152 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 153 | /// #include <kodi/gui/dialogs/YesNo.h> | ||
| 154 | /// | ||
| 155 | /// bool canceled; | ||
| 156 | /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( | ||
| 157 | /// "Yes / No test call", // The Header | ||
| 158 | /// "You has opened Yes / No dialog for test", | ||
| 159 | /// "", | ||
| 160 | /// "Is this OK for you?", | ||
| 161 | /// canceled, // return value about cancel button | ||
| 162 | /// "Not really", // No label, is optional and if empty "No" | ||
| 163 | /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" | ||
| 164 | /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", | ||
| 165 | /// ret ? "yes" : "no", | ||
| 166 | /// canceled ? "canceled" : "not canceled"); | ||
| 167 | /// ~~~~~~~~~~~~~ | ||
| 168 | /// | ||
| 169 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, | ||
| 170 | const std::string& line0, | ||
| 171 | const std::string& line1, | ||
| 172 | const std::string& line2, | ||
| 173 | bool& canceled, | ||
| 174 | const std::string& noLabel = "", | ||
| 175 | const std::string& yesLabel = "") | ||
| 176 | { | ||
| 177 | using namespace ::kodi::addon; | ||
| 178 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_button_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 179 | heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), | ||
| 180 | &canceled, noLabel.c_str(), yesLabel.c_str()); | ||
| 181 | } | ||
| 182 | //-------------------------------------------------------------------------- | ||
| 183 | }; | ||
| 184 | /// @} | ||
| 185 | |||
| 186 | } /* namespace dialogs */ | ||
| 187 | } /* namespace gui */ | ||
| 188 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/CMakeLists.txt deleted file mode 100644 index 939585c..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/CMakeLists.txt +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | set(HEADERS DllHelper.h ) | ||
| 2 | |||
| 3 | if(NOT ENABLE_STATIC_LIBS) | ||
| 4 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_tools) | ||
| 5 | endif() | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/AddonBase.h b/xbmc/addons/kodi-dev-kit/include/kodi/AddonBase.h index b0fddda..6ab4159 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/AddonBase.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/AddonBase.h | |||
| @@ -12,15 +12,20 @@ | |||
| 12 | #include "versions.h" | 12 | #include "versions.h" |
| 13 | 13 | ||
| 14 | #include <assert.h> /* assert */ | 14 | #include <assert.h> /* assert */ |
| 15 | #include <stdarg.h> /* va_list, va_start, va_arg, va_end */ | ||
| 16 | |||
| 17 | #ifdef __cplusplus | ||
| 18 | |||
| 15 | #include <cstdlib> | 19 | #include <cstdlib> |
| 16 | #include <cstring> | 20 | #include <cstring> |
| 17 | #include <ctime> | 21 | #include <ctime> |
| 18 | #include <memory> | 22 | #include <memory> |
| 19 | #include <stdarg.h> /* va_list, va_start, va_arg, va_end */ | ||
| 20 | #include <stdexcept> | 23 | #include <stdexcept> |
| 21 | #include <string> | 24 | #include <string> |
| 22 | #include <vector> | 25 | #include <vector> |
| 23 | 26 | ||
| 27 | #include "tools/StringUtils.h" | ||
| 28 | |||
| 24 | namespace kodi | 29 | namespace kodi |
| 25 | { | 30 | { |
| 26 | 31 | ||
| @@ -30,6 +35,34 @@ struct IRenderHelper; | |||
| 30 | } // namespace gui | 35 | } // namespace gui |
| 31 | 36 | ||
| 32 | //============================================================================== | 37 | //============================================================================== |
| 38 | /// @ingroup cpp_kodi_Defs | ||
| 39 | /// @defgroup cpp_kodi_Defs_HardwareContext using HardwareContext | ||
| 40 | /// @brief **Hardware specific device context**\n | ||
| 41 | /// This defines an independent value which is used for hardware and OS specific | ||
| 42 | /// values. | ||
| 43 | /// | ||
| 44 | /// This is basically a simple pointer which has to be changed to the desired | ||
| 45 | /// format at the corresponding places using <b>`static_cast<...>(...)`</b>. | ||
| 46 | /// | ||
| 47 | /// | ||
| 48 | ///------------------------------------------------------------------------- | ||
| 49 | /// | ||
| 50 | /// **Example:** | ||
| 51 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 52 | /// #include <d3d11_1.h> | ||
| 53 | /// .. | ||
| 54 | /// // Note: Device() there is used inside addon child class about | ||
| 55 | /// // kodi::addon::CInstanceVisualization | ||
| 56 | /// ID3D11DeviceContext1* context = static_cast<ID3D11DeviceContext1*>(kodi::addon::CInstanceVisualization::Device()); | ||
| 57 | /// .. | ||
| 58 | /// ~~~~~~~~~~~~~ | ||
| 59 | /// | ||
| 60 | ///@{ | ||
| 61 | using HardwareContext = ADDON_HARDWARE_CONTEXT; | ||
| 62 | ///@} | ||
| 63 | //------------------------------------------------------------------------------ | ||
| 64 | |||
| 65 | //============================================================================== | ||
| 33 | /// @ingroup cpp_kodi_addon_addonbase_Defs | 66 | /// @ingroup cpp_kodi_addon_addonbase_Defs |
| 34 | /// @defgroup cpp_kodi_addon_addonbase_Defs_CSettingValue class CSettingValue | 67 | /// @defgroup cpp_kodi_addon_addonbase_Defs_CSettingValue class CSettingValue |
| 35 | /// @brief Inside addon main instance used helper class to give settings value. | 68 | /// @brief Inside addon main instance used helper class to give settings value. |
| @@ -391,13 +424,13 @@ public: | |||
| 391 | /// { | 424 | /// { |
| 392 | /// if (instanceType == ADDON_INSTANCE_SCREENSAVER) | 425 | /// if (instanceType == ADDON_INSTANCE_SCREENSAVER) |
| 393 | /// { | 426 | /// { |
| 394 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my Screensaver"); | 427 | /// kodi::Log(ADDON_LOG_INFO, "Creating my Screensaver"); |
| 395 | /// addonInstance = new CMyScreensaver(instance); | 428 | /// addonInstance = new CMyScreensaver(instance); |
| 396 | /// return ADDON_STATUS_OK; | 429 | /// return ADDON_STATUS_OK; |
| 397 | /// } | 430 | /// } |
| 398 | /// else if (instanceType == ADDON_INSTANCE_VISUALIZATION) | 431 | /// else if (instanceType == ADDON_INSTANCE_VISUALIZATION) |
| 399 | /// { | 432 | /// { |
| 400 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my Visualization"); | 433 | /// kodi::Log(ADDON_LOG_INFO, "Creating my Visualization"); |
| 401 | /// addonInstance = new CMyVisualization(instance); | 434 | /// addonInstance = new CMyVisualization(instance); |
| 402 | /// return ADDON_STATUS_OK; | 435 | /// return ADDON_STATUS_OK; |
| 403 | /// } | 436 | /// } |
| @@ -664,13 +697,12 @@ inline void ATTRIBUTE_HIDDEN Log(const AddonLog loglevel, const char* format, .. | |||
| 664 | { | 697 | { |
| 665 | using namespace kodi::addon; | 698 | using namespace kodi::addon; |
| 666 | 699 | ||
| 667 | char buffer[16384]; | ||
| 668 | va_list args; | 700 | va_list args; |
| 669 | va_start(args, format); | 701 | va_start(args, format); |
| 670 | vsnprintf(buffer, sizeof(buffer), format, args); | 702 | const std::string str = kodi::tools::StringUtils::FormatV(format, args); |
| 671 | va_end(args); | 703 | va_end(args); |
| 672 | CAddonBase::m_interface->toKodi->addon_log_msg(CAddonBase::m_interface->toKodi->kodiBase, | 704 | CAddonBase::m_interface->toKodi->addon_log_msg(CAddonBase::m_interface->toKodi->kodiBase, |
| 673 | loglevel, buffer); | 705 | loglevel, str.c_str()); |
| 674 | } | 706 | } |
| 675 | //------------------------------------------------------------------------------ | 707 | //------------------------------------------------------------------------------ |
| 676 | 708 | ||
| @@ -1286,3 +1318,5 @@ inline void* GetInterface(const std::string& name, const std::string& version) | |||
| 1286 | return kodi::addon::GetTypeMinVersion(type); \ | 1318 | return kodi::addon::GetTypeMinVersion(type); \ |
| 1287 | } \ | 1319 | } \ |
| 1288 | AddonGlobalInterface* kodi::addon::CAddonBase::m_interface = nullptr; | 1320 | AddonGlobalInterface* kodi::addon::CAddonBase::m_interface = nullptr; |
| 1321 | |||
| 1322 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/AudioEngine.h b/xbmc/addons/kodi-dev-kit/include/kodi/AudioEngine.h index 0cfefac..36d1dd1 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/AudioEngine.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/AudioEngine.h | |||
| @@ -98,7 +98,7 @@ namespace audioengine | |||
| 98 | /// With the help of this format information, Kodi adjusts its processing | 98 | /// With the help of this format information, Kodi adjusts its processing |
| 99 | /// accordingly. | 99 | /// accordingly. |
| 100 | /// | 100 | /// |
| 101 | //@{ | 101 | ///@{ |
| 102 | class ATTRIBUTE_HIDDEN AudioEngineFormat | 102 | class ATTRIBUTE_HIDDEN AudioEngineFormat |
| 103 | : public addon::CStructHdl<AudioEngineFormat, AUDIO_ENGINE_FORMAT> | 103 | : public addon::CStructHdl<AudioEngineFormat, AUDIO_ENGINE_FORMAT> |
| 104 | { | 104 | { |
| @@ -139,7 +139,7 @@ public: | |||
| 139 | 139 | ||
| 140 | /// @addtogroup cpp_kodi_audioengine_Defs_AudioEngineFormat | 140 | /// @addtogroup cpp_kodi_audioengine_Defs_AudioEngineFormat |
| 141 | /// @copydetails cpp_kodi_audioengine_Defs_AudioEngineFormat_Help | 141 | /// @copydetails cpp_kodi_audioengine_Defs_AudioEngineFormat_Help |
| 142 | //@{ | 142 | ///@{ |
| 143 | 143 | ||
| 144 | /// @brief The stream's data format (eg, AUDIOENGINE_FMT_S16LE) | 144 | /// @brief The stream's data format (eg, AUDIOENGINE_FMT_S16LE) |
| 145 | void SetDataFormat(enum AudioEngineDataFormat format) { m_cStructure->m_dataFormat = format; } | 145 | void SetDataFormat(enum AudioEngineDataFormat format) { m_cStructure->m_dataFormat = format; } |
| @@ -228,8 +228,9 @@ public: | |||
| 228 | 228 | ||
| 229 | return true; | 229 | return true; |
| 230 | } | 230 | } |
| 231 | ///@} | ||
| 231 | }; | 232 | }; |
| 232 | //@} | 233 | ///@} |
| 233 | //---------------------------------------------------------------------------- | 234 | //---------------------------------------------------------------------------- |
| 234 | 235 | ||
| 235 | //}}} | 236 | //}}} |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/CMakeLists.txt index de7cb3e..d37078a 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/CMakeLists.txt +++ b/xbmc/addons/kodi-dev-kit/include/kodi/CMakeLists.txt | |||
| @@ -12,5 +12,5 @@ if(CORE_SYSTEM_NAME STREQUAL android) | |||
| 12 | endif() | 12 | endif() |
| 13 | 13 | ||
| 14 | if(NOT ENABLE_STATIC_LIBS) | 14 | if(NOT ENABLE_STATIC_LIBS) |
| 15 | core_add_library(addons_kodi-addon-dev-kit_include_kodi) | 15 | core_add_library(addons_kodi-dev-kit_include_kodi) |
| 16 | endif() | 16 | endif() |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h b/xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h index 2054ce6..1cf05fe 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h | |||
| @@ -110,12 +110,18 @@ public: | |||
| 110 | /// | Name | Type | Set call | Get call | 110 | /// | Name | Type | Set call | Get call |
| 111 | /// |------|------|----------|---------- | 111 | /// |------|------|----------|---------- |
| 112 | /// | **ID of device containing file** | `uint32_t` | @ref FileStatus::SetDeviceId "SetDeviceId" | @ref FileStatus::GetDeviceId "GetDeviceId" | 112 | /// | **ID of device containing file** | `uint32_t` | @ref FileStatus::SetDeviceId "SetDeviceId" | @ref FileStatus::GetDeviceId "GetDeviceId" |
| 113 | /// | **Represent file serial numbers** | `uint64_t` | @ref FileStatus::SetFileSerialNumber "SetFileSerialNumber" | @ref FileStatus::GetFileSerialNumber "GetFileSerialNumber" | ||
| 113 | /// | **Total size, in bytes** | `uint64_t` | @ref FileStatus::SetSize "SetSize" | @ref FileStatus::GetSize "GetSize" | 114 | /// | **Total size, in bytes** | `uint64_t` | @ref FileStatus::SetSize "SetSize" | @ref FileStatus::GetSize "GetSize" |
| 114 | /// | **Time of last access** | `time_t` | @ref FileStatus::SetAccessTime "SetAccessTime" | @ref FileStatus::GetAccessTime "GetAccessTime" | 115 | /// | **Time of last access** | `time_t` | @ref FileStatus::SetAccessTime "SetAccessTime" | @ref FileStatus::GetAccessTime "GetAccessTime" |
| 115 | /// | **Time of last modification** | `time_t` | @ref FileStatus::SetModificationTime "SetModificationTime" | @ref FileStatus::GetModificationTime "GetModificationTime" | 116 | /// | **Time of last modification** | `time_t` | @ref FileStatus::SetModificationTime "SetModificationTime" | @ref FileStatus::GetModificationTime "GetModificationTime" |
| 116 | /// | **Time of last status change** | `time_t` | @ref FileStatus::SetStatusTime "SetStatusTime" | @ref FileStatus::GetStatusTime "GetStatusTime" | 117 | /// | **Time of last status change** | `time_t` | @ref FileStatus::SetStatusTime "SetStatusTime" | @ref FileStatus::GetStatusTime "GetStatusTime" |
| 117 | /// | **Stat url is a directory** | `bool` | @ref FileStatus::SetIsDirectory "SetIsDirectory" | @ref FileStatus::GetIsDirectory "GetIsDirectory" | 118 | /// | **Stat url is a directory** | `bool` | @ref FileStatus::SetIsDirectory "SetIsDirectory" | @ref FileStatus::GetIsDirectory "GetIsDirectory" |
| 118 | /// | **Stat url as a symbolic link** | `bool` | @ref FileStatus::SetIsSymLink "SetIsSymLink" | @ref FileStatus::GetIsSymLink "GetIsSymLink" | 119 | /// | **Stat url as a symbolic link** | `bool` | @ref FileStatus::SetIsSymLink "SetIsSymLink" | @ref FileStatus::GetIsSymLink "GetIsSymLink" |
| 120 | /// | **Stat url as a block special** | `bool` | @ref FileStatus::SetIsBlock "SetIsBlock" | @ref FileStatus::GetIsBlock "GetIsBlock" | ||
| 121 | /// | **Stat url as a character special** | `bool` | @ref FileStatus::SetIsCharacter "SetIsCharacter" | @ref FileStatus::GetIsCharacter "GetIsCharacter" | ||
| 122 | /// | **Stat url as a FIFO special** | `bool` | @ref FileStatus::SetIsFifo "SetIsFifo" | @ref FileStatus::GetIsFifo "GetIsFifo" | ||
| 123 | /// | **Stat url as a regular** | `bool` | @ref FileStatus::SetIsRegular "SetIsRegular" | @ref FileStatus::GetIsRegular "GetIsRegular" | ||
| 124 | /// | **Stat url as a socket** | `bool` | @ref FileStatus::SetIsSocket "SetIsSocket" | @ref FileStatus::GetIsSocket "GetIsSocket" | ||
| 119 | /// | 125 | /// |
| 120 | 126 | ||
| 121 | /// @addtogroup cpp_kodi_vfs_Defs_FileStatus | 127 | /// @addtogroup cpp_kodi_vfs_Defs_FileStatus |
| @@ -128,6 +134,12 @@ public: | |||
| 128 | /// @brief Get ID of device containing file. | 134 | /// @brief Get ID of device containing file. |
| 129 | uint32_t GetDeviceId() const { return m_cStructure->deviceId; } | 135 | uint32_t GetDeviceId() const { return m_cStructure->deviceId; } |
| 130 | 136 | ||
| 137 | /// @brief Set the file serial number, which distinguishes this file from all other files on the same device. | ||
| 138 | void SetFileSerialNumber(uint64_t fileSerialNumber) { m_cStructure->fileSerialNumber = fileSerialNumber; } | ||
| 139 | |||
| 140 | /// @brief Get the file serial number, which distinguishes this file from all other files on the same device. | ||
| 141 | uint64_t GetFileSerialNumber() const { return m_cStructure->fileSerialNumber; } | ||
| 142 | |||
| 131 | /// @brief Set total size, in bytes. | 143 | /// @brief Set total size, in bytes. |
| 132 | void SetSize(uint64_t size) { m_cStructure->size = size; } | 144 | void SetSize(uint64_t size) { m_cStructure->size = size; } |
| 133 | 145 | ||
| @@ -167,6 +179,35 @@ public: | |||
| 167 | /// @brief Get stat url is a symbolic link. | 179 | /// @brief Get stat url is a symbolic link. |
| 168 | bool GetIsSymLink() const { return m_cStructure->isSymLink; } | 180 | bool GetIsSymLink() const { return m_cStructure->isSymLink; } |
| 169 | 181 | ||
| 182 | /// @brief Set stat url as a block special. | ||
| 183 | void SetIsBlock(bool isBlock) { m_cStructure->isBlock = isBlock; } | ||
| 184 | |||
| 185 | /// @brief Get stat url is a block special. | ||
| 186 | bool GetIsBlock() const { return m_cStructure->isBlock; } | ||
| 187 | |||
| 188 | /// @brief Set stat url as a character special. | ||
| 189 | void SetIsCharacter(bool isCharacter) { m_cStructure->isCharacter = isCharacter; } | ||
| 190 | |||
| 191 | /// @brief Get stat url is a character special. | ||
| 192 | bool GetIsCharacter() const { return m_cStructure->isCharacter; } | ||
| 193 | |||
| 194 | /// @brief Set stat url as a FIFO special. | ||
| 195 | void SetIsFifo(bool isFifo) { m_cStructure->isFifo = isFifo; } | ||
| 196 | |||
| 197 | /// @brief Get stat url is a FIFO special. | ||
| 198 | bool GetIsFifo() const { return m_cStructure->isFifo; } | ||
| 199 | |||
| 200 | /// @brief Set stat url as a regular. | ||
| 201 | void SetIsRegular(bool isRegular) { m_cStructure->isRegular = isRegular; } | ||
| 202 | |||
| 203 | /// @brief Get stat url is a regular. | ||
| 204 | bool GetIsRegular() const { return m_cStructure->isRegular; } | ||
| 205 | |||
| 206 | /// @brief Set stat url is a socket. | ||
| 207 | void SetIsSocket(bool isSocket) { m_cStructure->isSocket = isSocket; } | ||
| 208 | |||
| 209 | /// @brief Get stat url is a regular. | ||
| 210 | bool GetIsSocket() const { return m_cStructure->isSocket; } | ||
| 170 | //@} | 211 | //@} |
| 171 | }; | 212 | }; |
| 172 | //@} | 213 | //@} |
| @@ -777,6 +818,7 @@ inline bool ATTRIBUTE_HIDDEN DirectoryExists(const std::string& path) | |||
| 777 | /// directory whose name is given by path. | 818 | /// directory whose name is given by path. |
| 778 | /// | 819 | /// |
| 779 | /// @param[in] path Path to the directory. | 820 | /// @param[in] path Path to the directory. |
| 821 | /// @param[in] recursive [opt] Remove directory recursive (default is false) | ||
| 780 | /// @return Upon successful completion, the function RemoveDirectory() shall | 822 | /// @return Upon successful completion, the function RemoveDirectory() shall |
| 781 | /// return true. Otherwise, false shall be returned, and errno set | 823 | /// return true. Otherwise, false shall be returned, and errno set |
| 782 | /// to indicate the error. If false is returned, the named directory | 824 | /// to indicate the error. If false is returned, the named directory |
| @@ -793,12 +835,16 @@ inline bool ATTRIBUTE_HIDDEN DirectoryExists(const std::string& path) | |||
| 793 | /// ... | 835 | /// ... |
| 794 | /// ~~~~~~~~~~~~~ | 836 | /// ~~~~~~~~~~~~~ |
| 795 | /// | 837 | /// |
| 796 | inline bool ATTRIBUTE_HIDDEN RemoveDirectory(const std::string& path) | 838 | inline bool ATTRIBUTE_HIDDEN RemoveDirectory(const std::string& path, bool recursive = false) |
| 797 | { | 839 | { |
| 798 | using namespace kodi::addon; | 840 | using namespace kodi::addon; |
| 799 | 841 | ||
| 800 | return CAddonBase::m_interface->toKodi->kodi_filesystem->remove_directory( | 842 | if (!recursive) |
| 801 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | 843 | return CAddonBase::m_interface->toKodi->kodi_filesystem->remove_directory( |
| 844 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 845 | else | ||
| 846 | return CAddonBase::m_interface->toKodi->kodi_filesystem->remove_directory_recursive( | ||
| 847 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 802 | } | 848 | } |
| 803 | //------------------------------------------------------------------------------ | 849 | //------------------------------------------------------------------------------ |
| 804 | 850 | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/General.h b/xbmc/addons/kodi-dev-kit/include/kodi/General.h index 878eaa4..3fad5a0 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/General.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/General.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #include "AddonBase.h" | 11 | #include "AddonBase.h" |
| 12 | #include "c-api/general.h" | 12 | #include "c-api/general.h" |
| 13 | #include "tools/StringUtils.h" | ||
| 13 | 14 | ||
| 14 | #ifdef __cplusplus | 15 | #ifdef __cplusplus |
| 15 | 16 | ||
| @@ -317,12 +318,11 @@ inline void ATTRIBUTE_HIDDEN QueueFormattedNotification(QueueMsg type, const cha | |||
| 317 | using namespace kodi::addon; | 318 | using namespace kodi::addon; |
| 318 | 319 | ||
| 319 | va_list args; | 320 | va_list args; |
| 320 | char buffer[16384]; | ||
| 321 | va_start(args, format); | 321 | va_start(args, format); |
| 322 | vsprintf(buffer, format, args); | 322 | const std::string str = kodi::tools::StringUtils::FormatV(format, args); |
| 323 | va_end(args); | 323 | va_end(args); |
| 324 | CAddonBase::m_interface->toKodi->kodi->queue_notification( | 324 | CAddonBase::m_interface->toKodi->kodi->queue_notification( |
| 325 | CAddonBase::m_interface->toKodi->kodiBase, type, "", buffer, "", 5000, false, 1000); | 325 | CAddonBase::m_interface->toKodi->kodiBase, type, "", str.c_str(), "", 5000, false, 1000); |
| 326 | } | 326 | } |
| 327 | //------------------------------------------------------------------------------ | 327 | //------------------------------------------------------------------------------ |
| 328 | 328 | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/Network.h b/xbmc/addons/kodi-dev-kit/include/kodi/Network.h index 910385f..910385f 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/Network.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/Network.h | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/StreamCodec.h b/xbmc/addons/kodi-dev-kit/include/kodi/StreamCodec.h index e030371..e030371 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/StreamCodec.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/StreamCodec.h | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/StreamCrypto.h b/xbmc/addons/kodi-dev-kit/include/kodi/StreamCrypto.h index 8008aa1..8008aa1 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/StreamCrypto.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/StreamCrypto.h | |||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h new file mode 100644 index 0000000..a6bea7d --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h | |||
| @@ -0,0 +1,595 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | #include "../AudioEngine.h" | ||
| 13 | #include "../c-api/addon-instance/audio_decoder.h" | ||
| 14 | |||
| 15 | #ifdef __cplusplus | ||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace addon | ||
| 19 | { | ||
| 20 | |||
| 21 | class CInstanceAudioDecoder; | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_addon_audiodecoder_Defs_AudioDecoderInfoTag class AudioDecoderInfoTag | ||
| 25 | /// @ingroup cpp_kodi_addon_audiodecoder_Defs | ||
| 26 | /// @brief **Info tag data structure**\n | ||
| 27 | /// Representation of available information of processed audio file. | ||
| 28 | /// | ||
| 29 | /// This is used to store all the necessary data of audio stream and to have on | ||
| 30 | /// e.g. GUI for information. | ||
| 31 | /// | ||
| 32 | /// ---------------------------------------------------------------------------- | ||
| 33 | /// | ||
| 34 | /// @copydetails cpp_kodi_addon_audiodecoder_Defs_AudioDecoderInfoTag_Help | ||
| 35 | /// | ||
| 36 | ///@{ | ||
| 37 | class AudioDecoderInfoTag : public CStructHdl<AudioDecoderInfoTag, AUDIO_DECODER_INFO_TAG> | ||
| 38 | { | ||
| 39 | /*! \cond PRIVATE */ | ||
| 40 | friend class CInstanceAudioDecoder; | ||
| 41 | /*! \endcond */ | ||
| 42 | |||
| 43 | public: | ||
| 44 | /*! \cond PRIVATE */ | ||
| 45 | AudioDecoderInfoTag() { memset(m_cStructure, 0, sizeof(AUDIO_DECODER_INFO_TAG)); } | ||
| 46 | AudioDecoderInfoTag(const AudioDecoderInfoTag& tag) : CStructHdl(tag) {} | ||
| 47 | /*! \endcond */ | ||
| 48 | |||
| 49 | /// @defgroup cpp_kodi_addon_audiodecoder_Defs_AudioDecoderInfoTag_Help Value Help | ||
| 50 | /// @ingroup cpp_kodi_addon_audiodecoder_Defs_AudioDecoderInfoTag | ||
| 51 | /// | ||
| 52 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_audiodecoder_Defs_AudioDecoderInfoTag :</b> | ||
| 53 | /// | Name | Type | Set call | Get call | ||
| 54 | /// |------|------|----------|---------- | ||
| 55 | /// | **Title** | `std::string` | @ref AudioDecoderInfoTag::SetTitle "SetTitle" | @ref AudioDecoderInfoTag::GetTitle "GetTitle" | ||
| 56 | /// | **Artist** | `std::string` | @ref AudioDecoderInfoTag::SetArtist "SetArtist" | @ref AudioDecoderInfoTag::GetArtist "GetArtist" | ||
| 57 | /// | **Album** | `std::string` | @ref AudioDecoderInfoTag::SetAlbum "SetAlbum" | @ref AudioDecoderInfoTag::GetAlbum "GetAlbum" | ||
| 58 | /// | **Album artist** | `std::string` | @ref AudioDecoderInfoTag::SetAlbumArtist "SetAlbumArtist" | @ref AudioDecoderInfoTag::GetAlbumArtist "GetAlbumArtist" | ||
| 59 | /// | **Media type** | `std::string` | @ref AudioDecoderInfoTag::SetMediaType "SetMediaType" | @ref AudioDecoderInfoTag::GetMediaType "GetMediaType" | ||
| 60 | /// | **Genre** | `std::string` | @ref AudioDecoderInfoTag::SetGenre "SetGenre" | @ref AudioDecoderInfoTag::GetGenre "GetGenre" | ||
| 61 | /// | **Duration** | `int` | @ref AudioDecoderInfoTag::SetDuration "SetDuration" | @ref AudioDecoderInfoTag::GetDuration "GetDuration" | ||
| 62 | /// | **Track number** | `int` | @ref AudioDecoderInfoTag::SetTrack "SetTrack" | @ref AudioDecoderInfoTag::GetTrack "GetTrack" | ||
| 63 | /// | **Disc number** | `int` | @ref AudioDecoderInfoTag::SetDisc "SetDisc" | @ref AudioDecoderInfoTag::GetDisc "GetDisc" | ||
| 64 | /// | **Disc subtitle name** | `std::string` | @ref AudioDecoderInfoTag::SetDiscSubtitle "SetDiscSubtitle" | @ref AudioDecoderInfoTag::GetDiscSubtitle "GetDiscSubtitle" | ||
| 65 | /// | **Disc total amount** | `int` | @ref AudioDecoderInfoTag::SetDiscTotal "SetDiscTotal" | @ref AudioDecoderInfoTag::GetDiscTotal "GetDiscTotal" | ||
| 66 | /// | **Release date** | `std::string` | @ref AudioDecoderInfoTag::SetReleaseDate "SetReleaseDate" | @ref AudioDecoderInfoTag::GetReleaseDate "GetReleaseDate" | ||
| 67 | /// | **Lyrics** | `std::string` | @ref AudioDecoderInfoTag::SetLyrics "SetLyrics" | @ref AudioDecoderInfoTag::GetLyrics "GetLyrics" | ||
| 68 | /// | **Samplerate** | `int` | @ref AudioDecoderInfoTag::SetSamplerate "SetSamplerate" | @ref AudioDecoderInfoTag::GetSamplerate "GetSamplerate" | ||
| 69 | /// | **Channels amount** | `int` | @ref AudioDecoderInfoTag::SetChannels "SetChannels" | @ref AudioDecoderInfoTag::GetChannels "GetChannels" | ||
| 70 | /// | **Bitrate** | `int` | @ref AudioDecoderInfoTag::SetBitrate "SetBitrate" | @ref AudioDecoderInfoTag::GetBitrate "GetBitrate" | ||
| 71 | /// | **Comment text** | `std::string` | @ref AudioDecoderInfoTag::SetComment "SetComment" | @ref AudioDecoderInfoTag::GetComment "GetComment" | ||
| 72 | /// | ||
| 73 | |||
| 74 | /// @addtogroup cpp_kodi_addon_audiodecoder_Defs_AudioDecoderInfoTag | ||
| 75 | ///@{ | ||
| 76 | |||
| 77 | /// @brief Set the title from music as string on info tag. | ||
| 78 | void SetTitle(const std::string& title) | ||
| 79 | { | ||
| 80 | strncpy(m_cStructure->title, title.c_str(), sizeof(m_cStructure->title) - 1); | ||
| 81 | } | ||
| 82 | |||
| 83 | /// @brief Get title name | ||
| 84 | std::string GetTitle() const { return m_cStructure->title; } | ||
| 85 | |||
| 86 | /// @brief Set artist name | ||
| 87 | void SetArtist(const std::string& artist) | ||
| 88 | { | ||
| 89 | strncpy(m_cStructure->artist, artist.c_str(), sizeof(m_cStructure->artist) - 1); | ||
| 90 | } | ||
| 91 | |||
| 92 | /// @brief Get artist name | ||
| 93 | std::string GetArtist() const { return m_cStructure->artist; } | ||
| 94 | |||
| 95 | /// @brief Set album name | ||
| 96 | void SetAlbum(const std::string& album) | ||
| 97 | { | ||
| 98 | strncpy(m_cStructure->album, album.c_str(), sizeof(m_cStructure->album) - 1); | ||
| 99 | } | ||
| 100 | |||
| 101 | /// @brief Set album name | ||
| 102 | std::string GetAlbum() const { return m_cStructure->album; } | ||
| 103 | |||
| 104 | /// @brief Set album artist name | ||
| 105 | void SetAlbumArtist(const std::string& albumArtist) | ||
| 106 | { | ||
| 107 | strncpy(m_cStructure->album_artist, albumArtist.c_str(), | ||
| 108 | sizeof(m_cStructure->album_artist) - 1); | ||
| 109 | } | ||
| 110 | |||
| 111 | /// @brief Get album artist name | ||
| 112 | std::string GetAlbumArtist() const { return m_cStructure->album_artist; } | ||
| 113 | |||
| 114 | /// @brief Set the media type of the music item. | ||
| 115 | /// | ||
| 116 | /// Available strings about media type for music: | ||
| 117 | /// | String | Description | | ||
| 118 | /// |---------------:|:--------------------------------------------------| | ||
| 119 | /// | artist | If it is defined as an artist | ||
| 120 | /// | album | If it is defined as an album | ||
| 121 | /// | music | If it is defined as an music | ||
| 122 | /// | song | If it is defined as a song | ||
| 123 | /// | ||
| 124 | void SetMediaType(const std::string& mediaType) | ||
| 125 | { | ||
| 126 | strncpy(m_cStructure->media_type, mediaType.c_str(), sizeof(m_cStructure->media_type) - 1); | ||
| 127 | } | ||
| 128 | |||
| 129 | /// @brief Get the media type of the music item. | ||
| 130 | std::string GetMediaType() const { return m_cStructure->media_type; } | ||
| 131 | |||
| 132 | /// @brief Set genre name from music as string if present. | ||
| 133 | void SetGenre(const std::string& genre) | ||
| 134 | { | ||
| 135 | strncpy(m_cStructure->genre, genre.c_str(), sizeof(m_cStructure->genre) - 1); | ||
| 136 | } | ||
| 137 | |||
| 138 | /// @brief Get genre name from music as string if present. | ||
| 139 | std::string GetGenre() const { return m_cStructure->genre; } | ||
| 140 | |||
| 141 | /// @brief Set the duration of music as integer from info. | ||
| 142 | void SetDuration(int duration) { m_cStructure->duration = duration; } | ||
| 143 | |||
| 144 | /// @brief Get the duration of music as integer from info. | ||
| 145 | int GetDuration() const { return m_cStructure->duration; } | ||
| 146 | |||
| 147 | /// @brief Set track number (if present) from music info as integer. | ||
| 148 | void SetTrack(int track) { m_cStructure->track = track; } | ||
| 149 | |||
| 150 | /// @brief Get track number (if present). | ||
| 151 | int GetTrack() const { return m_cStructure->track; } | ||
| 152 | |||
| 153 | /// @brief Set disk number (if present) from music info as integer. | ||
| 154 | void SetDisc(int disc) { m_cStructure->disc = disc; } | ||
| 155 | |||
| 156 | /// @brief Get disk number (if present) | ||
| 157 | int GetDisc() const { return m_cStructure->disc; } | ||
| 158 | |||
| 159 | /// @brief Set disk subtitle name (if present) from music info. | ||
| 160 | void SetDiscSubtitle(const std::string& discSubtitle) | ||
| 161 | { | ||
| 162 | strncpy(m_cStructure->disc_subtitle, discSubtitle.c_str(), | ||
| 163 | sizeof(m_cStructure->disc_subtitle) - 1); | ||
| 164 | } | ||
| 165 | |||
| 166 | /// @brief Get disk subtitle name (if present) from music info. | ||
| 167 | std::string GetDiscSubtitle() const { return m_cStructure->disc_subtitle; } | ||
| 168 | |||
| 169 | /// @brief Set disks amount quantity (if present) from music info as integer. | ||
| 170 | void SetDiscTotal(int discTotal) { m_cStructure->disc_total = discTotal; } | ||
| 171 | |||
| 172 | /// @brief Get disks amount quantity (if present) | ||
| 173 | int GetDiscTotal() const { return m_cStructure->disc_total; } | ||
| 174 | |||
| 175 | /// @brief Set release date as string from music info (if present).\n | ||
| 176 | /// [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) date YYYY, YYYY-MM or YYYY-MM-DD | ||
| 177 | void SetReleaseDate(const std::string& releaseDate) | ||
| 178 | { | ||
| 179 | strncpy(m_cStructure->release_date, releaseDate.c_str(), | ||
| 180 | sizeof(m_cStructure->release_date) - 1); | ||
| 181 | } | ||
| 182 | |||
| 183 | /// @brief Get release date as string from music info (if present). | ||
| 184 | std::string GetReleaseDate() const { return m_cStructure->release_date; } | ||
| 185 | |||
| 186 | /// @brief Set string from lyrics. | ||
| 187 | void SetLyrics(const std::string& lyrics) | ||
| 188 | { | ||
| 189 | strncpy(m_cStructure->lyrics, lyrics.c_str(), sizeof(m_cStructure->lyrics) - 1); | ||
| 190 | } | ||
| 191 | |||
| 192 | /// @brief Get string from lyrics. | ||
| 193 | std::string GetLyrics() const { return m_cStructure->lyrics; } | ||
| 194 | |||
| 195 | /// @brief Set related stream samplerate. | ||
| 196 | void SetSamplerate(int samplerate) { m_cStructure->samplerate = samplerate; } | ||
| 197 | |||
| 198 | /// @brief Get related stream samplerate. | ||
| 199 | int GetSamplerate() const { return m_cStructure->samplerate; } | ||
| 200 | |||
| 201 | /// @brief Set related stream channels amount. | ||
| 202 | void SetChannels(int channels) { m_cStructure->channels = channels; } | ||
| 203 | |||
| 204 | /// @brief Get related stream channels amount. | ||
| 205 | int GetChannels() const { return m_cStructure->channels; } | ||
| 206 | |||
| 207 | /// @brief Set related stream bitrate. | ||
| 208 | void SetBitrate(int bitrate) { m_cStructure->bitrate = bitrate; } | ||
| 209 | |||
| 210 | /// @brief Get related stream bitrate. | ||
| 211 | int GetBitrate() const { return m_cStructure->bitrate; } | ||
| 212 | |||
| 213 | /// @brief Set additional information comment (if present). | ||
| 214 | void SetComment(const std::string& comment) | ||
| 215 | { | ||
| 216 | strncpy(m_cStructure->comment, comment.c_str(), sizeof(m_cStructure->comment) - 1); | ||
| 217 | } | ||
| 218 | |||
| 219 | /// @brief Get additional information comment (if present). | ||
| 220 | std::string GetComment() const { return m_cStructure->comment; } | ||
| 221 | |||
| 222 | ///@} | ||
| 223 | |||
| 224 | private: | ||
| 225 | AudioDecoderInfoTag(const AUDIO_DECODER_INFO_TAG* tag) : CStructHdl(tag) {} | ||
| 226 | AudioDecoderInfoTag(AUDIO_DECODER_INFO_TAG* tag) : CStructHdl(tag) {} | ||
| 227 | }; | ||
| 228 | ///@} | ||
| 229 | //------------------------------------------------------------------------------ | ||
| 230 | |||
| 231 | //============================================================================== | ||
| 232 | /// @defgroup cpp_kodi_addon_audiodecoder_Defs Definitions, structures and enumerators | ||
| 233 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 234 | /// @brief **Audio decoder add-on instance definition values**\n | ||
| 235 | /// All audio decoder functions associated data structures. | ||
| 236 | /// | ||
| 237 | /// Used to exchange the available options between Kodi and addon.\n | ||
| 238 | /// The groups described here correspond to the groups of functions on audio | ||
| 239 | /// decoder instance class. | ||
| 240 | /// | ||
| 241 | |||
| 242 | //============================================================================== | ||
| 243 | /// | ||
| 244 | /// \addtogroup cpp_kodi_addon_audiodecoder | ||
| 245 | /// @brief \cpp_class{ kodi::addon::CInstanceAudioDecoder } | ||
| 246 | /// **Audio decoder add-on instance** | ||
| 247 | /// | ||
| 248 | /// For audio decoders as binary add-ons. This class implements a way to handle | ||
| 249 | /// special types of audio files. | ||
| 250 | /// | ||
| 251 | /// The add-on handles loading of the source file and outputting the audio stream | ||
| 252 | /// for consumption by the player. | ||
| 253 | /// | ||
| 254 | /// The addon.xml defines the capabilities of this add-on. | ||
| 255 | /// | ||
| 256 | /// @note The option to have multiple instances is possible with audio-decoder | ||
| 257 | /// add-ons. This is useful, since some playback engines are riddled by global | ||
| 258 | /// variables, making decoding of multiple streams using the same instance | ||
| 259 | /// impossible. | ||
| 260 | /// | ||
| 261 | /// | ||
| 262 | /// ---------------------------------------------------------------------------- | ||
| 263 | /// | ||
| 264 | /// **Here's an example on addon.xml:** | ||
| 265 | /// ~~~~~~~~~~~~~{.xml} | ||
| 266 | /// <?xml version="1.0" encoding="UTF-8"?> | ||
| 267 | /// <addon | ||
| 268 | /// id="audiodecoder.myspecialnamefor" | ||
| 269 | /// version="1.0.0" | ||
| 270 | /// name="My special audio decoder addon" | ||
| 271 | /// provider-name="Your Name"> | ||
| 272 | /// <requires>@ADDON_DEPENDS@</requires> | ||
| 273 | /// <extension | ||
| 274 | /// point="kodi.audiodecoder" | ||
| 275 | /// name="2sf" | ||
| 276 | /// extension=".2sf|.mini2sf" | ||
| 277 | /// tags="true" | ||
| 278 | /// library_@PLATFORM@="@LIBRARY_FILENAME@"/> | ||
| 279 | /// <extension point="xbmc.addon.metadata"> | ||
| 280 | /// <summary lang="en_GB">My audio decoder addon addon</summary> | ||
| 281 | /// <description lang="en_GB">My audio decoder addon description</description> | ||
| 282 | /// <platform>@PLATFORM@</platform> | ||
| 283 | /// </extension> | ||
| 284 | /// </addon> | ||
| 285 | /// ~~~~~~~~~~~~~ | ||
| 286 | /// | ||
| 287 | /// Description to audio decoder related addon.xml values: | ||
| 288 | /// | Name | Description | ||
| 289 | /// |:------------------------------|---------------------------------------- | ||
| 290 | /// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"kodi.audiodecoder"</b>. | ||
| 291 | /// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build. | ||
| 292 | /// | <b>`name`</b> | The name of the decoder used in Kodi for display. | ||
| 293 | /// | <b>`extension`</b> | The file extensions / styles supported by this addon. | ||
| 294 | /// | <b>`tags`</b> | Boolean to point out that addon can bring own information to replayed file, if <b>`false`</b> only the file name is used as info.<br>If <b>`true`</b>, \ref CInstanceAudioDecoder::ReadTag is used and must be implemented. | ||
| 295 | /// | ||
| 296 | /// -------------------------------------------------------------------------- | ||
| 297 | /// | ||
| 298 | /// **Here is a code example how this addon is used:** | ||
| 299 | /// | ||
| 300 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 301 | /// #include <kodi/addon-instance/AudioDecoder.h> | ||
| 302 | /// | ||
| 303 | /// class CMyAudioDecoder : public kodi::addon::CInstanceAudioDecoder | ||
| 304 | /// { | ||
| 305 | /// public: | ||
| 306 | /// CMyAudioDecoder(KODI_HANDLE instance, const std::string& version); | ||
| 307 | /// | ||
| 308 | /// bool Init(const std::string& filename, unsigned int filecache, | ||
| 309 | /// int& channels, int& samplerate, | ||
| 310 | /// int& bitspersample, int64_t& totaltime, | ||
| 311 | /// int& bitrate, AudioEngineDataFormat& format, | ||
| 312 | /// std::vector<AudioEngineChannel>& channellist) override; | ||
| 313 | /// int ReadPCM(uint8_t* buffer, int size, int& actualsize) override; | ||
| 314 | /// }; | ||
| 315 | /// | ||
| 316 | /// CMyAudioDecoder::CMyAudioDecoder(KODI_HANDLE instance, const std::string& version) | ||
| 317 | /// : kodi::addon::CInstanceAudioDecoder(instance, version) | ||
| 318 | /// { | ||
| 319 | /// ... | ||
| 320 | /// } | ||
| 321 | /// | ||
| 322 | /// bool CMyAudioDecoder::Init(const std::string& filename, unsigned int filecache, | ||
| 323 | /// int& channels, int& samplerate, | ||
| 324 | /// int& bitspersample, int64_t& totaltime, | ||
| 325 | /// int& bitrate, AudioEngineDataFormat& format, | ||
| 326 | /// std::vector<AudioEngineChannel>& channellist) | ||
| 327 | /// { | ||
| 328 | /// ... | ||
| 329 | /// return true; | ||
| 330 | /// } | ||
| 331 | /// | ||
| 332 | /// int CMyAudioDecoder::ReadPCM(uint8_t* buffer, int size, int& actualsize) | ||
| 333 | /// { | ||
| 334 | /// ... | ||
| 335 | /// return 0; | ||
| 336 | /// } | ||
| 337 | /// | ||
| 338 | /// | ||
| 339 | /// //---------------------------------------------------------------------- | ||
| 340 | /// | ||
| 341 | /// class CMyAddon : public kodi::addon::CAddonBase | ||
| 342 | /// { | ||
| 343 | /// public: | ||
| 344 | /// CMyAddon() { } | ||
| 345 | /// ADDON_STATUS CreateInstance(int instanceType, | ||
| 346 | /// const std::string& instanceID, | ||
| 347 | /// KODI_HANDLE instance, | ||
| 348 | /// const std::string& version, | ||
| 349 | /// KODI_HANDLE& addonInstance) override; | ||
| 350 | /// }; | ||
| 351 | /// | ||
| 352 | /// // If you use only one instance in your add-on, can be instanceType and | ||
| 353 | /// // instanceID ignored | ||
| 354 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 355 | /// const std::string& instanceID, | ||
| 356 | /// KODI_HANDLE instance, | ||
| 357 | /// const std::string& version, | ||
| 358 | /// KODI_HANDLE& addonInstance) | ||
| 359 | /// { | ||
| 360 | /// if (instanceType == ADDON_INSTANCE_AUDIODECODER) | ||
| 361 | /// { | ||
| 362 | /// kodi::Log(ADDON_LOG_INFO, "Creating my audio decoder"); | ||
| 363 | /// addonInstance = new CMyAudioDecoder(instance, version); | ||
| 364 | /// return ADDON_STATUS_OK; | ||
| 365 | /// } | ||
| 366 | /// else if (...) | ||
| 367 | /// { | ||
| 368 | /// ... | ||
| 369 | /// } | ||
| 370 | /// return ADDON_STATUS_UNKNOWN; | ||
| 371 | /// } | ||
| 372 | /// | ||
| 373 | /// ADDONCREATOR(CMyAddon) | ||
| 374 | /// ~~~~~~~~~~~~~ | ||
| 375 | /// | ||
| 376 | /// The destruction of the example class `CMyAudioDecoder` is called from | ||
| 377 | /// Kodi's header. Manually deleting the add-on instance is not required. | ||
| 378 | /// | ||
| 379 | class ATTRIBUTE_HIDDEN CInstanceAudioDecoder : public IAddonInstance | ||
| 380 | { | ||
| 381 | public: | ||
| 382 | //========================================================================== | ||
| 383 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 384 | /// @brief Audio decoder class constructor used to support multiple instance | ||
| 385 | /// types. | ||
| 386 | /// | ||
| 387 | /// @param[in] instance The instance value given to | ||
| 388 | /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>. | ||
| 389 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to | ||
| 390 | /// allow compatibility to older Kodi versions. | ||
| 391 | /// | ||
| 392 | /// @note Recommended to set <b>`kodiVersion`</b>. | ||
| 393 | /// | ||
| 394 | /// | ||
| 395 | /// -------------------------------------------------------------------------- | ||
| 396 | /// | ||
| 397 | /// **Here's example about the use of this:** | ||
| 398 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 399 | /// class CMyAudioDecoder : public kodi::addon::CInstanceAudioDecoder | ||
| 400 | /// { | ||
| 401 | /// public: | ||
| 402 | /// CMyAudioDecoder(KODI_HANDLE instance, const std::string& kodiVersion) | ||
| 403 | /// : kodi::addon::CInstanceAudioDecoder(instance, kodiVersion) | ||
| 404 | /// { | ||
| 405 | /// ... | ||
| 406 | /// } | ||
| 407 | /// | ||
| 408 | /// ... | ||
| 409 | /// }; | ||
| 410 | /// | ||
| 411 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 412 | /// const std::string& instanceID, | ||
| 413 | /// KODI_HANDLE instance, | ||
| 414 | /// const std::string& version, | ||
| 415 | /// KODI_HANDLE& addonInstance) | ||
| 416 | /// { | ||
| 417 | /// kodi::Log(ADDON_LOG_INFO, "Creating my audio decoder"); | ||
| 418 | /// addonInstance = new CMyAudioDecoder(instance, version); | ||
| 419 | /// return ADDON_STATUS_OK; | ||
| 420 | /// } | ||
| 421 | /// ~~~~~~~~~~~~~ | ||
| 422 | /// | ||
| 423 | explicit CInstanceAudioDecoder(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 424 | : IAddonInstance(ADDON_INSTANCE_AUDIODECODER, | ||
| 425 | !kodiVersion.empty() ? kodiVersion | ||
| 426 | : GetKodiTypeVersion(ADDON_INSTANCE_AUDIODECODER)) | ||
| 427 | { | ||
| 428 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 429 | throw std::logic_error("kodi::addon::CInstanceAudioDecoder: Creation of multiple together with single instance way is not allowed!"); | ||
| 430 | |||
| 431 | SetAddonStruct(instance); | ||
| 432 | } | ||
| 433 | //-------------------------------------------------------------------------- | ||
| 434 | |||
| 435 | //========================================================================== | ||
| 436 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 437 | /// @brief Initialize a decoder. | ||
| 438 | /// | ||
| 439 | /// @param[in] filename The file to read | ||
| 440 | /// @param[in] filecache The file cache size | ||
| 441 | /// @param[out] channels Number of channels in output stream | ||
| 442 | /// @param[out] samplerate Samplerate of output stream | ||
| 443 | /// @param[out] bitspersample Bits per sample in output stream | ||
| 444 | /// @param[out] totaltime Total time for stream | ||
| 445 | /// @param[out] bitrate Average bitrate of input stream | ||
| 446 | /// @param[out] format Data format for output stream, see | ||
| 447 | /// @ref cpp_kodi_audioengine_Defs_AudioEngineFormat for | ||
| 448 | /// available values | ||
| 449 | /// @param[out] channellist Channel mapping for output streamm, see | ||
| 450 | /// @ref cpp_kodi_audioengine_Defs_AudioEngineChannel | ||
| 451 | /// for available values | ||
| 452 | /// @return true if successfully done, otherwise false | ||
| 453 | /// | ||
| 454 | virtual bool Init(const std::string& filename, | ||
| 455 | unsigned int filecache, | ||
| 456 | int& channels, | ||
| 457 | int& samplerate, | ||
| 458 | int& bitspersample, | ||
| 459 | int64_t& totaltime, | ||
| 460 | int& bitrate, | ||
| 461 | AudioEngineDataFormat& format, | ||
| 462 | std::vector<AudioEngineChannel>& channellist) = 0; | ||
| 463 | //-------------------------------------------------------------------------- | ||
| 464 | |||
| 465 | //========================================================================== | ||
| 466 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 467 | /// @brief Produce some noise. | ||
| 468 | /// | ||
| 469 | /// @param[in] buffer Output buffer | ||
| 470 | /// @param[in] size Size of output buffer | ||
| 471 | /// @param[out] actualsize Actual number of bytes written to output buffer | ||
| 472 | /// @return Return with following possible values: | ||
| 473 | /// | Value | Description | ||
| 474 | /// |:-----:|:------------ | ||
| 475 | /// | 0 | on success | ||
| 476 | /// | -1 | on end of stream | ||
| 477 | /// | 1 | on failure | ||
| 478 | /// | ||
| 479 | virtual int ReadPCM(uint8_t* buffer, int size, int& actualsize) = 0; | ||
| 480 | //-------------------------------------------------------------------------- | ||
| 481 | |||
| 482 | //========================================================================== | ||
| 483 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 484 | /// @brief Seek in output stream. | ||
| 485 | /// | ||
| 486 | /// @param[in] time Time position to seek to in milliseconds | ||
| 487 | /// @return Time position seek ended up on | ||
| 488 | /// | ||
| 489 | virtual int64_t Seek(int64_t time) { return time; } | ||
| 490 | //-------------------------------------------------------------------------- | ||
| 491 | |||
| 492 | //========================================================================== | ||
| 493 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 494 | /// @brief Read tag of a file. | ||
| 495 | /// | ||
| 496 | /// @param[in] file File to read tag for | ||
| 497 | /// @param[out] tag Information tag about | ||
| 498 | /// @return True on success, false on failure | ||
| 499 | /// | ||
| 500 | /// -------------------------------------------------------------------------- | ||
| 501 | /// | ||
| 502 | /// @copydetails cpp_kodi_addon_audiodecoder_Defs_AudioDecoderInfoTag_Help | ||
| 503 | /// | ||
| 504 | virtual bool ReadTag(const std::string& file, kodi::addon::AudioDecoderInfoTag& tag) | ||
| 505 | { | ||
| 506 | return false; | ||
| 507 | } | ||
| 508 | //-------------------------------------------------------------------------- | ||
| 509 | |||
| 510 | //========================================================================== | ||
| 511 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 512 | /// @brief Get number of tracks in a file. | ||
| 513 | /// | ||
| 514 | /// @param[in] file File to read tag for | ||
| 515 | /// @return Number of tracks in file | ||
| 516 | /// | ||
| 517 | virtual int TrackCount(const std::string& file) { return 1; } | ||
| 518 | //-------------------------------------------------------------------------- | ||
| 519 | |||
| 520 | private: | ||
| 521 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 522 | { | ||
| 523 | if (instance == nullptr) | ||
| 524 | throw std::logic_error("kodi::addon::CInstanceAudioDecoder: Creation with empty addon structure not allowed, table must be given from Kodi!"); | ||
| 525 | |||
| 526 | m_instanceData = static_cast<AddonInstance_AudioDecoder*>(instance); | ||
| 527 | |||
| 528 | m_instanceData->toAddon->addonInstance = this; | ||
| 529 | m_instanceData->toAddon->init = ADDON_Init; | ||
| 530 | m_instanceData->toAddon->read_pcm = ADDON_ReadPCM; | ||
| 531 | m_instanceData->toAddon->seek = ADDON_Seek; | ||
| 532 | m_instanceData->toAddon->read_tag = ADDON_ReadTag; | ||
| 533 | m_instanceData->toAddon->track_count = ADDON_TrackCount; | ||
| 534 | } | ||
| 535 | |||
| 536 | inline static bool ADDON_Init(const AddonInstance_AudioDecoder* instance, | ||
| 537 | const char* file, | ||
| 538 | unsigned int filecache, | ||
| 539 | int* channels, | ||
| 540 | int* samplerate, | ||
| 541 | int* bitspersample, | ||
| 542 | int64_t* totaltime, | ||
| 543 | int* bitrate, | ||
| 544 | AudioEngineDataFormat* format, | ||
| 545 | const AudioEngineChannel** info) | ||
| 546 | { | ||
| 547 | CInstanceAudioDecoder* thisClass = | ||
| 548 | static_cast<CInstanceAudioDecoder*>(instance->toAddon->addonInstance); | ||
| 549 | |||
| 550 | thisClass->m_channelList.clear(); | ||
| 551 | bool ret = thisClass->Init(file, filecache, *channels, *samplerate, *bitspersample, *totaltime, | ||
| 552 | *bitrate, *format, thisClass->m_channelList); | ||
| 553 | if (!thisClass->m_channelList.empty()) | ||
| 554 | { | ||
| 555 | if (thisClass->m_channelList.back() != AUDIOENGINE_CH_NULL) | ||
| 556 | thisClass->m_channelList.push_back(AUDIOENGINE_CH_NULL); | ||
| 557 | *info = thisClass->m_channelList.data(); | ||
| 558 | } | ||
| 559 | else | ||
| 560 | *info = nullptr; | ||
| 561 | return ret; | ||
| 562 | } | ||
| 563 | |||
| 564 | inline static int ADDON_ReadPCM(const AddonInstance_AudioDecoder* instance, uint8_t* buffer, int size, int* actualsize) | ||
| 565 | { | ||
| 566 | return static_cast<CInstanceAudioDecoder*>(instance->toAddon->addonInstance) | ||
| 567 | ->ReadPCM(buffer, size, *actualsize); | ||
| 568 | } | ||
| 569 | |||
| 570 | inline static int64_t ADDON_Seek(const AddonInstance_AudioDecoder* instance, int64_t time) | ||
| 571 | { | ||
| 572 | return static_cast<CInstanceAudioDecoder*>(instance->toAddon->addonInstance)->Seek(time); | ||
| 573 | } | ||
| 574 | |||
| 575 | inline static bool ADDON_ReadTag(const AddonInstance_AudioDecoder* instance, | ||
| 576 | const char* file, | ||
| 577 | struct AUDIO_DECODER_INFO_TAG* tag) | ||
| 578 | { | ||
| 579 | kodi::addon::AudioDecoderInfoTag cppTag(tag); | ||
| 580 | return static_cast<CInstanceAudioDecoder*>(instance->toAddon->addonInstance) | ||
| 581 | ->ReadTag(file, cppTag); | ||
| 582 | } | ||
| 583 | |||
| 584 | inline static int ADDON_TrackCount(const AddonInstance_AudioDecoder* instance, const char* file) | ||
| 585 | { | ||
| 586 | return static_cast<CInstanceAudioDecoder*>(instance->toAddon->addonInstance)->TrackCount(file); | ||
| 587 | } | ||
| 588 | |||
| 589 | std::vector<AudioEngineChannel> m_channelList; | ||
| 590 | AddonInstance_AudioDecoder* m_instanceData; | ||
| 591 | }; | ||
| 592 | |||
| 593 | } /* namespace addon */ | ||
| 594 | } /* namespace kodi */ | ||
| 595 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioEncoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioEncoder.h new file mode 100644 index 0000000..9a869c1 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioEncoder.h | |||
| @@ -0,0 +1,353 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | #include "../c-api/addon-instance/audio_encoder.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | namespace kodi | ||
| 16 | { | ||
| 17 | namespace addon | ||
| 18 | { | ||
| 19 | |||
| 20 | //============================================================================== | ||
| 21 | /// @addtogroup cpp_kodi_addon_audioencoder | ||
| 22 | /// @brief \cpp_class{ kodi::addon::CInstanceAudioEncoder } | ||
| 23 | /// **Audio encoder add-on instance.**\n | ||
| 24 | /// For audio encoders as binary add-ons. This class implements a way to handle | ||
| 25 | /// the encode of given stream to a new format. | ||
| 26 | /// | ||
| 27 | /// The addon.xml defines the capabilities of this add-on. | ||
| 28 | /// | ||
| 29 | /// | ||
| 30 | /// ---------------------------------------------------------------------------- | ||
| 31 | /// | ||
| 32 | /// **Here's an example on addon.xml:** | ||
| 33 | /// ~~~~~~~~~~~~~{.xml} | ||
| 34 | /// <extension | ||
| 35 | /// point="kodi.audioencoder" | ||
| 36 | /// extension=".flac" | ||
| 37 | /// library_@PLATFORM@="@LIBRARY_FILENAME@"/> | ||
| 38 | /// ~~~~~~~~~~~~~ | ||
| 39 | /// | ||
| 40 | /// Description to audio encoder related addon.xml values: | ||
| 41 | /// | Name | Description | ||
| 42 | /// |:------------------------------|---------------------------------------- | ||
| 43 | /// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"kodi.audioencoder"</b>. | ||
| 44 | /// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build. | ||
| 45 | /// | <b>`extension`</b> | The file extensions / styles supported by this addon. | ||
| 46 | /// | ||
| 47 | /// -------------------------------------------------------------------------- | ||
| 48 | /// | ||
| 49 | /// -------------------------------------------------------------------------- | ||
| 50 | /// | ||
| 51 | /// **Here is a code example how this addon is used:** | ||
| 52 | /// | ||
| 53 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 54 | /// #include <kodi/addon-instance/AudioEncoder.h> | ||
| 55 | /// | ||
| 56 | /// class ATTRIBUTE_HIDDEN CMyAudioEncoder : public kodi::addon::CInstanceAudioEncoder | ||
| 57 | /// { | ||
| 58 | /// public: | ||
| 59 | /// CMyAudioEncoder(KODI_HANDLE instance, const std::string& kodiVersion) | ||
| 60 | /// : kodi::addon::CInstanceAudioEncoder(instance, kodiVersion) | ||
| 61 | /// | ||
| 62 | /// bool Init(const std::string& filename, unsigned int filecache, | ||
| 63 | /// int& channels, int& samplerate, | ||
| 64 | /// int& bitspersample, int64_t& totaltime, | ||
| 65 | /// int& bitrate, AEDataFormat& format, | ||
| 66 | /// std::vector<AEChannel>& channellist) override; | ||
| 67 | /// int Encode(int numBytesRead, const uint8_t* pbtStream) override; | ||
| 68 | /// bool Finish() override; // Optional | ||
| 69 | /// }; | ||
| 70 | /// | ||
| 71 | /// CMyAudioEncoder::CMyAudioEncoder(KODI_HANDLE instance) | ||
| 72 | /// : kodi::addon::CInstanceAudioEncoder(instance) | ||
| 73 | /// { | ||
| 74 | /// ... | ||
| 75 | /// } | ||
| 76 | /// | ||
| 77 | /// bool CMyAudioEncoder::Start(int inChannels, | ||
| 78 | /// int inRate, | ||
| 79 | /// int inBits, | ||
| 80 | /// const std::string& title, | ||
| 81 | /// const std::string& artist, | ||
| 82 | /// const std::string& albumartist, | ||
| 83 | /// const std::string& album, | ||
| 84 | /// const std::string& year, | ||
| 85 | /// const std::string& track, | ||
| 86 | /// const std::string& genre, | ||
| 87 | /// const std::string& comment, | ||
| 88 | /// int trackLength) | ||
| 89 | /// { | ||
| 90 | /// ... | ||
| 91 | /// return true; | ||
| 92 | /// } | ||
| 93 | /// | ||
| 94 | /// int CMyAudioEncoder::Encode(int numBytesRead, const uint8_t* pbtStream) | ||
| 95 | /// { | ||
| 96 | /// uint8_t* data = nullptr; | ||
| 97 | /// int length = 0; | ||
| 98 | /// ... | ||
| 99 | /// kodi::addon::CInstanceAudioEncoder::Write(data, length); | ||
| 100 | /// | ||
| 101 | /// return 0; | ||
| 102 | /// } | ||
| 103 | /// | ||
| 104 | /// | ||
| 105 | /// bool CMyAudioEncoder::Finish() | ||
| 106 | /// { | ||
| 107 | /// ... | ||
| 108 | /// return true; | ||
| 109 | /// } | ||
| 110 | /// | ||
| 111 | /// //---------------------------------------------------------------------- | ||
| 112 | /// | ||
| 113 | /// class CMyAddon : public kodi::addon::CAddonBase | ||
| 114 | /// { | ||
| 115 | /// public: | ||
| 116 | /// CMyAddon() = default; | ||
| 117 | /// ADDON_STATUS CreateInstance(int instanceType, | ||
| 118 | /// const std::string& instanceID, | ||
| 119 | /// KODI_HANDLE instance, | ||
| 120 | /// const std::string& version, | ||
| 121 | /// KODI_HANDLE& addonInstance) override; | ||
| 122 | /// }; | ||
| 123 | /// | ||
| 124 | /// // If you use only one instance in your add-on, can be instanceType and | ||
| 125 | /// // instanceID ignored | ||
| 126 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 127 | /// const std::string& instanceID, | ||
| 128 | /// KODI_HANDLE instance, | ||
| 129 | /// const std::string& version, | ||
| 130 | /// KODI_HANDLE& addonInstance) | ||
| 131 | /// { | ||
| 132 | /// if (instanceType == ADDON_INSTANCE_AUDIOENCODER) | ||
| 133 | /// { | ||
| 134 | /// kodi::Log(ADDON_LOG_INFO, "Creating my audio encoder instance"); | ||
| 135 | /// addonInstance = new CMyAudioEncoder(instance, version); | ||
| 136 | /// return ADDON_STATUS_OK; | ||
| 137 | /// } | ||
| 138 | /// else if (...) | ||
| 139 | /// { | ||
| 140 | /// ... | ||
| 141 | /// } | ||
| 142 | /// return ADDON_STATUS_UNKNOWN; | ||
| 143 | /// } | ||
| 144 | /// | ||
| 145 | /// ADDONCREATOR(CMyAddon) | ||
| 146 | /// ~~~~~~~~~~~~~ | ||
| 147 | /// | ||
| 148 | /// The destruction of the example class `CMyAudioEncoder` is called from | ||
| 149 | /// Kodi's header. Manually deleting the add-on instance is not required. | ||
| 150 | /// | ||
| 151 | class ATTRIBUTE_HIDDEN CInstanceAudioEncoder : public IAddonInstance | ||
| 152 | { | ||
| 153 | public: | ||
| 154 | //============================================================================ | ||
| 155 | /// @ingroup cpp_kodi_addon_audioencoder | ||
| 156 | /// @brief Audio encoder class constructor used to support multiple instances. | ||
| 157 | /// | ||
| 158 | /// @param[in] instance The instance value given to | ||
| 159 | /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>. | ||
| 160 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to | ||
| 161 | /// allow compatibility to older Kodi versions. | ||
| 162 | /// | ||
| 163 | /// @note Recommended to set <b>`kodiVersion`</b>. | ||
| 164 | /// | ||
| 165 | /// | ||
| 166 | /// -------------------------------------------------------------------------- | ||
| 167 | /// | ||
| 168 | /// **Here's example about the use of this:** | ||
| 169 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 170 | /// class CMyAudioEncoder : public kodi::addon::CInstanceAudioEncoder | ||
| 171 | /// { | ||
| 172 | /// public: | ||
| 173 | /// CMyAudioEncoder(KODI_HANDLE instance, const std::string& kodiVersion) | ||
| 174 | /// : kodi::addon::CInstanceAudioEncoder(instance, kodiVersion) | ||
| 175 | /// { | ||
| 176 | /// ... | ||
| 177 | /// } | ||
| 178 | /// | ||
| 179 | /// ... | ||
| 180 | /// }; | ||
| 181 | /// | ||
| 182 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 183 | /// const std::string& instanceID, | ||
| 184 | /// KODI_HANDLE instance, | ||
| 185 | /// const std::string& version, | ||
| 186 | /// KODI_HANDLE& addonInstance) | ||
| 187 | /// { | ||
| 188 | /// kodi::Log(ADDON_LOG_INFO, "Creating my audio encoder instance"); | ||
| 189 | /// addonInstance = new CMyAudioEncoder(instance, version); | ||
| 190 | /// return ADDON_STATUS_OK; | ||
| 191 | /// } | ||
| 192 | /// ~~~~~~~~~~~~~ | ||
| 193 | /// | ||
| 194 | explicit CInstanceAudioEncoder(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 195 | : IAddonInstance(ADDON_INSTANCE_AUDIOENCODER, | ||
| 196 | !kodiVersion.empty() ? kodiVersion | ||
| 197 | : GetKodiTypeVersion(ADDON_INSTANCE_AUDIOENCODER)) | ||
| 198 | { | ||
| 199 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 200 | throw std::logic_error("kodi::addon::CInstanceAudioEncoder: Creation of multiple together " | ||
| 201 | "with single instance way is not allowed!"); | ||
| 202 | |||
| 203 | SetAddonStruct(instance); | ||
| 204 | } | ||
| 205 | //---------------------------------------------------------------------------- | ||
| 206 | |||
| 207 | //============================================================================ | ||
| 208 | /// @ingroup cpp_kodi_addon_audioencoder | ||
| 209 | /// @brief Start encoder (**required**) | ||
| 210 | /// | ||
| 211 | /// @param[in] inChannels Number of channels | ||
| 212 | /// @param[in] inRate Sample rate of input data | ||
| 213 | /// @param[in] inBits Bits per sample in input data | ||
| 214 | /// @param[in] title The title of the song | ||
| 215 | /// @param[in] artist The artist of the song | ||
| 216 | /// @param[in] albumartist The albumartist of the song | ||
| 217 | /// @param[in] year The year of the song | ||
| 218 | /// @param[in] track The track number of the song | ||
| 219 | /// @param[in] genre The genre of the song | ||
| 220 | /// @param[in] comment A comment to attach to the song | ||
| 221 | /// @param[in] trackLength Total track length in seconds | ||
| 222 | /// @return True on success, false on failure. | ||
| 223 | /// | ||
| 224 | virtual bool Start(int inChannels, | ||
| 225 | int inRate, | ||
| 226 | int inBits, | ||
| 227 | const std::string& title, | ||
| 228 | const std::string& artist, | ||
| 229 | const std::string& albumartist, | ||
| 230 | const std::string& album, | ||
| 231 | const std::string& year, | ||
| 232 | const std::string& track, | ||
| 233 | const std::string& genre, | ||
| 234 | const std::string& comment, | ||
| 235 | int trackLength) = 0; | ||
| 236 | //---------------------------------------------------------------------------- | ||
| 237 | |||
| 238 | //============================================================================ | ||
| 239 | /// @ingroup cpp_kodi_addon_audioencoder | ||
| 240 | /// @brief Encode a chunk of audio (**required**) | ||
| 241 | /// | ||
| 242 | /// @param[in] numBytesRead Number of bytes in input buffer | ||
| 243 | /// @param[in] pbtStream The input buffer | ||
| 244 | /// @return Number of bytes consumed | ||
| 245 | /// | ||
| 246 | virtual int Encode(int numBytesRead, const uint8_t* pbtStream) = 0; | ||
| 247 | //---------------------------------------------------------------------------- | ||
| 248 | |||
| 249 | //============================================================================ | ||
| 250 | /// @ingroup cpp_kodi_addon_audioencoder | ||
| 251 | /// @brief Finalize encoding (**optional**) | ||
| 252 | /// | ||
| 253 | /// @return True on success, false on failure. | ||
| 254 | /// | ||
| 255 | virtual bool Finish() { return true; } | ||
| 256 | //---------------------------------------------------------------------------- | ||
| 257 | |||
| 258 | //============================================================================ | ||
| 259 | /// @ingroup cpp_kodi_addon_audioencoder | ||
| 260 | /// @brief Write block of data | ||
| 261 | /// | ||
| 262 | /// @param[in] data Pointer to the array of elements to be written | ||
| 263 | /// @param[in] length Size in bytes to be written. | ||
| 264 | /// @return The total number of bytes successfully written is returned. | ||
| 265 | /// | ||
| 266 | /// @remarks Only called from addon itself. | ||
| 267 | /// | ||
| 268 | int Write(const uint8_t* data, int length) | ||
| 269 | { | ||
| 270 | return m_instanceData->toKodi->write(m_instanceData->toKodi->kodiInstance, data, length); | ||
| 271 | } | ||
| 272 | //---------------------------------------------------------------------------- | ||
| 273 | |||
| 274 | //============================================================================ | ||
| 275 | /// @ingroup cpp_kodi_addon_audioencoder | ||
| 276 | /// @brief Set the file's current position. | ||
| 277 | /// | ||
| 278 | /// The whence argument is optional and defaults to SEEK_SET (0) | ||
| 279 | /// | ||
| 280 | /// @param[in] position The position that you want to seek to | ||
| 281 | /// @param[in] whence [optional] offset relative to\n | ||
| 282 | /// You can set the value of whence to one | ||
| 283 | /// of three things: | ||
| 284 | /// | Value | int | Description | | ||
| 285 | /// |:--------:|:---:|:---------------------------------------------------| | ||
| 286 | /// | SEEK_SET | 0 | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence. | ||
| 287 | /// | SEEK_CUR | 1 | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes." | ||
| 288 | /// | SEEK_END | 2 | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion. | ||
| 289 | /// | ||
| 290 | /// @return Returns the resulting offset location as measured in bytes from | ||
| 291 | /// the beginning of the file. On error, the value -1 is returned. | ||
| 292 | /// | ||
| 293 | /// @remarks Only called from addon itself. | ||
| 294 | /// | ||
| 295 | int64_t Seek(int64_t position, int whence = SEEK_SET) | ||
| 296 | { | ||
| 297 | return m_instanceData->toKodi->seek(m_instanceData->toKodi->kodiInstance, position, whence); | ||
| 298 | } | ||
| 299 | //---------------------------------------------------------------------------- | ||
| 300 | |||
| 301 | private: | ||
| 302 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 303 | { | ||
| 304 | if (instance == nullptr) | ||
| 305 | throw std::logic_error("kodi::addon::CInstanceAudioEncoder: Creation with empty addon " | ||
| 306 | "structure not allowed, table must be given from Kodi!"); | ||
| 307 | |||
| 308 | m_instanceData = static_cast<AddonInstance_AudioEncoder*>(instance); | ||
| 309 | m_instanceData->toAddon->addonInstance = this; | ||
| 310 | m_instanceData->toAddon->start = ADDON_Start; | ||
| 311 | m_instanceData->toAddon->encode = ADDON_Encode; | ||
| 312 | m_instanceData->toAddon->finish = ADDON_Finish; | ||
| 313 | } | ||
| 314 | |||
| 315 | inline static bool ADDON_Start(const AddonInstance_AudioEncoder* instance, | ||
| 316 | int inChannels, | ||
| 317 | int inRate, | ||
| 318 | int inBits, | ||
| 319 | const char* title, | ||
| 320 | const char* artist, | ||
| 321 | const char* albumartist, | ||
| 322 | const char* album, | ||
| 323 | const char* year, | ||
| 324 | const char* track, | ||
| 325 | const char* genre, | ||
| 326 | const char* comment, | ||
| 327 | int trackLength) | ||
| 328 | { | ||
| 329 | return static_cast<CInstanceAudioEncoder*>(instance->toAddon->addonInstance) | ||
| 330 | ->Start(inChannels, inRate, inBits, title, artist, albumartist, album, year, track, genre, | ||
| 331 | comment, trackLength); | ||
| 332 | } | ||
| 333 | |||
| 334 | inline static int ADDON_Encode(const AddonInstance_AudioEncoder* instance, | ||
| 335 | int numBytesRead, | ||
| 336 | const uint8_t* pbtStream) | ||
| 337 | { | ||
| 338 | return static_cast<CInstanceAudioEncoder*>(instance->toAddon->addonInstance) | ||
| 339 | ->Encode(numBytesRead, pbtStream); | ||
| 340 | } | ||
| 341 | |||
| 342 | inline static bool ADDON_Finish(const AddonInstance_AudioEncoder* instance) | ||
| 343 | { | ||
| 344 | return static_cast<CInstanceAudioEncoder*>(instance->toAddon->addonInstance)->Finish(); | ||
| 345 | } | ||
| 346 | |||
| 347 | AddonInstance_AudioEncoder* m_instanceData; | ||
| 348 | }; | ||
| 349 | |||
| 350 | } /* namespace addon */ | ||
| 351 | } /* namespace kodi */ | ||
| 352 | |||
| 353 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/CMakeLists.txt index 8fa6e05..a57def3 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/CMakeLists.txt | |||
| @@ -4,7 +4,6 @@ set(HEADERS AudioDecoder.h | |||
| 4 | ImageDecoder.h | 4 | ImageDecoder.h |
| 5 | Inputstream.h | 5 | Inputstream.h |
| 6 | Peripheral.h | 6 | Peripheral.h |
| 7 | PeripheralUtils.h | ||
| 8 | PVR.h | 7 | PVR.h |
| 9 | Screensaver.h | 8 | Screensaver.h |
| 10 | VFS.h | 9 | VFS.h |
| @@ -12,5 +11,5 @@ set(HEADERS AudioDecoder.h | |||
| 12 | Visualization.h) | 11 | Visualization.h) |
| 13 | 12 | ||
| 14 | if(NOT ENABLE_STATIC_LIBS) | 13 | if(NOT ENABLE_STATIC_LIBS) |
| 15 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_addon-instance) | 14 | core_add_library(addons_kodi-dev-kit_include_kodi_addon-instance) |
| 16 | endif() | 15 | endif() |
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Game.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Game.h new file mode 100644 index 0000000..3dca94d --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Game.h | |||
| @@ -0,0 +1,1190 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | #include "../c-api/addon-instance/game.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace addon | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================== | ||
| 22 | /// @addtogroup cpp_kodi_addon_game | ||
| 23 | /// | ||
| 24 | /// To use on Libretro and for stand-alone games or emulators that does not use | ||
| 25 | /// the Libretro API. | ||
| 26 | /// | ||
| 27 | /// Possible examples could be, Nvidia GameStream via Limelight or WINE capture | ||
| 28 | /// could possible through the Game API. | ||
| 29 | /// | ||
| 30 | |||
| 31 | //============================================================================== | ||
| 32 | /// @defgroup cpp_kodi_addon_game_Defs Definitions, structures and enumerators | ||
| 33 | /// @ingroup cpp_kodi_addon_game | ||
| 34 | /// @brief **Game add-on instance definition values** | ||
| 35 | /// | ||
| 36 | |||
| 37 | //============================================================================== | ||
| 38 | /// @defgroup cpp_kodi_addon_game_Defs_InputTypes_GameControllerLayout class GameControllerLayout | ||
| 39 | /// @ingroup cpp_kodi_addon_game_Defs_InputTypes | ||
| 40 | /// @brief Data of layouts for known controllers. | ||
| 41 | /// | ||
| 42 | /// Used on @ref kodi::addon::CInstanceGame::SetControllerLayouts(). | ||
| 43 | ///@{ | ||
| 44 | class GameControllerLayout | ||
| 45 | { | ||
| 46 | public: | ||
| 47 | /*! @cond PRIVATE */ | ||
| 48 | explicit GameControllerLayout() = default; | ||
| 49 | GameControllerLayout(const game_controller_layout& layout) | ||
| 50 | { | ||
| 51 | controller_id = layout.controller_id; | ||
| 52 | provides_input = layout.provides_input; | ||
| 53 | for (unsigned int i = 0; i < layout.digital_button_count; ++i) | ||
| 54 | digital_buttons.push_back(layout.digital_buttons[i]); | ||
| 55 | for (unsigned int i = 0; i < layout.analog_button_count; ++i) | ||
| 56 | analog_buttons.push_back(layout.analog_buttons[i]); | ||
| 57 | for (unsigned int i = 0; i < layout.analog_stick_count; ++i) | ||
| 58 | analog_sticks.push_back(layout.analog_sticks[i]); | ||
| 59 | for (unsigned int i = 0; i < layout.accelerometer_count; ++i) | ||
| 60 | accelerometers.push_back(layout.accelerometers[i]); | ||
| 61 | for (unsigned int i = 0; i < layout.key_count; ++i) | ||
| 62 | keys.push_back(layout.keys[i]); | ||
| 63 | for (unsigned int i = 0; i < layout.rel_pointer_count; ++i) | ||
| 64 | rel_pointers.push_back(layout.rel_pointers[i]); | ||
| 65 | for (unsigned int i = 0; i < layout.abs_pointer_count; ++i) | ||
| 66 | abs_pointers.push_back(layout.abs_pointers[i]); | ||
| 67 | for (unsigned int i = 0; i < layout.motor_count; ++i) | ||
| 68 | motors.push_back(layout.motors[i]); | ||
| 69 | } | ||
| 70 | /*! @endcond */ | ||
| 71 | |||
| 72 | /// @brief Controller identifier. | ||
| 73 | std::string controller_id; | ||
| 74 | |||
| 75 | /// @brief Provides input. | ||
| 76 | /// | ||
| 77 | /// False for multitaps | ||
| 78 | bool provides_input; | ||
| 79 | |||
| 80 | /// @brief Digital buttons. | ||
| 81 | std::vector<std::string> digital_buttons; | ||
| 82 | |||
| 83 | /// @brief Analog buttons. | ||
| 84 | std::vector<std::string> analog_buttons; | ||
| 85 | |||
| 86 | /// @brief Analog sticks. | ||
| 87 | std::vector<std::string> analog_sticks; | ||
| 88 | |||
| 89 | /// @brief Accelerometers. | ||
| 90 | std::vector<std::string> accelerometers; | ||
| 91 | |||
| 92 | /// @brief Keys. | ||
| 93 | std::vector<std::string> keys; | ||
| 94 | |||
| 95 | /// @brief Relative pointers. | ||
| 96 | std::vector<std::string> rel_pointers; | ||
| 97 | |||
| 98 | /// @brief Absolute pointers. | ||
| 99 | std::vector<std::string> abs_pointers; | ||
| 100 | |||
| 101 | /// @brief Motors. | ||
| 102 | std::vector<std::string> motors; | ||
| 103 | }; | ||
| 104 | ///@} | ||
| 105 | //------------------------------------------------------------------------------ | ||
| 106 | |||
| 107 | //============================================================================== | ||
| 108 | /// @addtogroup cpp_kodi_addon_game | ||
| 109 | /// @brief @cpp_class{ kodi::addon::CInstanceGame } | ||
| 110 | /// **Game add-on instance**\n | ||
| 111 | /// This class provides the basic game processing system for use as an add-on in | ||
| 112 | /// Kodi. | ||
| 113 | /// | ||
| 114 | /// This class is created at addon by Kodi. | ||
| 115 | /// | ||
| 116 | class ATTRIBUTE_HIDDEN CInstanceGame : public IAddonInstance | ||
| 117 | { | ||
| 118 | public: | ||
| 119 | //============================================================================ | ||
| 120 | /// @defgroup cpp_kodi_addon_game_Base 1. Basic functions | ||
| 121 | /// @ingroup cpp_kodi_addon_game | ||
| 122 | /// @brief **Functions to manage the addon and get basic information about it** | ||
| 123 | /// | ||
| 124 | ///@{ | ||
| 125 | |||
| 126 | //============================================================================ | ||
| 127 | /// @brief Game class constructor | ||
| 128 | /// | ||
| 129 | /// Used by an add-on that only supports only Game and only in one instance. | ||
| 130 | /// | ||
| 131 | /// This class is created at addon by Kodi. | ||
| 132 | /// | ||
| 133 | /// | ||
| 134 | /// -------------------------------------------------------------------------- | ||
| 135 | /// | ||
| 136 | /// | ||
| 137 | /// **Here's example about the use of this:** | ||
| 138 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 139 | /// #include <kodi/addon-instance/Game.h> | ||
| 140 | /// ... | ||
| 141 | /// | ||
| 142 | /// class ATTRIBUTE_HIDDEN CGameExample | ||
| 143 | /// : public kodi::addon::CAddonBase, | ||
| 144 | /// public kodi::addon::CInstanceGame | ||
| 145 | /// { | ||
| 146 | /// public: | ||
| 147 | /// CGameExample() | ||
| 148 | /// { | ||
| 149 | /// } | ||
| 150 | /// | ||
| 151 | /// virtual ~CGameExample(); | ||
| 152 | /// { | ||
| 153 | /// } | ||
| 154 | /// | ||
| 155 | /// ... | ||
| 156 | /// }; | ||
| 157 | /// | ||
| 158 | /// ADDONCREATOR(CGameExample) | ||
| 159 | /// ~~~~~~~~~~~~~ | ||
| 160 | /// | ||
| 161 | CInstanceGame() : IAddonInstance(ADDON_INSTANCE_GAME, GetKodiTypeVersion(ADDON_INSTANCE_GAME)) | ||
| 162 | { | ||
| 163 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 164 | throw std::logic_error("kodi::addon::CInstanceGame: Creation of more as one in single " | ||
| 165 | "instance way is not allowed!"); | ||
| 166 | |||
| 167 | SetAddonStruct(CAddonBase::m_interface->firstKodiInstance); | ||
| 168 | CAddonBase::m_interface->globalSingleInstance = this; | ||
| 169 | } | ||
| 170 | //---------------------------------------------------------------------------- | ||
| 171 | |||
| 172 | //============================================================================ | ||
| 173 | /// @brief Destructor | ||
| 174 | /// | ||
| 175 | ~CInstanceGame() override = default; | ||
| 176 | //---------------------------------------------------------------------------- | ||
| 177 | |||
| 178 | //============================================================================ | ||
| 179 | /// @brief **Callback to Kodi Function**\n | ||
| 180 | /// The path of the game client being loaded. | ||
| 181 | /// | ||
| 182 | /// @return the used game client Dll path | ||
| 183 | /// | ||
| 184 | /// @remarks Only called from addon itself | ||
| 185 | /// | ||
| 186 | std::string GameClientDllPath() const { return m_instanceData->props->game_client_dll_path; } | ||
| 187 | //---------------------------------------------------------------------------- | ||
| 188 | |||
| 189 | //============================================================================ | ||
| 190 | /// @brief **Callback to Kodi Function**\n | ||
| 191 | /// Paths to proxy DLLs used to load the game client. | ||
| 192 | /// | ||
| 193 | /// @param[out] paths vector list to store available dll paths | ||
| 194 | /// @return true if success and dll paths present | ||
| 195 | /// | ||
| 196 | /// @remarks Only called from addon itself | ||
| 197 | /// | ||
| 198 | bool ProxyDllPaths(std::vector<std::string>& paths) | ||
| 199 | { | ||
| 200 | for (unsigned int i = 0; i < m_instanceData->props->proxy_dll_count; ++i) | ||
| 201 | { | ||
| 202 | if (m_instanceData->props->proxy_dll_paths[i] != nullptr) | ||
| 203 | paths.push_back(m_instanceData->props->proxy_dll_paths[i]); | ||
| 204 | } | ||
| 205 | return !paths.empty(); | ||
| 206 | } | ||
| 207 | //---------------------------------------------------------------------------- | ||
| 208 | |||
| 209 | //============================================================================ | ||
| 210 | /// @brief **Callback to Kodi Function**\n | ||
| 211 | /// The "system" directories of the frontend. | ||
| 212 | /// | ||
| 213 | /// These directories can be used to store system-specific ROMs such as | ||
| 214 | /// BIOSes, configuration data, etc. | ||
| 215 | /// | ||
| 216 | /// @return the used resource directory | ||
| 217 | /// | ||
| 218 | /// @remarks Only called from addon itself | ||
| 219 | /// | ||
| 220 | bool ResourceDirectories(std::vector<std::string>& dirs) | ||
| 221 | { | ||
| 222 | for (unsigned int i = 0; i < m_instanceData->props->resource_directory_count; ++i) | ||
| 223 | { | ||
| 224 | if (m_instanceData->props->resource_directories[i] != nullptr) | ||
| 225 | dirs.push_back(m_instanceData->props->resource_directories[i]); | ||
| 226 | } | ||
| 227 | return !dirs.empty(); | ||
| 228 | } | ||
| 229 | //---------------------------------------------------------------------------- | ||
| 230 | |||
| 231 | //============================================================================ | ||
| 232 | /// @brief **Callback to Kodi Function**\n | ||
| 233 | /// The writable directory of the frontend. | ||
| 234 | /// | ||
| 235 | /// This directory can be used to store SRAM, memory cards, high scores, | ||
| 236 | /// etc, if the game client cannot use the regular memory interface, | ||
| 237 | /// GetMemoryData(). | ||
| 238 | /// | ||
| 239 | /// @return the used profile directory | ||
| 240 | /// | ||
| 241 | /// @remarks Only called from addon itself | ||
| 242 | /// | ||
| 243 | std::string ProfileDirectory() const { return m_instanceData->props->profile_directory; } | ||
| 244 | //---------------------------------------------------------------------------- | ||
| 245 | |||
| 246 | //============================================================================ | ||
| 247 | /// @brief **Callback to Kodi Function**\n | ||
| 248 | /// The value of the <supports_vfs> property from addon.xml. | ||
| 249 | /// | ||
| 250 | /// @return true if VFS is supported | ||
| 251 | /// | ||
| 252 | /// @remarks Only called from addon itself | ||
| 253 | /// | ||
| 254 | bool SupportsVFS() const { return m_instanceData->props->supports_vfs; } | ||
| 255 | //---------------------------------------------------------------------------- | ||
| 256 | |||
| 257 | //============================================================================ | ||
| 258 | /// @brief **Callback to Kodi Function**\n | ||
| 259 | /// The extensions in the <extensions> property from addon.xml. | ||
| 260 | /// | ||
| 261 | /// @param[out] extensions vector list to store available extension | ||
| 262 | /// @return true if success and extensions present | ||
| 263 | /// | ||
| 264 | /// @remarks Only called from addon itself | ||
| 265 | /// | ||
| 266 | bool Extensions(std::vector<std::string>& extensions) | ||
| 267 | { | ||
| 268 | for (unsigned int i = 0; i < m_instanceData->props->extension_count; ++i) | ||
| 269 | { | ||
| 270 | if (m_instanceData->props->extensions[i] != nullptr) | ||
| 271 | extensions.push_back(m_instanceData->props->extensions[i]); | ||
| 272 | } | ||
| 273 | return !extensions.empty(); | ||
| 274 | } | ||
| 275 | //---------------------------------------------------------------------------- | ||
| 276 | |||
| 277 | ///@} | ||
| 278 | |||
| 279 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 280 | |||
| 281 | //============================================================================ | ||
| 282 | /// | ||
| 283 | /// @defgroup cpp_kodi_addon_game_Operation 2. Game operations | ||
| 284 | /// @ingroup cpp_kodi_addon_game | ||
| 285 | /// @brief **Game operations** | ||
| 286 | /// | ||
| 287 | /// These are mandatory functions for using this addon to get the available | ||
| 288 | /// channels. | ||
| 289 | /// | ||
| 290 | /// | ||
| 291 | ///--------------------------------------------------------------------------- | ||
| 292 | /// | ||
| 293 | /// **Game operation parts in interface:**\n | ||
| 294 | /// Copy this to your project and extend with your parts or leave functions | ||
| 295 | /// complete away where not used or supported. | ||
| 296 | /// | ||
| 297 | /// @copydetails cpp_kodi_addon_game_Operation_header_addon_auto_check | ||
| 298 | /// @copydetails cpp_kodi_addon_game_Operation_source_addon_auto_check | ||
| 299 | /// | ||
| 300 | ///@{ | ||
| 301 | |||
| 302 | //============================================================================ | ||
| 303 | /// @brief Load a game | ||
| 304 | /// | ||
| 305 | /// @param[in] url The URL to load | ||
| 306 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was loaded | ||
| 307 | /// | ||
| 308 | virtual GAME_ERROR LoadGame(const std::string& url) | ||
| 309 | { | ||
| 310 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 311 | } | ||
| 312 | //---------------------------------------------------------------------------- | ||
| 313 | |||
| 314 | //============================================================================ | ||
| 315 | /// @brief Load a game that requires multiple files | ||
| 316 | /// | ||
| 317 | /// @param[in] type The game type | ||
| 318 | /// @param[in] urls An array of urls | ||
| 319 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was loaded | ||
| 320 | /// | ||
| 321 | virtual GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const std::vector<std::string>& urls) | ||
| 322 | { | ||
| 323 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 324 | } | ||
| 325 | //---------------------------------------------------------------------------- | ||
| 326 | |||
| 327 | //============================================================================ | ||
| 328 | /// @brief Begin playing without a game file | ||
| 329 | /// | ||
| 330 | /// If the add-on supports standalone mode, it must add the <supports_standalone> | ||
| 331 | /// tag to the extension point in addon.xml: | ||
| 332 | /// | ||
| 333 | /// <supports_no_game>false</supports_no_game> | ||
| 334 | /// | ||
| 335 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game add-on was loaded | ||
| 336 | /// | ||
| 337 | virtual GAME_ERROR LoadStandalone() | ||
| 338 | { | ||
| 339 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 340 | } | ||
| 341 | //---------------------------------------------------------------------------- | ||
| 342 | |||
| 343 | //============================================================================ | ||
| 344 | /// @brief Unload the current game | ||
| 345 | /// | ||
| 346 | /// Unloads a currently loaded game | ||
| 347 | /// | ||
| 348 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was unloaded | ||
| 349 | /// | ||
| 350 | virtual GAME_ERROR UnloadGame() | ||
| 351 | { | ||
| 352 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 353 | } | ||
| 354 | //---------------------------------------------------------------------------- | ||
| 355 | |||
| 356 | //============================================================================ | ||
| 357 | /// @brief Get timing information about the loaded game | ||
| 358 | /// | ||
| 359 | /// @param[out] timing_info The info structure to fill | ||
| 360 | /// | ||
| 361 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if info was filled | ||
| 362 | /// | ||
| 363 | virtual GAME_ERROR GetGameTiming(game_system_timing& timing_info) | ||
| 364 | { | ||
| 365 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 366 | } | ||
| 367 | //---------------------------------------------------------------------------- | ||
| 368 | |||
| 369 | //============================================================================ | ||
| 370 | /// @brief Get region of the loaded game | ||
| 371 | /// | ||
| 372 | /// @return the region, or @ref GAME_REGION_UNKNOWN if unknown or no game is loaded | ||
| 373 | /// | ||
| 374 | virtual GAME_REGION GetRegion() | ||
| 375 | { | ||
| 376 | return GAME_REGION_UNKNOWN; | ||
| 377 | } | ||
| 378 | //---------------------------------------------------------------------------- | ||
| 379 | |||
| 380 | //============================================================================ | ||
| 381 | /// @brief Return true if the client requires the frontend to provide a game loop | ||
| 382 | /// | ||
| 383 | /// The game loop is a thread that calls RunFrame() in a loop at a rate | ||
| 384 | /// determined by the playback speed and the client's FPS. | ||
| 385 | /// | ||
| 386 | /// @return true if the frontend should provide a game loop, false otherwise | ||
| 387 | /// | ||
| 388 | virtual bool RequiresGameLoop() | ||
| 389 | { | ||
| 390 | return false; | ||
| 391 | } | ||
| 392 | //---------------------------------------------------------------------------- | ||
| 393 | |||
| 394 | //============================================================================ | ||
| 395 | /// @brief Run a single frame for add-ons that use a game loop | ||
| 396 | /// | ||
| 397 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if there was no error | ||
| 398 | /// | ||
| 399 | virtual GAME_ERROR RunFrame() | ||
| 400 | { | ||
| 401 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 402 | } | ||
| 403 | //---------------------------------------------------------------------------- | ||
| 404 | |||
| 405 | //============================================================================ | ||
| 406 | /// @brief Reset the current game | ||
| 407 | /// | ||
| 408 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was reset | ||
| 409 | /// | ||
| 410 | virtual GAME_ERROR Reset() | ||
| 411 | { | ||
| 412 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 413 | } | ||
| 414 | //---------------------------------------------------------------------------- | ||
| 415 | |||
| 416 | //========================================================================== | ||
| 417 | /// @brief **Callback to Kodi Function**\n | ||
| 418 | /// Requests the frontend to stop the current game | ||
| 419 | /// | ||
| 420 | /// @remarks Only called from addon itself | ||
| 421 | /// | ||
| 422 | void CloseGame(void) { m_instanceData->toKodi->CloseGame(m_instanceData->toKodi->kodiInstance); } | ||
| 423 | //---------------------------------------------------------------------------- | ||
| 424 | |||
| 425 | //============================================================================ | ||
| 426 | /// @defgroup cpp_kodi_addon_game_Operation_CStream Class: CStream | ||
| 427 | /// @ingroup cpp_kodi_addon_game_Operation | ||
| 428 | /// @brief @cpp_class{ kodi::addon::CInstanceGame::CStream } | ||
| 429 | /// **Game stream handler** | ||
| 430 | /// | ||
| 431 | /// This class will be integrated into the addon, which can then open it if | ||
| 432 | /// necessary for the processing of an audio or video stream. | ||
| 433 | /// | ||
| 434 | /// | ||
| 435 | /// @note Callback to Kodi class | ||
| 436 | ///@{ | ||
| 437 | class CStream | ||
| 438 | { | ||
| 439 | public: | ||
| 440 | CStream() = default; | ||
| 441 | |||
| 442 | CStream(const game_stream_properties& properties) | ||
| 443 | { | ||
| 444 | Open(properties); | ||
| 445 | } | ||
| 446 | |||
| 447 | ~CStream() | ||
| 448 | { | ||
| 449 | Close(); | ||
| 450 | } | ||
| 451 | |||
| 452 | //========================================================================== | ||
| 453 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 454 | /// @brief Create a stream for gameplay data | ||
| 455 | /// | ||
| 456 | /// @param[in] properties The stream properties | ||
| 457 | /// @return A stream handle, or `nullptr` on failure | ||
| 458 | /// | ||
| 459 | /// @remarks Only called from addon itself | ||
| 460 | /// | ||
| 461 | bool Open(const game_stream_properties& properties) | ||
| 462 | { | ||
| 463 | if (!CAddonBase::m_interface->globalSingleInstance) | ||
| 464 | return false; | ||
| 465 | |||
| 466 | if (m_handle) | ||
| 467 | { | ||
| 468 | kodi::Log(ADDON_LOG_INFO, "kodi::addon::CInstanceGame::CStream already becomes reopened"); | ||
| 469 | Close(); | ||
| 470 | } | ||
| 471 | |||
| 472 | AddonToKodiFuncTable_Game& cb = | ||
| 473 | *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 474 | ->m_instanceData->toKodi; | ||
| 475 | m_handle = cb.OpenStream(cb.kodiInstance, &properties); | ||
| 476 | return m_handle != nullptr; | ||
| 477 | } | ||
| 478 | //-------------------------------------------------------------------------- | ||
| 479 | |||
| 480 | //========================================================================== | ||
| 481 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 482 | /// @brief Free the specified stream | ||
| 483 | /// | ||
| 484 | /// @remarks Only called from addon itself | ||
| 485 | /// | ||
| 486 | void Close() | ||
| 487 | { | ||
| 488 | if (!m_handle || !CAddonBase::m_interface->globalSingleInstance) | ||
| 489 | return; | ||
| 490 | |||
| 491 | AddonToKodiFuncTable_Game& cb = | ||
| 492 | *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 493 | ->m_instanceData->toKodi; | ||
| 494 | cb.CloseStream(cb.kodiInstance, m_handle); | ||
| 495 | m_handle = nullptr; | ||
| 496 | } | ||
| 497 | //-------------------------------------------------------------------------- | ||
| 498 | |||
| 499 | //========================================================================== | ||
| 500 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 501 | /// @brief Get a buffer for zero-copy stream data | ||
| 502 | /// | ||
| 503 | /// @param[in] width The framebuffer width, or 0 for no width specified | ||
| 504 | /// @param[in] height The framebuffer height, or 0 for no height specified | ||
| 505 | /// @param[out] buffer The buffer, or unmodified if false is returned | ||
| 506 | /// @return True if buffer was set, false otherwise | ||
| 507 | /// | ||
| 508 | /// @note If this returns true, buffer must be freed using @ref ReleaseBuffer(). | ||
| 509 | /// | ||
| 510 | /// @remarks Only called from addon itself | ||
| 511 | /// | ||
| 512 | bool GetBuffer(unsigned int width, unsigned int height, game_stream_buffer& buffer) | ||
| 513 | { | ||
| 514 | if (!m_handle || !CAddonBase::m_interface->globalSingleInstance) | ||
| 515 | return false; | ||
| 516 | |||
| 517 | AddonToKodiFuncTable_Game& cb = | ||
| 518 | *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 519 | ->m_instanceData->toKodi; | ||
| 520 | return cb.GetStreamBuffer(cb.kodiInstance, m_handle, width, height, &buffer); | ||
| 521 | } | ||
| 522 | //-------------------------------------------------------------------------- | ||
| 523 | |||
| 524 | //========================================================================== | ||
| 525 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 526 | /// @brief Add a data packet to a stream | ||
| 527 | /// | ||
| 528 | /// @param[in] packet The data packet | ||
| 529 | /// | ||
| 530 | /// @remarks Only called from addon itself | ||
| 531 | /// | ||
| 532 | void AddData(const game_stream_packet& packet) | ||
| 533 | { | ||
| 534 | if (!m_handle || !CAddonBase::m_interface->globalSingleInstance) | ||
| 535 | return; | ||
| 536 | |||
| 537 | AddonToKodiFuncTable_Game& cb = | ||
| 538 | *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 539 | ->m_instanceData->toKodi; | ||
| 540 | cb.AddStreamData(cb.kodiInstance, m_handle, &packet); | ||
| 541 | } | ||
| 542 | //-------------------------------------------------------------------------- | ||
| 543 | |||
| 544 | //========================================================================== | ||
| 545 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 546 | /// @brief Free an allocated buffer | ||
| 547 | /// | ||
| 548 | /// @param[in] buffer The buffer returned from GetStreamBuffer() | ||
| 549 | /// | ||
| 550 | /// @remarks Only called from addon itself | ||
| 551 | /// | ||
| 552 | void ReleaseBuffer(game_stream_buffer& buffer) | ||
| 553 | { | ||
| 554 | if (!m_handle || !CAddonBase::m_interface->globalSingleInstance) | ||
| 555 | return; | ||
| 556 | |||
| 557 | AddonToKodiFuncTable_Game& cb = | ||
| 558 | *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 559 | ->m_instanceData->toKodi; | ||
| 560 | cb.ReleaseStreamBuffer(cb.kodiInstance, m_handle, &buffer); | ||
| 561 | } | ||
| 562 | //-------------------------------------------------------------------------- | ||
| 563 | |||
| 564 | //========================================================================== | ||
| 565 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 566 | /// @brief To check stream open was OK, e.g. after use of constructor | ||
| 567 | /// | ||
| 568 | /// @return true if stream was successfully opened | ||
| 569 | /// | ||
| 570 | /// @remarks Only called from addon itself | ||
| 571 | /// | ||
| 572 | bool IsOpen() const { return m_handle != nullptr; } | ||
| 573 | //-------------------------------------------------------------------------- | ||
| 574 | |||
| 575 | private: | ||
| 576 | KODI_GAME_STREAM_HANDLE m_handle = nullptr; | ||
| 577 | }; | ||
| 578 | ///@} | ||
| 579 | |||
| 580 | ///@} | ||
| 581 | |||
| 582 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 583 | |||
| 584 | //============================================================================ | ||
| 585 | /// | ||
| 586 | /// @defgroup cpp_kodi_addon_game_HardwareRendering 3. Hardware rendering operations | ||
| 587 | /// @ingroup cpp_kodi_addon_game | ||
| 588 | /// @brief **Hardware rendering operations** | ||
| 589 | /// | ||
| 590 | /// | ||
| 591 | ///--------------------------------------------------------------------------- | ||
| 592 | /// | ||
| 593 | /// **Hardware rendering operation parts in interface:**\n | ||
| 594 | /// Copy this to your project and extend with your parts or leave functions | ||
| 595 | /// complete away where not used or supported. | ||
| 596 | /// | ||
| 597 | /// @copydetails cpp_kodi_addon_game_HardwareRendering_header_addon_auto_check | ||
| 598 | /// @copydetails cpp_kodi_addon_game_HardwareRendering_source_addon_auto_check | ||
| 599 | /// | ||
| 600 | ///@{ | ||
| 601 | |||
| 602 | //============================================================================ | ||
| 603 | /// @brief Invalidates the current HW context and reinitializes GPU resources | ||
| 604 | /// | ||
| 605 | /// Any GL state is lost, and must not be deinitialized explicitly. | ||
| 606 | /// | ||
| 607 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the HW context was reset | ||
| 608 | /// | ||
| 609 | virtual GAME_ERROR HwContextReset() | ||
| 610 | { | ||
| 611 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 612 | } | ||
| 613 | //---------------------------------------------------------------------------- | ||
| 614 | |||
| 615 | //============================================================================ | ||
| 616 | /// @brief Called before the context is destroyed | ||
| 617 | /// | ||
| 618 | /// Resources can be deinitialized at this step. | ||
| 619 | /// | ||
| 620 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the HW context was destroyed | ||
| 621 | /// | ||
| 622 | virtual GAME_ERROR HwContextDestroy() | ||
| 623 | { | ||
| 624 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 625 | } | ||
| 626 | |||
| 627 | //============================================================================ | ||
| 628 | /// @brief **Callback to Kodi Function**<br>Get a symbol from the hardware context | ||
| 629 | /// | ||
| 630 | /// @param[in] sym The symbol's name | ||
| 631 | /// | ||
| 632 | /// @return A function pointer for the specified symbol | ||
| 633 | /// | ||
| 634 | /// @remarks Only called from addon itself | ||
| 635 | /// | ||
| 636 | game_proc_address_t HwGetProcAddress(const char* sym) | ||
| 637 | { | ||
| 638 | return m_instanceData->toKodi->HwGetProcAddress(m_instanceData->toKodi->kodiInstance, sym); | ||
| 639 | } | ||
| 640 | //---------------------------------------------------------------------------- | ||
| 641 | |||
| 642 | ///@} | ||
| 643 | |||
| 644 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 645 | |||
| 646 | //============================================================================ | ||
| 647 | /// @defgroup cpp_kodi_addon_game_InputOperations 4. Input operations | ||
| 648 | /// @ingroup cpp_kodi_addon_game | ||
| 649 | /// @brief **Input operations** | ||
| 650 | /// | ||
| 651 | /// | ||
| 652 | ///--------------------------------------------------------------------------- | ||
| 653 | /// | ||
| 654 | /// **Hardware rendering operation parts in interface:**\n | ||
| 655 | /// Copy this to your project and extend with your parts or leave functions | ||
| 656 | /// complete away where not used or supported. | ||
| 657 | /// | ||
| 658 | /// @copydetails cpp_kodi_addon_game_InputOperations_header_addon_auto_check | ||
| 659 | /// @copydetails cpp_kodi_addon_game_InputOperations_source_addon_auto_check | ||
| 660 | /// | ||
| 661 | ///@{ | ||
| 662 | |||
| 663 | //============================================================================ | ||
| 664 | /// @brief Check if input is accepted for a feature on the controller | ||
| 665 | /// | ||
| 666 | /// If only a subset of the controller profile is used, this can return false | ||
| 667 | /// for unsupported features to not absorb their input. | ||
| 668 | /// | ||
| 669 | /// If the entire controller profile is used, this should always return true. | ||
| 670 | /// | ||
| 671 | /// @param[in] controller_id The ID of the controller profile | ||
| 672 | /// @param[in] feature_name The name of a feature in that profile | ||
| 673 | /// @return true if input is accepted for the feature, false otherwise | ||
| 674 | /// | ||
| 675 | virtual bool HasFeature(const std::string& controller_id, const std::string& feature_name) | ||
| 676 | { | ||
| 677 | return false; | ||
| 678 | } | ||
| 679 | //---------------------------------------------------------------------------- | ||
| 680 | |||
| 681 | //============================================================================ | ||
| 682 | /// @brief Get the input topology that specifies which controllers can be connected | ||
| 683 | /// | ||
| 684 | /// @return The input topology, or null to use the default | ||
| 685 | /// | ||
| 686 | /// If this returns non-null, topology must be freed using FreeTopology(). | ||
| 687 | /// | ||
| 688 | /// If this returns null, the topology will default to a single port that can | ||
| 689 | /// accept all controllers imported by addon.xml. The port ID is set to | ||
| 690 | /// the @ref DEFAULT_PORT_ID constant. | ||
| 691 | /// | ||
| 692 | virtual game_input_topology* GetTopology() | ||
| 693 | { | ||
| 694 | return nullptr; | ||
| 695 | } | ||
| 696 | //---------------------------------------------------------------------------- | ||
| 697 | |||
| 698 | //============================================================================ | ||
| 699 | /// @brief Free the topology's resources | ||
| 700 | /// | ||
| 701 | /// @param[in] topology The topology returned by GetTopology() | ||
| 702 | /// | ||
| 703 | virtual void FreeTopology(game_input_topology* topology) | ||
| 704 | { | ||
| 705 | } | ||
| 706 | //---------------------------------------------------------------------------- | ||
| 707 | |||
| 708 | //============================================================================ | ||
| 709 | /// @brief Set the layouts for known controllers | ||
| 710 | /// | ||
| 711 | /// @param[in] controllers The controller layouts | ||
| 712 | /// | ||
| 713 | /// After loading the input topology, the frontend will call this with | ||
| 714 | /// controller layouts for all controllers discovered in the topology. | ||
| 715 | /// | ||
| 716 | virtual void SetControllerLayouts(const std::vector<kodi::addon::GameControllerLayout>& controllers) | ||
| 717 | { | ||
| 718 | } | ||
| 719 | //---------------------------------------------------------------------------- | ||
| 720 | |||
| 721 | //============================================================================ | ||
| 722 | /// @brief Enable/disable keyboard input using the specified controller | ||
| 723 | /// | ||
| 724 | /// @param[in] enable True to enable input, false otherwise | ||
| 725 | /// @param[in] controller_id The controller ID if enabling, or unused if disabling | ||
| 726 | /// | ||
| 727 | /// @return True if keyboard input was enabled, false otherwise | ||
| 728 | /// | ||
| 729 | virtual bool EnableKeyboard(bool enable, const std::string& controller_id) | ||
| 730 | { | ||
| 731 | return false; | ||
| 732 | } | ||
| 733 | //---------------------------------------------------------------------------- | ||
| 734 | |||
| 735 | //============================================================================ | ||
| 736 | /// @brief Enable/disable mouse input using the specified controller | ||
| 737 | /// | ||
| 738 | /// @param[in] enable True to enable input, false otherwise | ||
| 739 | /// @param[in] controller_id The controller ID if enabling, or unused if disabling | ||
| 740 | /// | ||
| 741 | /// @return True if mouse input was enabled, false otherwise | ||
| 742 | /// | ||
| 743 | virtual bool EnableMouse(bool enable, const std::string& controller_id) | ||
| 744 | { | ||
| 745 | return false; | ||
| 746 | } | ||
| 747 | //-------------------------------------------------------------------------- | ||
| 748 | |||
| 749 | //========================================================================== | ||
| 750 | /// @brief Connect/disconnect a controller to a port on the virtual game console | ||
| 751 | /// | ||
| 752 | /// @param[in] connect True to connect a controller, false to disconnect | ||
| 753 | /// @param[in] port_address The address of the port | ||
| 754 | /// @param[in] controller_id The controller ID if connecting, or unused if disconnecting | ||
| 755 | /// @return True if the \p controller was (dis-)connected to the port, false otherwise | ||
| 756 | /// | ||
| 757 | /// The address is a string that allows traversal of the controller topology. | ||
| 758 | /// It is formed by alternating port IDs and controller IDs separated by "/". | ||
| 759 | /// | ||
| 760 | /// For example, assume that the topology represented in XML for Snes9x is: | ||
| 761 | /// | ||
| 762 | /// ~~~~~~~~~~~~~{.xml} | ||
| 763 | /// <logicaltopology> | ||
| 764 | /// <port type="controller" id="1"> | ||
| 765 | /// <accepts controller="game.controller.snes"/> | ||
| 766 | /// <accepts controller="game.controller.snes.multitap"> | ||
| 767 | /// <port type="controller" id="1"> | ||
| 768 | /// <accepts controller="game.controller.snes"/> | ||
| 769 | /// </port> | ||
| 770 | /// <port type="controller" id="2"> | ||
| 771 | /// <accepts controller="game.controller.snes"/> | ||
| 772 | /// </port> | ||
| 773 | /// ... | ||
| 774 | /// </accepts> | ||
| 775 | /// </port> | ||
| 776 | /// </logicaltopology> | ||
| 777 | /// ~~~~~~~~~~~~~ | ||
| 778 | /// | ||
| 779 | /// To connect a multitap to the console's first port, the multitap's controller | ||
| 780 | /// info is set using the port address: | ||
| 781 | /// | ||
| 782 | /// 1 | ||
| 783 | /// | ||
| 784 | /// To connect a SNES controller to the second port of the multitap, the | ||
| 785 | /// controller info is next set using the address: | ||
| 786 | /// | ||
| 787 | /// 1/game.controller.multitap/2 | ||
| 788 | /// | ||
| 789 | /// Any attempts to connect a controller to a port on a disconnected multitap | ||
| 790 | /// will return false. | ||
| 791 | /// | ||
| 792 | virtual bool ConnectController(bool connect, | ||
| 793 | const std::string& port_address, | ||
| 794 | const std::string& controller_id) | ||
| 795 | { | ||
| 796 | return false; | ||
| 797 | } | ||
| 798 | //---------------------------------------------------------------------------- | ||
| 799 | |||
| 800 | //============================================================================ | ||
| 801 | /// @brief Notify the add-on of an input event | ||
| 802 | /// | ||
| 803 | /// @param[in] event The input event | ||
| 804 | /// | ||
| 805 | /// @return true if the event was handled, false otherwise | ||
| 806 | /// | ||
| 807 | virtual bool InputEvent(const game_input_event& event) | ||
| 808 | { | ||
| 809 | return false; | ||
| 810 | } | ||
| 811 | //---------------------------------------------------------------------------- | ||
| 812 | |||
| 813 | //============================================================================ | ||
| 814 | /// @brief **Callback to Kodi Function**<br>Notify the port of an input event | ||
| 815 | /// | ||
| 816 | /// @param[in] event The input event | ||
| 817 | /// @return true if the event was handled, false otherwise | ||
| 818 | /// | ||
| 819 | /// @note Input events can arrive for the following sources: | ||
| 820 | /// - @ref GAME_INPUT_EVENT_MOTOR | ||
| 821 | /// | ||
| 822 | /// @remarks Only called from addon itself | ||
| 823 | /// | ||
| 824 | bool KodiInputEvent(const game_input_event& event) | ||
| 825 | { | ||
| 826 | return m_instanceData->toKodi->InputEvent(m_instanceData->toKodi->kodiInstance, &event); | ||
| 827 | } | ||
| 828 | //---------------------------------------------------------------------------- | ||
| 829 | |||
| 830 | ///@} | ||
| 831 | |||
| 832 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 833 | |||
| 834 | //============================================================================ | ||
| 835 | /// @defgroup cpp_kodi_addon_game_SerializationOperations 5. Serialization operations | ||
| 836 | /// @ingroup cpp_kodi_addon_game | ||
| 837 | /// @brief **Serialization operations** | ||
| 838 | /// | ||
| 839 | /// | ||
| 840 | ///--------------------------------------------------------------------------- | ||
| 841 | /// | ||
| 842 | /// **Serialization operation parts in interface:**\n | ||
| 843 | /// Copy this to your project and extend with your parts or leave functions | ||
| 844 | /// complete away where not used or supported. | ||
| 845 | /// | ||
| 846 | /// @copydetails cpp_kodi_addon_game_SerializationOperations_header_addon_auto_check | ||
| 847 | /// @copydetails cpp_kodi_addon_game_SerializationOperations_source_addon_auto_check | ||
| 848 | /// | ||
| 849 | ///@{ | ||
| 850 | |||
| 851 | //============================================================================ | ||
| 852 | /// @brief Get the number of bytes required to serialize the game | ||
| 853 | /// | ||
| 854 | /// @return the number of bytes, or 0 if serialization is not supported | ||
| 855 | /// | ||
| 856 | virtual size_t SerializeSize() | ||
| 857 | { | ||
| 858 | return 0; | ||
| 859 | } | ||
| 860 | //---------------------------------------------------------------------------- | ||
| 861 | |||
| 862 | //============================================================================ | ||
| 863 | /// @brief Serialize the state of the game | ||
| 864 | /// | ||
| 865 | /// @param[in] data The buffer receiving the serialized game data | ||
| 866 | /// @param[in] size The size of the buffer | ||
| 867 | /// | ||
| 868 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was serialized into the buffer | ||
| 869 | /// | ||
| 870 | virtual GAME_ERROR Serialize(uint8_t* data, size_t size) | ||
| 871 | { | ||
| 872 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 873 | } | ||
| 874 | //---------------------------------------------------------------------------- | ||
| 875 | |||
| 876 | //============================================================================ | ||
| 877 | /// @brief Deserialize the game from the given state | ||
| 878 | /// | ||
| 879 | /// @param[in] data A buffer containing the game's new state | ||
| 880 | /// @param[in] size The size of the buffer | ||
| 881 | /// | ||
| 882 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game deserialized | ||
| 883 | /// | ||
| 884 | virtual GAME_ERROR Deserialize(const uint8_t* data, size_t size) | ||
| 885 | { | ||
| 886 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 887 | } | ||
| 888 | //---------------------------------------------------------------------------- | ||
| 889 | |||
| 890 | ///@} | ||
| 891 | |||
| 892 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 893 | |||
| 894 | //============================================================================ | ||
| 895 | /// @defgroup cpp_kodi_addon_game_CheatOperations 6. Cheat operations | ||
| 896 | /// @ingroup cpp_kodi_addon_game | ||
| 897 | /// @brief **Cheat operations** | ||
| 898 | /// | ||
| 899 | /// | ||
| 900 | ///--------------------------------------------------------------------------- | ||
| 901 | /// | ||
| 902 | /// **Cheat operation parts in interface:**\n | ||
| 903 | /// Copy this to your project and extend with your parts or leave functions | ||
| 904 | /// complete away where not used or supported. | ||
| 905 | /// | ||
| 906 | /// @copydetails cpp_kodi_addon_game_CheatOperations_header_addon_auto_check | ||
| 907 | /// @copydetails cpp_kodi_addon_game_CheatOperations_source_addon_auto_check | ||
| 908 | /// | ||
| 909 | ///@{ | ||
| 910 | |||
| 911 | //============================================================================ | ||
| 912 | /// @brief Reset the cheat system | ||
| 913 | /// | ||
| 914 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the cheat system was reset | ||
| 915 | /// | ||
| 916 | virtual GAME_ERROR CheatReset() | ||
| 917 | { | ||
| 918 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 919 | } | ||
| 920 | //---------------------------------------------------------------------------- | ||
| 921 | |||
| 922 | //============================================================================ | ||
| 923 | /// @brief Get a region of memory | ||
| 924 | /// | ||
| 925 | /// @param[in] type The type of memory to retrieve | ||
| 926 | /// @param[in] data Set to the region of memory; must remain valid until UnloadGame() is called | ||
| 927 | /// @param[in] size Set to the size of the region of memory | ||
| 928 | /// | ||
| 929 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if data was set to a valid buffer | ||
| 930 | /// | ||
| 931 | virtual GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t*& data, size_t& size) | ||
| 932 | { | ||
| 933 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 934 | } | ||
| 935 | //---------------------------------------------------------------------------- | ||
| 936 | |||
| 937 | //============================================================================ | ||
| 938 | /// @brief Set a cheat code | ||
| 939 | /// | ||
| 940 | /// @param[in] index | ||
| 941 | /// @param[in] enabled | ||
| 942 | /// @param[in] code | ||
| 943 | /// | ||
| 944 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the cheat was set | ||
| 945 | /// | ||
| 946 | virtual GAME_ERROR SetCheat(unsigned int index, bool enabled, const std::string& code) | ||
| 947 | { | ||
| 948 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 949 | } | ||
| 950 | //---------------------------------------------------------------------------- | ||
| 951 | |||
| 952 | ///@} | ||
| 953 | |||
| 954 | private: | ||
| 955 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 956 | { | ||
| 957 | if (instance == nullptr) | ||
| 958 | throw std::logic_error("kodi::addon::CInstanceGame: Creation with empty addon structure not" | ||
| 959 | "allowed, table must be given from Kodi!"); | ||
| 960 | |||
| 961 | m_instanceData = static_cast<AddonInstance_Game*>(instance); | ||
| 962 | m_instanceData->toAddon->addonInstance = this; | ||
| 963 | |||
| 964 | m_instanceData->toAddon->LoadGame = ADDON_LoadGame; | ||
| 965 | m_instanceData->toAddon->LoadGameSpecial = ADDON_LoadGameSpecial; | ||
| 966 | m_instanceData->toAddon->LoadStandalone = ADDON_LoadStandalone; | ||
| 967 | m_instanceData->toAddon->UnloadGame = ADDON_UnloadGame; | ||
| 968 | m_instanceData->toAddon->GetGameTiming = ADDON_GetGameTiming; | ||
| 969 | m_instanceData->toAddon->GetRegion = ADDON_GetRegion; | ||
| 970 | m_instanceData->toAddon->RequiresGameLoop = ADDON_RequiresGameLoop; | ||
| 971 | m_instanceData->toAddon->RunFrame = ADDON_RunFrame; | ||
| 972 | m_instanceData->toAddon->Reset = ADDON_Reset; | ||
| 973 | |||
| 974 | m_instanceData->toAddon->HwContextReset = ADDON_HwContextReset; | ||
| 975 | m_instanceData->toAddon->HwContextDestroy = ADDON_HwContextDestroy; | ||
| 976 | |||
| 977 | m_instanceData->toAddon->HasFeature = ADDON_HasFeature; | ||
| 978 | m_instanceData->toAddon->GetTopology = ADDON_GetTopology; | ||
| 979 | m_instanceData->toAddon->FreeTopology = ADDON_FreeTopology; | ||
| 980 | m_instanceData->toAddon->SetControllerLayouts = ADDON_SetControllerLayouts; | ||
| 981 | m_instanceData->toAddon->EnableKeyboard = ADDON_EnableKeyboard; | ||
| 982 | m_instanceData->toAddon->EnableMouse = ADDON_EnableMouse; | ||
| 983 | m_instanceData->toAddon->ConnectController = ADDON_ConnectController; | ||
| 984 | m_instanceData->toAddon->InputEvent = ADDON_InputEvent; | ||
| 985 | |||
| 986 | m_instanceData->toAddon->SerializeSize = ADDON_SerializeSize; | ||
| 987 | m_instanceData->toAddon->Serialize = ADDON_Serialize; | ||
| 988 | m_instanceData->toAddon->Deserialize = ADDON_Deserialize; | ||
| 989 | |||
| 990 | m_instanceData->toAddon->CheatReset = ADDON_CheatReset; | ||
| 991 | m_instanceData->toAddon->GetMemory = ADDON_GetMemory; | ||
| 992 | m_instanceData->toAddon->SetCheat = ADDON_SetCheat; | ||
| 993 | } | ||
| 994 | |||
| 995 | // --- Game operations --------------------------------------------------------- | ||
| 996 | |||
| 997 | inline static GAME_ERROR ADDON_LoadGame(const AddonInstance_Game* instance, const char* url) | ||
| 998 | { | ||
| 999 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->LoadGame(url); | ||
| 1000 | } | ||
| 1001 | |||
| 1002 | inline static GAME_ERROR ADDON_LoadGameSpecial(const AddonInstance_Game* instance, | ||
| 1003 | SPECIAL_GAME_TYPE type, | ||
| 1004 | const char** urls, | ||
| 1005 | size_t urlCount) | ||
| 1006 | { | ||
| 1007 | std::vector<std::string> urlList; | ||
| 1008 | for (size_t i = 0; i < urlCount; ++i) | ||
| 1009 | { | ||
| 1010 | if (urls[i] != nullptr) | ||
| 1011 | urlList.push_back(urls[i]); | ||
| 1012 | } | ||
| 1013 | |||
| 1014 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance) | ||
| 1015 | ->LoadGameSpecial(type, urlList); | ||
| 1016 | } | ||
| 1017 | |||
| 1018 | inline static GAME_ERROR ADDON_LoadStandalone(const AddonInstance_Game* instance) | ||
| 1019 | { | ||
| 1020 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->LoadStandalone(); | ||
| 1021 | } | ||
| 1022 | |||
| 1023 | inline static GAME_ERROR ADDON_UnloadGame(const AddonInstance_Game* instance) | ||
| 1024 | { | ||
| 1025 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->UnloadGame(); | ||
| 1026 | } | ||
| 1027 | |||
| 1028 | inline static GAME_ERROR ADDON_GetGameTiming(const AddonInstance_Game* instance, | ||
| 1029 | game_system_timing* timing_info) | ||
| 1030 | { | ||
| 1031 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance) | ||
| 1032 | ->GetGameTiming(*timing_info); | ||
| 1033 | } | ||
| 1034 | |||
| 1035 | inline static GAME_REGION ADDON_GetRegion(const AddonInstance_Game* instance) | ||
| 1036 | { | ||
| 1037 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetRegion(); | ||
| 1038 | } | ||
| 1039 | |||
| 1040 | inline static bool ADDON_RequiresGameLoop(const AddonInstance_Game* instance) | ||
| 1041 | { | ||
| 1042 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->RequiresGameLoop(); | ||
| 1043 | } | ||
| 1044 | |||
| 1045 | inline static GAME_ERROR ADDON_RunFrame(const AddonInstance_Game* instance) | ||
| 1046 | { | ||
| 1047 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->RunFrame(); | ||
| 1048 | } | ||
| 1049 | |||
| 1050 | inline static GAME_ERROR ADDON_Reset(const AddonInstance_Game* instance) | ||
| 1051 | { | ||
| 1052 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Reset(); | ||
| 1053 | } | ||
| 1054 | |||
| 1055 | |||
| 1056 | // --- Hardware rendering operations ------------------------------------------- | ||
| 1057 | |||
| 1058 | inline static GAME_ERROR ADDON_HwContextReset(const AddonInstance_Game* instance) | ||
| 1059 | { | ||
| 1060 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->HwContextReset(); | ||
| 1061 | } | ||
| 1062 | |||
| 1063 | inline static GAME_ERROR ADDON_HwContextDestroy(const AddonInstance_Game* instance) | ||
| 1064 | { | ||
| 1065 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->HwContextDestroy(); | ||
| 1066 | } | ||
| 1067 | |||
| 1068 | |||
| 1069 | // --- Input operations -------------------------------------------------------- | ||
| 1070 | |||
| 1071 | inline static bool ADDON_HasFeature(const AddonInstance_Game* instance, | ||
| 1072 | const char* controller_id, | ||
| 1073 | const char* feature_name) | ||
| 1074 | { | ||
| 1075 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance) | ||
| 1076 | ->HasFeature(controller_id, feature_name); | ||
| 1077 | } | ||
| 1078 | |||
| 1079 | inline static game_input_topology* ADDON_GetTopology(const AddonInstance_Game* instance) | ||
| 1080 | { | ||
| 1081 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetTopology(); | ||
| 1082 | } | ||
| 1083 | |||
| 1084 | inline static void ADDON_FreeTopology(const AddonInstance_Game* instance, | ||
| 1085 | game_input_topology* topology) | ||
| 1086 | { | ||
| 1087 | static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->FreeTopology(topology); | ||
| 1088 | } | ||
| 1089 | |||
| 1090 | inline static void ADDON_SetControllerLayouts(const AddonInstance_Game* instance, | ||
| 1091 | const game_controller_layout* controllers, | ||
| 1092 | unsigned int controller_count) | ||
| 1093 | { | ||
| 1094 | if (controllers == nullptr) | ||
| 1095 | return; | ||
| 1096 | |||
| 1097 | std::vector<GameControllerLayout> controllerList; | ||
| 1098 | for (unsigned int i = 0; i < controller_count; ++i) | ||
| 1099 | controllerList.push_back(controllers[i]); | ||
| 1100 | |||
| 1101 | static_cast<CInstanceGame*>(instance->toAddon->addonInstance) | ||
| 1102 | ->SetControllerLayouts(controllerList); | ||
| 1103 | } | ||
| 1104 | |||
| 1105 | inline static bool ADDON_EnableKeyboard(const AddonInstance_Game* instance, | ||
| 1106 | bool enable, | ||
| 1107 | const char* controller_id) | ||
| 1108 | { | ||
| 1109 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance) | ||
| 1110 | ->EnableKeyboard(enable, controller_id); | ||
| 1111 | } | ||
| 1112 | |||
| 1113 | inline static bool ADDON_EnableMouse(const AddonInstance_Game* instance, | ||
| 1114 | bool enable, | ||
| 1115 | const char* controller_id) | ||
| 1116 | { | ||
| 1117 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance) | ||
| 1118 | ->EnableMouse(enable, controller_id); | ||
| 1119 | } | ||
| 1120 | |||
| 1121 | inline static bool ADDON_ConnectController(const AddonInstance_Game* instance, | ||
| 1122 | bool connect, | ||
| 1123 | const char* port_address, | ||
| 1124 | const char* controller_id) | ||
| 1125 | { | ||
| 1126 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance) | ||
| 1127 | ->ConnectController(connect, port_address, controller_id); | ||
| 1128 | } | ||
| 1129 | |||
| 1130 | inline static bool ADDON_InputEvent(const AddonInstance_Game* instance, | ||
| 1131 | const game_input_event* event) | ||
| 1132 | { | ||
| 1133 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->InputEvent(*event); | ||
| 1134 | } | ||
| 1135 | |||
| 1136 | |||
| 1137 | // --- Serialization operations ------------------------------------------------ | ||
| 1138 | |||
| 1139 | inline static size_t ADDON_SerializeSize(const AddonInstance_Game* instance) | ||
| 1140 | { | ||
| 1141 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->SerializeSize(); | ||
| 1142 | } | ||
| 1143 | |||
| 1144 | inline static GAME_ERROR ADDON_Serialize(const AddonInstance_Game* instance, | ||
| 1145 | uint8_t* data, | ||
| 1146 | size_t size) | ||
| 1147 | { | ||
| 1148 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Serialize(data, size); | ||
| 1149 | } | ||
| 1150 | |||
| 1151 | inline static GAME_ERROR ADDON_Deserialize(const AddonInstance_Game* instance, | ||
| 1152 | const uint8_t* data, | ||
| 1153 | size_t size) | ||
| 1154 | { | ||
| 1155 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Deserialize(data, size); | ||
| 1156 | } | ||
| 1157 | |||
| 1158 | |||
| 1159 | // --- Cheat operations -------------------------------------------------------- | ||
| 1160 | |||
| 1161 | inline static GAME_ERROR ADDON_CheatReset(const AddonInstance_Game* instance) | ||
| 1162 | { | ||
| 1163 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->CheatReset(); | ||
| 1164 | } | ||
| 1165 | |||
| 1166 | inline static GAME_ERROR ADDON_GetMemory(const AddonInstance_Game* instance, | ||
| 1167 | GAME_MEMORY type, | ||
| 1168 | uint8_t** data, | ||
| 1169 | size_t* size) | ||
| 1170 | { | ||
| 1171 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance) | ||
| 1172 | ->GetMemory(type, *data, *size); | ||
| 1173 | } | ||
| 1174 | |||
| 1175 | inline static GAME_ERROR ADDON_SetCheat(const AddonInstance_Game* instance, | ||
| 1176 | unsigned int index, | ||
| 1177 | bool enabled, | ||
| 1178 | const char* code) | ||
| 1179 | { | ||
| 1180 | return static_cast<CInstanceGame*>(instance->toAddon->addonInstance) | ||
| 1181 | ->SetCheat(index, enabled, code); | ||
| 1182 | } | ||
| 1183 | |||
| 1184 | AddonInstance_Game* m_instanceData; | ||
| 1185 | }; | ||
| 1186 | |||
| 1187 | } /* namespace addon */ | ||
| 1188 | } /* namespace kodi */ | ||
| 1189 | |||
| 1190 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/ImageDecoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/ImageDecoder.h index e41e5ef..7aeef7b 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/ImageDecoder.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/ImageDecoder.h | |||
| @@ -177,7 +177,7 @@ namespace addon | |||
| 177 | /// { | 177 | /// { |
| 178 | /// if (instanceType == ADDON_INSTANCE_IMAGEDECODER) | 178 | /// if (instanceType == ADDON_INSTANCE_IMAGEDECODER) |
| 179 | /// { | 179 | /// { |
| 180 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my image decoder instance"); | 180 | /// kodi::Log(ADDON_LOG_INFO, "Creating my image decoder instance"); |
| 181 | /// addonInstance = new CMyImageDecoder(instance, version); | 181 | /// addonInstance = new CMyImageDecoder(instance, version); |
| 182 | /// return ADDON_STATUS_OK; | 182 | /// return ADDON_STATUS_OK; |
| 183 | /// } | 183 | /// } |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h index 354806e..396b92e 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h | |||
| @@ -28,6 +28,11 @@ | |||
| 28 | //Increment this level always if you add features which can lead to compile failures in the addon | 28 | //Increment this level always if you add features which can lead to compile failures in the addon |
| 29 | #define INPUTSTREAM_VERSION_LEVEL 2 | 29 | #define INPUTSTREAM_VERSION_LEVEL 2 |
| 30 | 30 | ||
| 31 | #define INPUTSTREAM_MAX_STREAM_COUNT 256 | ||
| 32 | #define INPUTSTREAM_MAX_STRING_NAME_SIZE 256 | ||
| 33 | #define INPUTSTREAM_MAX_STRING_CODEC_SIZE 32 | ||
| 34 | #define INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE 64 | ||
| 35 | |||
| 31 | #ifdef __cplusplus | 36 | #ifdef __cplusplus |
| 32 | extern "C" | 37 | extern "C" |
| 33 | { | 38 | { |
| @@ -90,9 +95,8 @@ extern "C" | |||
| 90 | */ | 95 | */ |
| 91 | struct INPUTSTREAM_IDS | 96 | struct INPUTSTREAM_IDS |
| 92 | { | 97 | { |
| 93 | static const unsigned int MAX_STREAM_COUNT = 256; | ||
| 94 | unsigned int m_streamCount; | 98 | unsigned int m_streamCount; |
| 95 | unsigned int m_streamIds[MAX_STREAM_COUNT]; | 99 | unsigned int m_streamIds[INPUTSTREAM_MAX_STREAM_COUNT]; |
| 96 | }; | 100 | }; |
| 97 | 101 | ||
| 98 | /*! | 102 | /*! |
| @@ -238,45 +242,90 @@ extern "C" | |||
| 238 | 242 | ||
| 239 | uint32_t m_flags; | 243 | uint32_t m_flags; |
| 240 | 244 | ||
| 241 | char m_name[256]; /*!< @brief (optinal) name of the stream, \0 for default handling */ | 245 | //! @brief (optional) name of the stream, \0 for default handling |
| 242 | char m_codecName[32]; /*!< @brief (required) name of codec according to ffmpeg */ | 246 | char m_name[INPUTSTREAM_MAX_STRING_NAME_SIZE]; |
| 243 | char m_codecInternalName | 247 | |
| 244 | [32]; /*!< @brief (optional) internal name of codec (selectionstream info) */ | 248 | //! @brief (required) name of codec according to ffmpeg |
| 245 | STREAMCODEC_PROFILE m_codecProfile; /*!< @brief (optional) the profile of the codec */ | 249 | char m_codecName[INPUTSTREAM_MAX_STRING_CODEC_SIZE]; |
| 246 | unsigned int m_pID; /*!< @brief (required) physical index */ | 250 | |
| 251 | //! @brief (optional) internal name of codec (selectionstream info) | ||
| 252 | char m_codecInternalName[INPUTSTREAM_MAX_STRING_CODEC_SIZE]; | ||
| 253 | |||
| 254 | //! @brief (optional) the profile of the codec | ||
| 255 | STREAMCODEC_PROFILE m_codecProfile; | ||
| 256 | |||
| 257 | //! @brief (required) physical index | ||
| 258 | unsigned int m_pID; | ||
| 247 | 259 | ||
| 248 | const uint8_t* m_ExtraData; | 260 | const uint8_t* m_ExtraData; |
| 249 | unsigned int m_ExtraSize; | 261 | unsigned int m_ExtraSize; |
| 250 | 262 | ||
| 251 | char m_language[64]; /*!< @brief RFC 5646 language code (empty string if undefined) */ | 263 | //! @brief RFC 5646 language code (empty string if undefined) |
| 264 | char m_language[INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE]; | ||
| 265 | |||
| 266 | //! Video stream related data | ||
| 267 | //@{ | ||
| 268 | |||
| 269 | //! @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps | ||
| 270 | unsigned int m_FpsScale; | ||
| 252 | 271 | ||
| 253 | unsigned int | ||
| 254 | m_FpsScale; /*!< @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps */ | ||
| 255 | unsigned int m_FpsRate; | 272 | unsigned int m_FpsRate; |
| 256 | unsigned int m_Height; /*!< @brief height of the stream reported by the demuxer */ | ||
| 257 | unsigned int m_Width; /*!< @brief width of the stream reported by the demuxer */ | ||
| 258 | float m_Aspect; /*!< @brief display aspect of stream */ | ||
| 259 | 273 | ||
| 274 | //! @brief height of the stream reported by the demuxer | ||
| 275 | unsigned int m_Height; | ||
| 276 | |||
| 277 | //! @brief width of the stream reported by the demuxer | ||
| 278 | unsigned int m_Width; | ||
| 279 | |||
| 280 | //! @brief display aspect of stream | ||
| 281 | float m_Aspect; | ||
| 282 | |||
| 283 | //@} | ||
| 284 | |||
| 285 | //! Audio stream related data | ||
| 286 | //@{ | ||
| 287 | |||
| 288 | //! @brief (required) amount of channels | ||
| 289 | unsigned int m_Channels; | ||
| 290 | |||
| 291 | //! @brief (required) sample rate | ||
| 292 | unsigned int m_SampleRate; | ||
| 293 | |||
| 294 | //! @brief (required) bit rate | ||
| 295 | unsigned int m_BitRate; | ||
| 296 | |||
| 297 | //! @brief (required) bits per sample | ||
| 298 | unsigned int m_BitsPerSample; | ||
| 260 | 299 | ||
| 261 | unsigned int m_Channels; /*!< @brief (required) amount of channels */ | ||
| 262 | unsigned int m_SampleRate; /*!< @brief (required) sample rate */ | ||
| 263 | unsigned int m_BitRate; /*!< @brief (required) bit rate */ | ||
| 264 | unsigned int m_BitsPerSample; /*!< @brief (required) bits per sample */ | ||
| 265 | unsigned int m_BlockAlign; | 300 | unsigned int m_BlockAlign; |
| 266 | 301 | ||
| 302 | //@} | ||
| 303 | |||
| 267 | CRYPTO_INFO m_cryptoInfo; | 304 | CRYPTO_INFO m_cryptoInfo; |
| 268 | 305 | ||
| 269 | // new in API version 2.0.8 | 306 | // new in API version 2.0.8 |
| 270 | unsigned int m_codecFourCC; /*!< @brief Codec If available, the fourcc code codec */ | 307 | //@{ |
| 271 | COLORSPACE m_colorSpace; /*!< @brief definition of colorspace */ | 308 | //! @brief Codec If available, the fourcc code codec |
| 272 | COLORRANGE m_colorRange; /*!< @brief color range if available */ | 309 | unsigned int m_codecFourCC; |
| 310 | |||
| 311 | //! @brief definition of colorspace | ||
| 312 | COLORSPACE m_colorSpace; | ||
| 313 | |||
| 314 | //! @brief color range if available | ||
| 315 | COLORRANGE m_colorRange; | ||
| 316 | //@} | ||
| 273 | 317 | ||
| 274 | //new in API 2.0.9 / INPUTSTREAM_VERSION_LEVEL 1 | 318 | //new in API 2.0.9 / INPUTSTREAM_VERSION_LEVEL 1 |
| 319 | //@{ | ||
| 275 | COLORPRIMARIES m_colorPrimaries; | 320 | COLORPRIMARIES m_colorPrimaries; |
| 276 | COLORTRC m_colorTransferCharacteristic; | 321 | COLORTRC m_colorTransferCharacteristic; |
| 277 | INPUTSTREAM_MASTERING_METADATA* m_masteringMetadata; /*!< @brief mastering static Metadata */ | 322 | //@} |
| 278 | INPUTSTREAM_CONTENTLIGHT_METADATA* | 323 | |
| 279 | m_contentLightMetadata; /*!< @brief content light static Metadata */ | 324 | //! @brief mastering static Metadata |
| 325 | INPUTSTREAM_MASTERING_METADATA* m_masteringMetadata; | ||
| 326 | |||
| 327 | //! @brief content light static Metadata | ||
| 328 | INPUTSTREAM_CONTENTLIGHT_METADATA* m_contentLightMetadata; | ||
| 280 | }; | 329 | }; |
| 281 | 330 | ||
| 282 | struct INPUTSTREAM_TIMES | 331 | struct INPUTSTREAM_TIMES |
| @@ -372,9 +421,9 @@ extern "C" | |||
| 372 | 421 | ||
| 373 | typedef struct AddonInstance_InputStream /* internal */ | 422 | typedef struct AddonInstance_InputStream /* internal */ |
| 374 | { | 423 | { |
| 375 | AddonProps_InputStream props; | 424 | AddonProps_InputStream* props; |
| 376 | AddonToKodiFuncTable_InputStream toKodi; | 425 | AddonToKodiFuncTable_InputStream* toKodi; |
| 377 | KodiToAddonFuncTable_InputStream toAddon; | 426 | KodiToAddonFuncTable_InputStream* toAddon; |
| 378 | } AddonInstance_InputStream; | 427 | } AddonInstance_InputStream; |
| 379 | 428 | ||
| 380 | #ifdef __cplusplus | 429 | #ifdef __cplusplus |
| @@ -612,8 +661,8 @@ public: | |||
| 612 | */ | 661 | */ |
| 613 | DemuxPacket* AllocateDemuxPacket(int dataSize) | 662 | DemuxPacket* AllocateDemuxPacket(int dataSize) |
| 614 | { | 663 | { |
| 615 | return m_instanceData->toKodi.allocate_demux_packet(m_instanceData->toKodi.kodiInstance, | 664 | return m_instanceData->toKodi->allocate_demux_packet(m_instanceData->toKodi->kodiInstance, |
| 616 | dataSize); | 665 | dataSize); |
| 617 | } | 666 | } |
| 618 | 667 | ||
| 619 | /*! | 668 | /*! |
| @@ -623,8 +672,8 @@ public: | |||
| 623 | */ | 672 | */ |
| 624 | DemuxPacket* AllocateEncryptedDemuxPacket(int dataSize, unsigned int encryptedSubsampleCount) | 673 | DemuxPacket* AllocateEncryptedDemuxPacket(int dataSize, unsigned int encryptedSubsampleCount) |
| 625 | { | 674 | { |
| 626 | return m_instanceData->toKodi.allocate_encrypted_demux_packet( | 675 | return m_instanceData->toKodi->allocate_encrypted_demux_packet( |
| 627 | m_instanceData->toKodi.kodiInstance, dataSize, encryptedSubsampleCount); | 676 | m_instanceData->toKodi->kodiInstance, dataSize, encryptedSubsampleCount); |
| 628 | } | 677 | } |
| 629 | 678 | ||
| 630 | /*! | 679 | /*! |
| @@ -633,7 +682,7 @@ public: | |||
| 633 | */ | 682 | */ |
| 634 | void FreeDemuxPacket(DemuxPacket* packet) | 683 | void FreeDemuxPacket(DemuxPacket* packet) |
| 635 | { | 684 | { |
| 636 | return m_instanceData->toKodi.free_demux_packet(m_instanceData->toKodi.kodiInstance, packet); | 685 | return m_instanceData->toKodi->free_demux_packet(m_instanceData->toKodi->kodiInstance, packet); |
| 637 | } | 686 | } |
| 638 | 687 | ||
| 639 | private: | 688 | private: |
| @@ -654,66 +703,69 @@ private: | |||
| 654 | sscanf(kodiVersion.c_str(), "%d.%d.%d", &api[0], &api[1], &api[2]); | 703 | sscanf(kodiVersion.c_str(), "%d.%d.%d", &api[0], &api[1], &api[2]); |
| 655 | 704 | ||
| 656 | m_instanceData = static_cast<AddonInstance_InputStream*>(instance); | 705 | m_instanceData = static_cast<AddonInstance_InputStream*>(instance); |
| 657 | m_instanceData->toAddon.addonInstance = this; | 706 | m_instanceData->toAddon->addonInstance = this; |
| 658 | m_instanceData->toAddon.open = ADDON_Open; | 707 | m_instanceData->toAddon->open = ADDON_Open; |
| 659 | m_instanceData->toAddon.close = ADDON_Close; | 708 | m_instanceData->toAddon->close = ADDON_Close; |
| 660 | m_instanceData->toAddon.get_capabilities = ADDON_GetCapabilities; | 709 | m_instanceData->toAddon->get_capabilities = ADDON_GetCapabilities; |
| 661 | 710 | ||
| 662 | m_instanceData->toAddon.get_stream_ids = ADDON_GetStreamIds; | 711 | m_instanceData->toAddon->get_stream_ids = ADDON_GetStreamIds; |
| 663 | m_instanceData->toAddon.get_stream = ADDON_GetStream; | 712 | m_instanceData->toAddon->get_stream = ADDON_GetStream; |
| 664 | m_instanceData->toAddon.enable_stream = ADDON_EnableStream; | 713 | m_instanceData->toAddon->enable_stream = ADDON_EnableStream; |
| 665 | m_instanceData->toAddon.open_stream = ADDON_OpenStream; | 714 | m_instanceData->toAddon->open_stream = ADDON_OpenStream; |
| 666 | m_instanceData->toAddon.demux_reset = ADDON_DemuxReset; | 715 | m_instanceData->toAddon->demux_reset = ADDON_DemuxReset; |
| 667 | m_instanceData->toAddon.demux_abort = ADDON_DemuxAbort; | 716 | m_instanceData->toAddon->demux_abort = ADDON_DemuxAbort; |
| 668 | m_instanceData->toAddon.demux_flush = ADDON_DemuxFlush; | 717 | m_instanceData->toAddon->demux_flush = ADDON_DemuxFlush; |
| 669 | m_instanceData->toAddon.demux_read = ADDON_DemuxRead; | 718 | m_instanceData->toAddon->demux_read = ADDON_DemuxRead; |
| 670 | m_instanceData->toAddon.demux_seek_time = ADDON_DemuxSeekTime; | 719 | m_instanceData->toAddon->demux_seek_time = ADDON_DemuxSeekTime; |
| 671 | m_instanceData->toAddon.demux_set_speed = ADDON_DemuxSetSpeed; | 720 | m_instanceData->toAddon->demux_set_speed = ADDON_DemuxSetSpeed; |
| 672 | m_instanceData->toAddon.set_video_resolution = ADDON_SetVideoResolution; | 721 | m_instanceData->toAddon->set_video_resolution = ADDON_SetVideoResolution; |
| 673 | 722 | ||
| 674 | m_instanceData->toAddon.get_total_time = ADDON_GetTotalTime; | 723 | m_instanceData->toAddon->get_total_time = ADDON_GetTotalTime; |
| 675 | m_instanceData->toAddon.get_time = ADDON_GetTime; | 724 | m_instanceData->toAddon->get_time = ADDON_GetTime; |
| 676 | 725 | ||
| 677 | m_instanceData->toAddon.get_times = ADDON_GetTimes; | 726 | m_instanceData->toAddon->get_times = ADDON_GetTimes; |
| 678 | m_instanceData->toAddon.pos_time = ADDON_PosTime; | 727 | m_instanceData->toAddon->pos_time = ADDON_PosTime; |
| 679 | 728 | ||
| 680 | m_instanceData->toAddon.read_stream = ADDON_ReadStream; | 729 | m_instanceData->toAddon->read_stream = ADDON_ReadStream; |
| 681 | m_instanceData->toAddon.seek_stream = ADDON_SeekStream; | 730 | m_instanceData->toAddon->seek_stream = ADDON_SeekStream; |
| 682 | m_instanceData->toAddon.position_stream = ADDON_PositionStream; | 731 | m_instanceData->toAddon->position_stream = ADDON_PositionStream; |
| 683 | m_instanceData->toAddon.length_stream = ADDON_LengthStream; | 732 | m_instanceData->toAddon->length_stream = ADDON_LengthStream; |
| 684 | m_instanceData->toAddon.is_real_time_stream = ADDON_IsRealTimeStream; | 733 | m_instanceData->toAddon->is_real_time_stream = ADDON_IsRealTimeStream; |
| 685 | 734 | ||
| 686 | int minChapterVersion[3] = { 2, 0, 10 }; | 735 | // Added on 2.0.10 |
| 687 | if (compareVersion(api, minChapterVersion) >= 0) | 736 | m_instanceData->toAddon->get_chapter = ADDON_GetChapter; |
| 737 | m_instanceData->toAddon->get_chapter_count = ADDON_GetChapterCount; | ||
| 738 | m_instanceData->toAddon->get_chapter_name = ADDON_GetChapterName; | ||
| 739 | m_instanceData->toAddon->get_chapter_pos = ADDON_GetChapterPos; | ||
| 740 | m_instanceData->toAddon->seek_chapter = ADDON_SeekChapter; | ||
| 741 | |||
| 742 | // Added on 2.0.12 | ||
| 743 | m_instanceData->toAddon->block_size_stream = ADDON_GetBlockSize; | ||
| 744 | |||
| 745 | /* | ||
| 746 | // Way to include part on new API version | ||
| 747 | int minPartVersion[3] = { 3, 0, 0 }; | ||
| 748 | if (compareVersion(api, minPartVersion) >= 0) | ||
| 688 | { | 749 | { |
| 689 | m_instanceData->toAddon.get_chapter = ADDON_GetChapter; | ||
| 690 | m_instanceData->toAddon.get_chapter_count = ADDON_GetChapterCount; | ||
| 691 | m_instanceData->toAddon.get_chapter_name = ADDON_GetChapterName; | ||
| 692 | m_instanceData->toAddon.get_chapter_pos = ADDON_GetChapterPos; | ||
| 693 | m_instanceData->toAddon.seek_chapter = ADDON_SeekChapter; | ||
| 694 | } | ||
| 695 | 750 | ||
| 696 | int minBlockSizeVersion[3] = {2, 0, 12}; | ||
| 697 | if (compareVersion(api, minBlockSizeVersion) >= 0) | ||
| 698 | { | ||
| 699 | m_instanceData->toAddon.block_size_stream = ADDON_GetBlockSize; | ||
| 700 | } | 751 | } |
| 752 | */ | ||
| 701 | } | 753 | } |
| 702 | 754 | ||
| 703 | inline static bool ADDON_Open(const AddonInstance_InputStream* instance, INPUTSTREAM* props) | 755 | inline static bool ADDON_Open(const AddonInstance_InputStream* instance, INPUTSTREAM* props) |
| 704 | { | 756 | { |
| 705 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->Open(*props); | 757 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->Open(*props); |
| 706 | } | 758 | } |
| 707 | 759 | ||
| 708 | inline static void ADDON_Close(const AddonInstance_InputStream* instance) | 760 | inline static void ADDON_Close(const AddonInstance_InputStream* instance) |
| 709 | { | 761 | { |
| 710 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->Close(); | 762 | static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->Close(); |
| 711 | } | 763 | } |
| 712 | 764 | ||
| 713 | inline static void ADDON_GetCapabilities(const AddonInstance_InputStream* instance, | 765 | inline static void ADDON_GetCapabilities(const AddonInstance_InputStream* instance, |
| 714 | INPUTSTREAM_CAPABILITIES* capabilities) | 766 | INPUTSTREAM_CAPABILITIES* capabilities) |
| 715 | { | 767 | { |
| 716 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance) | 768 | static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance) |
| 717 | ->GetCapabilities(*capabilities); | 769 | ->GetCapabilities(*capabilities); |
| 718 | } | 770 | } |
| 719 | 771 | ||
| @@ -721,47 +773,48 @@ private: | |||
| 721 | // IDemux | 773 | // IDemux |
| 722 | inline static struct INPUTSTREAM_IDS ADDON_GetStreamIds(const AddonInstance_InputStream* instance) | 774 | inline static struct INPUTSTREAM_IDS ADDON_GetStreamIds(const AddonInstance_InputStream* instance) |
| 723 | { | 775 | { |
| 724 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetStreamIds(); | 776 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetStreamIds(); |
| 725 | } | 777 | } |
| 726 | 778 | ||
| 727 | inline static struct INPUTSTREAM_INFO ADDON_GetStream(const AddonInstance_InputStream* instance, | 779 | inline static struct INPUTSTREAM_INFO ADDON_GetStream(const AddonInstance_InputStream* instance, |
| 728 | int streamid) | 780 | int streamid) |
| 729 | { | 781 | { |
| 730 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetStream(streamid); | 782 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance) |
| 783 | ->GetStream(streamid); | ||
| 731 | } | 784 | } |
| 732 | 785 | ||
| 733 | inline static void ADDON_EnableStream(const AddonInstance_InputStream* instance, | 786 | inline static void ADDON_EnableStream(const AddonInstance_InputStream* instance, |
| 734 | int streamid, | 787 | int streamid, |
| 735 | bool enable) | 788 | bool enable) |
| 736 | { | 789 | { |
| 737 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance) | 790 | static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance) |
| 738 | ->EnableStream(streamid, enable); | 791 | ->EnableStream(streamid, enable); |
| 739 | } | 792 | } |
| 740 | 793 | ||
| 741 | inline static bool ADDON_OpenStream(const AddonInstance_InputStream* instance, int streamid) | 794 | inline static bool ADDON_OpenStream(const AddonInstance_InputStream* instance, int streamid) |
| 742 | { | 795 | { |
| 743 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance) | 796 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance) |
| 744 | ->OpenStream(streamid); | 797 | ->OpenStream(streamid); |
| 745 | } | 798 | } |
| 746 | 799 | ||
| 747 | inline static void ADDON_DemuxReset(const AddonInstance_InputStream* instance) | 800 | inline static void ADDON_DemuxReset(const AddonInstance_InputStream* instance) |
| 748 | { | 801 | { |
| 749 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxReset(); | 802 | static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxReset(); |
| 750 | } | 803 | } |
| 751 | 804 | ||
| 752 | inline static void ADDON_DemuxAbort(const AddonInstance_InputStream* instance) | 805 | inline static void ADDON_DemuxAbort(const AddonInstance_InputStream* instance) |
| 753 | { | 806 | { |
| 754 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxAbort(); | 807 | static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxAbort(); |
| 755 | } | 808 | } |
| 756 | 809 | ||
| 757 | inline static void ADDON_DemuxFlush(const AddonInstance_InputStream* instance) | 810 | inline static void ADDON_DemuxFlush(const AddonInstance_InputStream* instance) |
| 758 | { | 811 | { |
| 759 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxFlush(); | 812 | static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxFlush(); |
| 760 | } | 813 | } |
| 761 | 814 | ||
| 762 | inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_InputStream* instance) | 815 | inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_InputStream* instance) |
| 763 | { | 816 | { |
| 764 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxRead(); | 817 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxRead(); |
| 765 | } | 818 | } |
| 766 | 819 | ||
| 767 | inline static bool ADDON_DemuxSeekTime(const AddonInstance_InputStream* instance, | 820 | inline static bool ADDON_DemuxSeekTime(const AddonInstance_InputStream* instance, |
| @@ -769,20 +822,20 @@ private: | |||
| 769 | bool backwards, | 822 | bool backwards, |
| 770 | double* startpts) | 823 | double* startpts) |
| 771 | { | 824 | { |
| 772 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance) | 825 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance) |
| 773 | ->DemuxSeekTime(time, backwards, *startpts); | 826 | ->DemuxSeekTime(time, backwards, *startpts); |
| 774 | } | 827 | } |
| 775 | 828 | ||
| 776 | inline static void ADDON_DemuxSetSpeed(const AddonInstance_InputStream* instance, int speed) | 829 | inline static void ADDON_DemuxSetSpeed(const AddonInstance_InputStream* instance, int speed) |
| 777 | { | 830 | { |
| 778 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxSetSpeed(speed); | 831 | static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxSetSpeed(speed); |
| 779 | } | 832 | } |
| 780 | 833 | ||
| 781 | inline static void ADDON_SetVideoResolution(const AddonInstance_InputStream* instance, | 834 | inline static void ADDON_SetVideoResolution(const AddonInstance_InputStream* instance, |
| 782 | int width, | 835 | int width, |
| 783 | int height) | 836 | int height) |
| 784 | { | 837 | { |
| 785 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance) | 838 | static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance) |
| 786 | ->SetVideoResolution(width, height); | 839 | ->SetVideoResolution(width, height); |
| 787 | } | 840 | } |
| 788 | 841 | ||
| @@ -790,57 +843,57 @@ private: | |||
| 790 | // IDisplayTime | 843 | // IDisplayTime |
| 791 | inline static int ADDON_GetTotalTime(const AddonInstance_InputStream* instance) | 844 | inline static int ADDON_GetTotalTime(const AddonInstance_InputStream* instance) |
| 792 | { | 845 | { |
| 793 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetTotalTime(); | 846 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetTotalTime(); |
| 794 | } | 847 | } |
| 795 | 848 | ||
| 796 | inline static int ADDON_GetTime(const AddonInstance_InputStream* instance) | 849 | inline static int ADDON_GetTime(const AddonInstance_InputStream* instance) |
| 797 | { | 850 | { |
| 798 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetTime(); | 851 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetTime(); |
| 799 | } | 852 | } |
| 800 | 853 | ||
| 801 | // ITime | 854 | // ITime |
| 802 | inline static bool ADDON_GetTimes(const AddonInstance_InputStream* instance, | 855 | inline static bool ADDON_GetTimes(const AddonInstance_InputStream* instance, |
| 803 | INPUTSTREAM_TIMES* times) | 856 | INPUTSTREAM_TIMES* times) |
| 804 | { | 857 | { |
| 805 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetTimes(*times); | 858 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetTimes(*times); |
| 806 | } | 859 | } |
| 807 | 860 | ||
| 808 | // IPosTime | 861 | // IPosTime |
| 809 | inline static bool ADDON_PosTime(const AddonInstance_InputStream* instance, int ms) | 862 | inline static bool ADDON_PosTime(const AddonInstance_InputStream* instance, int ms) |
| 810 | { | 863 | { |
| 811 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->PosTime(ms); | 864 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->PosTime(ms); |
| 812 | } | 865 | } |
| 813 | 866 | ||
| 814 | inline static int ADDON_GetChapter(const AddonInstance_InputStream* instance) | 867 | inline static int ADDON_GetChapter(const AddonInstance_InputStream* instance) |
| 815 | { | 868 | { |
| 816 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapter(); | 869 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetChapter(); |
| 817 | } | 870 | } |
| 818 | 871 | ||
| 819 | inline static int ADDON_GetChapterCount(const AddonInstance_InputStream* instance) | 872 | inline static int ADDON_GetChapterCount(const AddonInstance_InputStream* instance) |
| 820 | { | 873 | { |
| 821 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapterCount(); | 874 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetChapterCount(); |
| 822 | } | 875 | } |
| 823 | 876 | ||
| 824 | inline static const char* ADDON_GetChapterName(const AddonInstance_InputStream* instance, int ch) | 877 | inline static const char* ADDON_GetChapterName(const AddonInstance_InputStream* instance, int ch) |
| 825 | { | 878 | { |
| 826 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapterName(ch); | 879 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetChapterName(ch); |
| 827 | } | 880 | } |
| 828 | 881 | ||
| 829 | inline static int64_t ADDON_GetChapterPos(const AddonInstance_InputStream* instance, int ch) | 882 | inline static int64_t ADDON_GetChapterPos(const AddonInstance_InputStream* instance, int ch) |
| 830 | { | 883 | { |
| 831 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapterPos(ch); | 884 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetChapterPos(ch); |
| 832 | } | 885 | } |
| 833 | 886 | ||
| 834 | inline static bool ADDON_SeekChapter(const AddonInstance_InputStream* instance, int ch) | 887 | inline static bool ADDON_SeekChapter(const AddonInstance_InputStream* instance, int ch) |
| 835 | { | 888 | { |
| 836 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->SeekChapter(ch); | 889 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->SeekChapter(ch); |
| 837 | } | 890 | } |
| 838 | 891 | ||
| 839 | inline static int ADDON_ReadStream(const AddonInstance_InputStream* instance, | 892 | inline static int ADDON_ReadStream(const AddonInstance_InputStream* instance, |
| 840 | uint8_t* buffer, | 893 | uint8_t* buffer, |
| 841 | unsigned int bufferSize) | 894 | unsigned int bufferSize) |
| 842 | { | 895 | { |
| 843 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance) | 896 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance) |
| 844 | ->ReadStream(buffer, bufferSize); | 897 | ->ReadStream(buffer, bufferSize); |
| 845 | } | 898 | } |
| 846 | 899 | ||
| @@ -848,28 +901,28 @@ private: | |||
| 848 | int64_t position, | 901 | int64_t position, |
| 849 | int whence) | 902 | int whence) |
| 850 | { | 903 | { |
| 851 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance) | 904 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance) |
| 852 | ->SeekStream(position, whence); | 905 | ->SeekStream(position, whence); |
| 853 | } | 906 | } |
| 854 | 907 | ||
| 855 | inline static int64_t ADDON_PositionStream(const AddonInstance_InputStream* instance) | 908 | inline static int64_t ADDON_PositionStream(const AddonInstance_InputStream* instance) |
| 856 | { | 909 | { |
| 857 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->PositionStream(); | 910 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->PositionStream(); |
| 858 | } | 911 | } |
| 859 | 912 | ||
| 860 | inline static int64_t ADDON_LengthStream(const AddonInstance_InputStream* instance) | 913 | inline static int64_t ADDON_LengthStream(const AddonInstance_InputStream* instance) |
| 861 | { | 914 | { |
| 862 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->LengthStream(); | 915 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->LengthStream(); |
| 863 | } | 916 | } |
| 864 | 917 | ||
| 865 | inline static int ADDON_GetBlockSize(const AddonInstance_InputStream* instance) | 918 | inline static int ADDON_GetBlockSize(const AddonInstance_InputStream* instance) |
| 866 | { | 919 | { |
| 867 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetBlockSize(); | 920 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetBlockSize(); |
| 868 | } | 921 | } |
| 869 | 922 | ||
| 870 | inline static bool ADDON_IsRealTimeStream(const AddonInstance_InputStream* instance) | 923 | inline static bool ADDON_IsRealTimeStream(const AddonInstance_InputStream* instance) |
| 871 | { | 924 | { |
| 872 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->IsRealTimeStream(); | 925 | return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->IsRealTimeStream(); |
| 873 | } | 926 | } |
| 874 | 927 | ||
| 875 | AddonInstance_InputStream* m_instanceData; | 928 | AddonInstance_InputStream* m_instanceData; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PVR.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h index 0bca8e2..d5977a7 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PVR.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h | |||
| @@ -364,7 +364,7 @@ namespace addon | |||
| 364 | /// { | 364 | /// { |
| 365 | /// if (instanceType == ADDON_INSTANCE_PVR) | 365 | /// if (instanceType == ADDON_INSTANCE_PVR) |
| 366 | /// { | 366 | /// { |
| 367 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my PVR client instance"); | 367 | /// kodi::Log(ADDON_LOG_INFO, "Creating my PVR client instance"); |
| 368 | /// addonInstance = new CMyPVRClient(instance, version); | 368 | /// addonInstance = new CMyPVRClient(instance, version); |
| 369 | /// return ADDON_STATUS_OK; | 369 | /// return ADDON_STATUS_OK; |
| 370 | /// } | 370 | /// } |
| @@ -484,7 +484,7 @@ public: | |||
| 484 | /// const std::string& version, | 484 | /// const std::string& version, |
| 485 | /// KODI_HANDLE& addonInstance) | 485 | /// KODI_HANDLE& addonInstance) |
| 486 | /// { | 486 | /// { |
| 487 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my PVR client instance"); | 487 | /// kodi::Log(ADDON_LOG_INFO, "Creating my PVR client instance"); |
| 488 | /// addonInstance = new CMyPVRClient(instance, version); | 488 | /// addonInstance = new CMyPVRClient(instance, version); |
| 489 | /// return ADDON_STATUS_OK; | 489 | /// return ADDON_STATUS_OK; |
| 490 | /// } | 490 | /// } |
| @@ -623,8 +623,8 @@ public: | |||
| 623 | //============================================================================ | 623 | //============================================================================ |
| 624 | /// @brief Get the disk space reported by the backend (if supported). | 624 | /// @brief Get the disk space reported by the backend (if supported). |
| 625 | /// | 625 | /// |
| 626 | /// @param[in] total The total disk space in bytes. | 626 | /// @param[in] total The total disk space in KiB. |
| 627 | /// @param[in] used The used disk space in bytes. | 627 | /// @param[in] used The used disk space in KiB. |
| 628 | /// @return @ref PVR_ERROR_NO_ERROR if the drive space has been fetched | 628 | /// @return @ref PVR_ERROR_NO_ERROR if the drive space has been fetched |
| 629 | /// successfully. | 629 | /// successfully. |
| 630 | /// | 630 | /// |
| @@ -635,8 +635,8 @@ public: | |||
| 635 | /// ~~~~~~~~~~~~~{.cpp} | 635 | /// ~~~~~~~~~~~~~{.cpp} |
| 636 | /// PVR_ERROR CMyPVRClient::GetDriveSpace(uint64_t& total, uint64_t& used) | 636 | /// PVR_ERROR CMyPVRClient::GetDriveSpace(uint64_t& total, uint64_t& used) |
| 637 | /// { | 637 | /// { |
| 638 | /// total = 10 * 1024 * 1024 * 1024; // To set complete size of drive in bytes | 638 | /// total = 100 * 1024 * 1024; // To set complete size of drive in KiB (100GB) |
| 639 | /// used = 122324243; // To set the used amount | 639 | /// used = 12232424; // To set the used amount |
| 640 | /// return PVR_ERROR_NO_ERROR; | 640 | /// return PVR_ERROR_NO_ERROR; |
| 641 | /// } | 641 | /// } |
| 642 | /// ~~~~~~~~~~~~~ | 642 | /// ~~~~~~~~~~~~~ |
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Peripheral.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Peripheral.h new file mode 100644 index 0000000..46060a8 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Peripheral.h | |||
| @@ -0,0 +1,907 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | #include "peripheral/PeripheralUtils.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | namespace kodi | ||
| 16 | { | ||
| 17 | namespace addon | ||
| 18 | { | ||
| 19 | |||
| 20 | //############################################################################## | ||
| 21 | /// @defgroup cpp_kodi_addon_peripheral_Defs Definitions, structures and enumerators | ||
| 22 | /// @ingroup cpp_kodi_addon_peripheral | ||
| 23 | /// @brief %Peripheral add-on general variables | ||
| 24 | /// | ||
| 25 | /// Used to exchange the available options between Kodi and addon. | ||
| 26 | /// | ||
| 27 | /// | ||
| 28 | |||
| 29 | //############################################################################## | ||
| 30 | /// @defgroup cpp_kodi_addon_peripheral_Defs_General 1. General | ||
| 31 | /// @ingroup cpp_kodi_addon_peripheral_Defs | ||
| 32 | /// @brief **%Peripheral add-on general variables**\n | ||
| 33 | /// Used to exchange the available options between Kodi and addon. | ||
| 34 | /// | ||
| 35 | /// This group also includes @ref cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities | ||
| 36 | /// with which Kodi an @ref kodi::addon::CInstancePeripheral::GetCapabilities() | ||
| 37 | /// queries the supported **modules** of the addon. | ||
| 38 | /// | ||
| 39 | |||
| 40 | //############################################################################## | ||
| 41 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Peripheral 2. Peripheral | ||
| 42 | /// @ingroup cpp_kodi_addon_peripheral_Defs | ||
| 43 | /// @brief **%Peripheral add-on operation variables**\n | ||
| 44 | /// Used to exchange the available options between Kodi and addon. | ||
| 45 | /// | ||
| 46 | |||
| 47 | //############################################################################## | ||
| 48 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Event 3. Event | ||
| 49 | /// @ingroup cpp_kodi_addon_peripheral_Defs | ||
| 50 | /// @brief **%Event add-on operation variables**\n | ||
| 51 | /// Used to exchange the available options between Kodi and addon. | ||
| 52 | /// | ||
| 53 | |||
| 54 | //############################################################################## | ||
| 55 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick 4. Joystick | ||
| 56 | /// @ingroup cpp_kodi_addon_peripheral_Defs | ||
| 57 | /// @brief **%Joystick add-on operation variables**\n | ||
| 58 | /// Used to exchange the available options between Kodi and addon. | ||
| 59 | /// | ||
| 60 | |||
| 61 | //============================================================================== | ||
| 62 | /// @addtogroup cpp_kodi_addon_peripheral | ||
| 63 | /// @brief \cpp_class{ kodi::addon::CInstancePeripheral } | ||
| 64 | /// **%Peripheral add-on instance** | ||
| 65 | /// | ||
| 66 | /// The peripheral add-ons provides access to many joystick and gamepad | ||
| 67 | /// interfaces across various platforms. An input addon is used to map the | ||
| 68 | /// buttons/axis on your physical input device, to the buttons/axis of your | ||
| 69 | /// virtual system. This is necessary because different retro systems usually | ||
| 70 | /// have different button layouts. A controller configuration utility is also | ||
| 71 | /// in the works. | ||
| 72 | /// | ||
| 73 | /// ---------------------------------------------------------------------------- | ||
| 74 | /// | ||
| 75 | /// Here is an example of what the <b>`addon.xml.in`</b> would look like for an | ||
| 76 | /// peripheral addon: | ||
| 77 | /// | ||
| 78 | /// ~~~~~~~~~~~~~{.xml} | ||
| 79 | /// <?xml version="1.0" encoding="UTF-8"?> | ||
| 80 | /// <addon | ||
| 81 | /// id="peripheral.myspecialnamefor" | ||
| 82 | /// version="1.0.0" | ||
| 83 | /// name="My special peripheral addon" | ||
| 84 | /// provider-name="Your Name"> | ||
| 85 | /// <requires>@ADDON_DEPENDS@</requires> | ||
| 86 | /// <extension | ||
| 87 | /// point="kodi.peripheral" | ||
| 88 | /// provides_joysticks="true" | ||
| 89 | /// provides_buttonmaps="true" | ||
| 90 | /// library_@PLATFORM@="@LIBRARY_FILENAME@"/> | ||
| 91 | /// <extension point="xbmc.addon.metadata"> | ||
| 92 | /// <summary lang="en_GB">My peripheral addon</summary> | ||
| 93 | /// <description lang="en_GB">My peripheral addon description</description> | ||
| 94 | /// <platform>@PLATFORM@</platform> | ||
| 95 | /// </extension> | ||
| 96 | /// </addon> | ||
| 97 | /// ~~~~~~~~~~~~~ | ||
| 98 | /// | ||
| 99 | /// Description to peripheral related addon.xml values: | ||
| 100 | /// | Name | Description | ||
| 101 | /// |:------------------------------|---------------------------------------- | ||
| 102 | /// | <b>`provides_joysticks`</b> | Set to "true" if addon provides joystick support. | ||
| 103 | /// | <b>`provides_buttonmaps`</b> | Set to "true" if button map is used and supported by addon. | ||
| 104 | /// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"kodi.peripheral"</b>. | ||
| 105 | /// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build. | ||
| 106 | /// | ||
| 107 | /// @remark For more detailed description of the <b>`addon.xml`</b>, see also https://kodi.wiki/view/Addon.xml. | ||
| 108 | /// | ||
| 109 | /// | ||
| 110 | /// -------------------------------------------------------------------------- | ||
| 111 | /// | ||
| 112 | /// **Here is an example of how addon can be used as a single:** | ||
| 113 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 114 | /// #include <kodi/addon-instance/Peripheral.h> | ||
| 115 | /// | ||
| 116 | /// class CMyPeripheralAddon : public kodi::addon::CAddonBase, | ||
| 117 | /// public kodi::addon::CInstancePeripheral | ||
| 118 | /// { | ||
| 119 | /// public: | ||
| 120 | /// CMyPeripheralAddon(); | ||
| 121 | /// | ||
| 122 | /// void GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities) override; | ||
| 123 | /// ... | ||
| 124 | /// }; | ||
| 125 | /// | ||
| 126 | /// CMyPeripheralAddon::CMyPeripheralAddon() | ||
| 127 | /// { | ||
| 128 | /// ... | ||
| 129 | /// } | ||
| 130 | /// | ||
| 131 | /// void CMyPeripheralAddon::GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities) | ||
| 132 | /// { | ||
| 133 | /// capabilities.SetProvidesJoysticks(true); | ||
| 134 | /// capabilities.SetProvidesButtonmaps(true); | ||
| 135 | /// ... | ||
| 136 | /// } | ||
| 137 | /// | ||
| 138 | /// ADDONCREATOR(CMyPeripheralAddon) | ||
| 139 | /// ~~~~~~~~~~~~~ | ||
| 140 | /// | ||
| 141 | /// @note It is imperative to use the necessary functions of this class in the | ||
| 142 | /// addon. | ||
| 143 | /// | ||
| 144 | /// -------------------------------------------------------------------------- | ||
| 145 | /// | ||
| 146 | /// | ||
| 147 | /// **Here is another example where the peripheral is used together with | ||
| 148 | /// other instance types:** | ||
| 149 | /// | ||
| 150 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 151 | /// #include <kodi/addon-instance/Peripheral.h> | ||
| 152 | /// | ||
| 153 | /// class CMyPeripheralAddon : public kodi::addon::CInstancePeripheral | ||
| 154 | /// { | ||
| 155 | /// public: | ||
| 156 | /// CMyPeripheralAddon(KODI_HANDLE instance, const std::string& version); | ||
| 157 | /// | ||
| 158 | /// void GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities) override; | ||
| 159 | /// ... | ||
| 160 | /// }; | ||
| 161 | /// | ||
| 162 | /// CMyPeripheralAddon::CMyPeripheralAddon(KODI_HANDLE instance, const std::string& version) | ||
| 163 | /// : CInstancePeripheral(instance, version) | ||
| 164 | /// { | ||
| 165 | /// ... | ||
| 166 | /// } | ||
| 167 | /// | ||
| 168 | /// void CMyPeripheralAddon::GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities) | ||
| 169 | /// { | ||
| 170 | /// capabilities.SetProvidesJoysticks(true); | ||
| 171 | /// capabilities.SetProvidesButtonmaps(true); | ||
| 172 | /// ... | ||
| 173 | /// } | ||
| 174 | /// | ||
| 175 | /// //---------------------------------------------------------------------- | ||
| 176 | /// | ||
| 177 | /// class CMyAddon : public kodi::addon::CAddonBase | ||
| 178 | /// { | ||
| 179 | /// public: | ||
| 180 | /// CMyAddon() = default; | ||
| 181 | /// ADDON_STATUS CreateInstance(int instanceType, | ||
| 182 | /// const std::string& instanceID, | ||
| 183 | /// KODI_HANDLE instance, | ||
| 184 | /// const std::string& version, | ||
| 185 | /// KODI_HANDLE& addonInstance) override; | ||
| 186 | /// }; | ||
| 187 | /// | ||
| 188 | /// // If you use only one instance in your add-on, can be instanceType and | ||
| 189 | /// // instanceID ignored | ||
| 190 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 191 | /// const std::string& instanceID, | ||
| 192 | /// KODI_HANDLE instance, | ||
| 193 | /// const std::string& version, | ||
| 194 | /// KODI_HANDLE& addonInstance) | ||
| 195 | /// { | ||
| 196 | /// if (instanceType == ADDON_INSTANCE_PERIPHERAL) | ||
| 197 | /// { | ||
| 198 | /// kodi::Log(ADDON_LOG_INFO, "Creating my peripheral addon"); | ||
| 199 | /// addonInstance = new CMyPeripheralAddon(instance, version); | ||
| 200 | /// return ADDON_STATUS_OK; | ||
| 201 | /// } | ||
| 202 | /// else if (...) | ||
| 203 | /// { | ||
| 204 | /// ... | ||
| 205 | /// } | ||
| 206 | /// return ADDON_STATUS_UNKNOWN; | ||
| 207 | /// } | ||
| 208 | /// | ||
| 209 | /// ADDONCREATOR(CMyAddon) | ||
| 210 | /// ~~~~~~~~~~~~~ | ||
| 211 | /// | ||
| 212 | /// The destruction of the example class `CMyPeripheralAddon` is called from | ||
| 213 | /// Kodi's header. Manually deleting the add-on instance is not required. | ||
| 214 | /// | ||
| 215 | class ATTRIBUTE_HIDDEN CInstancePeripheral : public IAddonInstance | ||
| 216 | { | ||
| 217 | public: | ||
| 218 | //============================================================================ | ||
| 219 | /// @ingroup cpp_kodi_addon_peripheral | ||
| 220 | /// @brief %Peripheral class constructor. | ||
| 221 | /// | ||
| 222 | /// Used by an add-on that only supports peripheral. | ||
| 223 | /// | ||
| 224 | CInstancePeripheral() | ||
| 225 | : IAddonInstance(ADDON_INSTANCE_PERIPHERAL, GetKodiTypeVersion(ADDON_INSTANCE_PERIPHERAL)) | ||
| 226 | { | ||
| 227 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 228 | throw std::logic_error("kodi::addon::CInstancePeripheral: Creation of more as one in single " | ||
| 229 | "instance way is not allowed!"); | ||
| 230 | |||
| 231 | SetAddonStruct(CAddonBase::m_interface->firstKodiInstance); | ||
| 232 | CAddonBase::m_interface->globalSingleInstance = this; | ||
| 233 | } | ||
| 234 | //---------------------------------------------------------------------------- | ||
| 235 | |||
| 236 | //============================================================================ | ||
| 237 | /// @ingroup cpp_kodi_addon_peripheral | ||
| 238 | /// @brief %Peripheral addon class constructor used to support multiple | ||
| 239 | /// instance types. | ||
| 240 | /// | ||
| 241 | /// @param[in] instance The instance value given to | ||
| 242 | /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>. | ||
| 243 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to | ||
| 244 | /// allow compatibility to older Kodi versions. | ||
| 245 | /// | ||
| 246 | /// @note Recommended to set <b>`kodiVersion`</b>. | ||
| 247 | /// | ||
| 248 | /// | ||
| 249 | /// -------------------------------------------------------------------------- | ||
| 250 | /// | ||
| 251 | //////*Here's example about the use of this:** | ||
| 252 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 253 | /// class CMyPeripheralAddon : public kodi::addon::CInstancePeripheral | ||
| 254 | /// { | ||
| 255 | /// public: | ||
| 256 | /// CMyPeripheralAddon(KODI_HANDLE instance, const std::string& kodiVersion) | ||
| 257 | /// : kodi::addon::CInstancePeripheral(instance, kodiVersion) | ||
| 258 | /// { | ||
| 259 | /// ... | ||
| 260 | /// } | ||
| 261 | /// | ||
| 262 | /// ... | ||
| 263 | /// }; | ||
| 264 | /// | ||
| 265 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 266 | /// const std::string& instanceID, | ||
| 267 | /// KODI_HANDLE instance, | ||
| 268 | /// const std::string& version, | ||
| 269 | /// KODI_HANDLE& addonInstance) | ||
| 270 | /// { | ||
| 271 | /// kodi::Log(ADDON_LOG_INFO, "Creating my peripheral"); | ||
| 272 | /// addonInstance = new CMyPeripheralAddon(instance, version); | ||
| 273 | /// return ADDON_STATUS_OK; | ||
| 274 | /// } | ||
| 275 | /// ~~~~~~~~~~~~~ | ||
| 276 | /// | ||
| 277 | explicit CInstancePeripheral(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 278 | : IAddonInstance(ADDON_INSTANCE_PERIPHERAL, | ||
| 279 | !kodiVersion.empty() ? kodiVersion | ||
| 280 | : GetKodiTypeVersion(ADDON_INSTANCE_PERIPHERAL)) | ||
| 281 | { | ||
| 282 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 283 | throw std::logic_error("kodi::addon::CInstancePeripheral: Creation of multiple together with " | ||
| 284 | "single instance way is not allowed!"); | ||
| 285 | |||
| 286 | SetAddonStruct(instance); | ||
| 287 | } | ||
| 288 | //---------------------------------------------------------------------------- | ||
| 289 | |||
| 290 | //============================================================================ | ||
| 291 | /// @ingroup cpp_kodi_addon_peripheral | ||
| 292 | /// @brief Destructor. | ||
| 293 | /// | ||
| 294 | ~CInstancePeripheral() override = default; | ||
| 295 | //---------------------------------------------------------------------------- | ||
| 296 | |||
| 297 | //============================================================================ | ||
| 298 | /// @defgroup cpp_kodi_addon_peripheral_peripheralOp 1. Peripheral operations | ||
| 299 | /// @ingroup cpp_kodi_addon_peripheral | ||
| 300 | /// @brief %Peripheral operations to handle control about. | ||
| 301 | /// | ||
| 302 | ///--------------------------------------------------------------------------- | ||
| 303 | /// | ||
| 304 | /// **%Peripheral parts in interface:**\n | ||
| 305 | /// Copy this to your project and extend with your parts or leave functions | ||
| 306 | /// complete away where not used or supported. | ||
| 307 | /// | ||
| 308 | /// @copydetails cpp_kodi_addon_peripheral_peripheralOp_header_addon_auto_check | ||
| 309 | /// @copydetails cpp_kodi_addon_peripheral_peripheralOp_source_addon_auto_check | ||
| 310 | /// | ||
| 311 | ///@{ | ||
| 312 | |||
| 313 | //============================================================================ | ||
| 314 | /// @brief Get the list of features that this add-on provides. | ||
| 315 | /// | ||
| 316 | /// Called by the frontend to query the add-on's capabilities and supported | ||
| 317 | /// peripherals. All capabilities that the add-on supports should be set to true. | ||
| 318 | /// | ||
| 319 | /// @param[out] capabilities The add-on's capabilities | ||
| 320 | /// | ||
| 321 | /// @remarks Valid implementation required. | ||
| 322 | /// | ||
| 323 | /// | ||
| 324 | /// ---------------------------------------------------------------------------- | ||
| 325 | /// | ||
| 326 | /// @copydetails cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities_Help | ||
| 327 | /// | ||
| 328 | /// -------------------------------------------------------------------------- | ||
| 329 | /// | ||
| 330 | /// **Example:** | ||
| 331 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 332 | /// void CMyPeripheralAddon::GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities) | ||
| 333 | /// { | ||
| 334 | /// capabilities.SetProvidesJoysticks(true); | ||
| 335 | /// capabilities.SetProvidesButtonmaps(true); | ||
| 336 | /// } | ||
| 337 | /// ~~~~~~~~~~~~~ | ||
| 338 | /// | ||
| 339 | virtual void GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities) {} | ||
| 340 | //---------------------------------------------------------------------------- | ||
| 341 | |||
| 342 | //============================================================================ | ||
| 343 | /// @brief Perform a scan for joysticks | ||
| 344 | /// | ||
| 345 | /// The frontend calls this when a hardware change is detected. If an add-on | ||
| 346 | /// detects a hardware change, it can trigger this function using the | ||
| 347 | /// @ref TriggerScan() callback. | ||
| 348 | /// | ||
| 349 | /// @param[in] scan_results Assigned to allocated memory | ||
| 350 | /// @return @ref PERIPHERAL_NO_ERROR if successful | ||
| 351 | /// | ||
| 352 | /// | ||
| 353 | /// -------------------------------------------------------------------------- | ||
| 354 | /// | ||
| 355 | /// @copydetails cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral_Help | ||
| 356 | /// | ||
| 357 | virtual PERIPHERAL_ERROR PerformDeviceScan( | ||
| 358 | std::vector<std::shared_ptr<kodi::addon::Peripheral>>& scan_results) | ||
| 359 | { | ||
| 360 | return PERIPHERAL_ERROR_NOT_IMPLEMENTED; | ||
| 361 | } | ||
| 362 | //---------------------------------------------------------------------------- | ||
| 363 | |||
| 364 | //============================================================================ | ||
| 365 | /// @brief Get all events that have occurred since the last call to | ||
| 366 | /// @ref GetEvents(). | ||
| 367 | /// | ||
| 368 | /// @param[out] events List of available events within addon | ||
| 369 | /// @return @ref PERIPHERAL_NO_ERROR if successful | ||
| 370 | /// | ||
| 371 | /// ---------------------------------------------------------------------------- | ||
| 372 | /// | ||
| 373 | /// @copydetails cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent_Help | ||
| 374 | /// | ||
| 375 | virtual PERIPHERAL_ERROR GetEvents(std::vector<kodi::addon::PeripheralEvent>& events) | ||
| 376 | { | ||
| 377 | return PERIPHERAL_ERROR_NOT_IMPLEMENTED; | ||
| 378 | } | ||
| 379 | //---------------------------------------------------------------------------- | ||
| 380 | |||
| 381 | //============================================================================ | ||
| 382 | /// @brief Send an input event to the peripheral. | ||
| 383 | /// | ||
| 384 | /// @param[in] event The input event | ||
| 385 | /// @return true if the event was handled, false otherwise | ||
| 386 | /// | ||
| 387 | virtual bool SendEvent(const kodi::addon::PeripheralEvent& event) { return false; } | ||
| 388 | //---------------------------------------------------------------------------- | ||
| 389 | |||
| 390 | ///@} | ||
| 391 | |||
| 392 | //============================================================================ | ||
| 393 | /// @defgroup cpp_kodi_addon_peripheral_joystickOp 2. Joystick operations | ||
| 394 | /// @ingroup cpp_kodi_addon_peripheral | ||
| 395 | /// @brief %Joystick operations to handle control about. | ||
| 396 | /// | ||
| 397 | /// | ||
| 398 | ///--------------------------------------------------------------------------- | ||
| 399 | /// | ||
| 400 | /// **%Joystick parts in interface:**\n | ||
| 401 | /// Copy this to your project and extend with your parts or leave functions | ||
| 402 | /// complete away where not used or supported. | ||
| 403 | /// | ||
| 404 | /// @copydetails cpp_kodi_addon_peripheral_joystickOp_header_addon_auto_check | ||
| 405 | /// @copydetails cpp_kodi_addon_peripheral_joystickOp_source_addon_auto_check | ||
| 406 | /// | ||
| 407 | ///@{ | ||
| 408 | |||
| 409 | //============================================================================ | ||
| 410 | /// @brief Get extended info about an attached joystick. | ||
| 411 | /// | ||
| 412 | /// @param[in] index The joystick's driver index | ||
| 413 | /// @param[out] info The container for the allocated joystick info | ||
| 414 | /// @return @ref PERIPHERAL_NO_ERROR if successful | ||
| 415 | /// | ||
| 416 | /// | ||
| 417 | /// ---------------------------------------------------------------------------- | ||
| 418 | /// | ||
| 419 | /// @copydetails cpp_kodi_addon_peripheral_Defs_Joystick_Joystick_Help | ||
| 420 | /// | ||
| 421 | virtual PERIPHERAL_ERROR GetJoystickInfo(unsigned int index, kodi::addon::Joystick& info) | ||
| 422 | { | ||
| 423 | return PERIPHERAL_ERROR_NOT_IMPLEMENTED; | ||
| 424 | } | ||
| 425 | //---------------------------------------------------------------------------- | ||
| 426 | |||
| 427 | //============================================================================ | ||
| 428 | /// @brief Get the features that allow translating the joystick into the | ||
| 429 | /// controller profile. | ||
| 430 | /// | ||
| 431 | /// @param[in] joystick The device's joystick properties; unknown values may | ||
| 432 | /// be left at their default | ||
| 433 | /// @param[in] controller_id The controller profile being requested, e.g. | ||
| 434 | /// `game.controller.default` | ||
| 435 | /// @param[out] features The array of allocated features | ||
| 436 | /// @return @ref PERIPHERAL_NO_ERROR if successful | ||
| 437 | /// | ||
| 438 | virtual PERIPHERAL_ERROR GetFeatures(const kodi::addon::Joystick& joystick, | ||
| 439 | const std::string& controller_id, | ||
| 440 | std::vector<kodi::addon::JoystickFeature>& features) | ||
| 441 | { | ||
| 442 | return PERIPHERAL_ERROR_NOT_IMPLEMENTED; | ||
| 443 | } | ||
| 444 | //---------------------------------------------------------------------------- | ||
| 445 | |||
| 446 | //============================================================================ | ||
| 447 | /// @brief Add or update joystick features. | ||
| 448 | /// | ||
| 449 | /// @param[in] joystick The device's joystick properties; unknown values may be | ||
| 450 | /// left at their default | ||
| 451 | /// @param[in] controller_id The game controller profile being updated | ||
| 452 | /// @param[in] features The array of features | ||
| 453 | /// @return @ref PERIPHERAL_NO_ERROR if successful | ||
| 454 | /// | ||
| 455 | virtual PERIPHERAL_ERROR MapFeatures(const kodi::addon::Joystick& joystick, | ||
| 456 | const std::string& controller_id, | ||
| 457 | const std::vector<kodi::addon::JoystickFeature>& features) | ||
| 458 | { | ||
| 459 | return PERIPHERAL_ERROR_NOT_IMPLEMENTED; | ||
| 460 | } | ||
| 461 | //---------------------------------------------------------------------------- | ||
| 462 | |||
| 463 | //============================================================================ | ||
| 464 | /// @brief Get the driver primitives that should be ignored while mapping the | ||
| 465 | /// device. | ||
| 466 | /// | ||
| 467 | /// @param[in] joystick The device's joystick properties; unknown values may | ||
| 468 | /// be left at their default | ||
| 469 | /// @param[out] primitives The array of allocated driver primitives to be | ||
| 470 | /// ignored | ||
| 471 | /// @return @ref PERIPHERAL_NO_ERROR if successful | ||
| 472 | /// | ||
| 473 | virtual PERIPHERAL_ERROR GetIgnoredPrimitives( | ||
| 474 | const kodi::addon::Joystick& joystick, std::vector<kodi::addon::DriverPrimitive>& primitives) | ||
| 475 | { | ||
| 476 | return PERIPHERAL_ERROR_NOT_IMPLEMENTED; | ||
| 477 | } | ||
| 478 | //---------------------------------------------------------------------------- | ||
| 479 | |||
| 480 | //============================================================================ | ||
| 481 | /// @brief Set the list of driver primitives that are ignored for the device. | ||
| 482 | /// | ||
| 483 | /// @param[in] joystick The device's joystick properties; unknown values may be left at their default | ||
| 484 | /// @param[in] primitives The array of driver primitives to ignore | ||
| 485 | /// @return @ref PERIPHERAL_NO_ERROR if successful | ||
| 486 | /// | ||
| 487 | virtual PERIPHERAL_ERROR SetIgnoredPrimitives( | ||
| 488 | const kodi::addon::Joystick& joystick, | ||
| 489 | const std::vector<kodi::addon::DriverPrimitive>& primitives) | ||
| 490 | { | ||
| 491 | return PERIPHERAL_ERROR_NOT_IMPLEMENTED; | ||
| 492 | } | ||
| 493 | //---------------------------------------------------------------------------- | ||
| 494 | |||
| 495 | //============================================================================ | ||
| 496 | /// @brief Save the button map for the given joystick. | ||
| 497 | /// | ||
| 498 | /// @param[in] joystick The device's joystick properties | ||
| 499 | /// | ||
| 500 | virtual void SaveButtonMap(const kodi::addon::Joystick& joystick) {} | ||
| 501 | //---------------------------------------------------------------------------- | ||
| 502 | |||
| 503 | //============================================================================ | ||
| 504 | /// @brief Revert the button map to the last time it was loaded or committed to disk | ||
| 505 | /// @param[in] joystick The device's joystick properties | ||
| 506 | /// | ||
| 507 | virtual void RevertButtonMap(const kodi::addon::Joystick& joystick) {} | ||
| 508 | //---------------------------------------------------------------------------- | ||
| 509 | |||
| 510 | //============================================================================ | ||
| 511 | /// @brief Reset the button map for the given joystick and controller profile ID | ||
| 512 | /// @param[in] joystick The device's joystick properties | ||
| 513 | /// @param[in] controller_id The game controller profile being reset | ||
| 514 | /// | ||
| 515 | virtual void ResetButtonMap(const kodi::addon::Joystick& joystick, | ||
| 516 | const std::string& controller_id) | ||
| 517 | { | ||
| 518 | } | ||
| 519 | //---------------------------------------------------------------------------- | ||
| 520 | |||
| 521 | //============================================================================ | ||
| 522 | /// @brief Powers off the given joystick if supported | ||
| 523 | /// @param[in] index The joystick's driver index | ||
| 524 | /// | ||
| 525 | virtual void PowerOffJoystick(unsigned int index) {} | ||
| 526 | //---------------------------------------------------------------------------- | ||
| 527 | |||
| 528 | ///@} | ||
| 529 | |||
| 530 | //============================================================================ | ||
| 531 | /// @defgroup cpp_kodi_addon_peripheral_callbacks 3. Callback functions | ||
| 532 | /// @ingroup cpp_kodi_addon_peripheral | ||
| 533 | /// @brief Callback to Kodi functions. | ||
| 534 | /// | ||
| 535 | ///@{ | ||
| 536 | |||
| 537 | //============================================================================ | ||
| 538 | /// @brief Used to get the full path where the add-on is installed. | ||
| 539 | /// | ||
| 540 | /// @return The add-on installation path | ||
| 541 | /// | ||
| 542 | const std::string AddonPath() const { return m_instanceData->props->addon_path; } | ||
| 543 | //---------------------------------------------------------------------------- | ||
| 544 | |||
| 545 | //============================================================================ | ||
| 546 | /// @brief Used to get the full path to the add-on's user profile. | ||
| 547 | /// | ||
| 548 | /// @note The trailing folder (consisting of the add-on's ID) is not created | ||
| 549 | /// by default. If it is needed, you must call kodi::vfs::CreateDirectory() | ||
| 550 | /// to create the folder. | ||
| 551 | /// | ||
| 552 | /// @return Path to the user profile | ||
| 553 | /// | ||
| 554 | const std::string UserPath() const { return m_instanceData->props->user_path; } | ||
| 555 | //---------------------------------------------------------------------------- | ||
| 556 | |||
| 557 | //============================================================================ | ||
| 558 | /// @brief Trigger a scan for peripherals | ||
| 559 | /// | ||
| 560 | /// The add-on calls this if a change in hardware is detected. | ||
| 561 | /// | ||
| 562 | void TriggerScan(void) | ||
| 563 | { | ||
| 564 | return m_instanceData->toKodi->trigger_scan(m_instanceData->toKodi->kodiInstance); | ||
| 565 | } | ||
| 566 | //---------------------------------------------------------------------------- | ||
| 567 | |||
| 568 | //============================================================================ | ||
| 569 | /// @brief Notify the frontend that button maps have changed. | ||
| 570 | /// | ||
| 571 | /// @param[in] deviceName [optional] The name of the device to refresh, or | ||
| 572 | /// empty/null for all devices | ||
| 573 | /// @param[in] controllerId [optional] The controller ID to refresh, or | ||
| 574 | /// empty/null for all controllers | ||
| 575 | /// | ||
| 576 | void RefreshButtonMaps(const std::string& deviceName = "", const std::string& controllerId = "") | ||
| 577 | { | ||
| 578 | return m_instanceData->toKodi->refresh_button_maps(m_instanceData->toKodi->kodiInstance, | ||
| 579 | deviceName.c_str(), controllerId.c_str()); | ||
| 580 | } | ||
| 581 | //---------------------------------------------------------------------------- | ||
| 582 | |||
| 583 | //============================================================================ | ||
| 584 | /// @brief Return the number of features belonging to the specified | ||
| 585 | /// controller. | ||
| 586 | /// | ||
| 587 | /// @param[in] controllerId The controller ID to enumerate | ||
| 588 | /// @param[in] type [optional] Type to filter by, or @ref JOYSTICK_FEATURE_TYPE_UNKNOWN | ||
| 589 | /// for all features | ||
| 590 | /// @return The number of features matching the request parameters | ||
| 591 | /// | ||
| 592 | unsigned int FeatureCount(const std::string& controllerId, | ||
| 593 | JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN) | ||
| 594 | { | ||
| 595 | return m_instanceData->toKodi->feature_count(m_instanceData->toKodi->kodiInstance, | ||
| 596 | controllerId.c_str(), type); | ||
| 597 | } | ||
| 598 | //---------------------------------------------------------------------------- | ||
| 599 | |||
| 600 | //============================================================================ | ||
| 601 | /// @brief Return the type of the feature. | ||
| 602 | /// | ||
| 603 | /// @param[in] controllerId The controller ID to check | ||
| 604 | /// @param[in] featureName The feature to check | ||
| 605 | /// @return The type of the specified feature, or @ref JOYSTICK_FEATURE_TYPE_UNKNOWN | ||
| 606 | /// if unknown | ||
| 607 | /// | ||
| 608 | JOYSTICK_FEATURE_TYPE FeatureType(const std::string& controllerId, const std::string& featureName) | ||
| 609 | { | ||
| 610 | return m_instanceData->toKodi->feature_type(m_instanceData->toKodi->kodiInstance, | ||
| 611 | controllerId.c_str(), featureName.c_str()); | ||
| 612 | } | ||
| 613 | //---------------------------------------------------------------------------- | ||
| 614 | |||
| 615 | ///@} | ||
| 616 | |||
| 617 | private: | ||
| 618 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 619 | { | ||
| 620 | if (instance == nullptr) | ||
| 621 | throw std::logic_error("kodi::addon::CInstancePeripheral: Creation with empty addon " | ||
| 622 | "structure not allowed, table must be given from Kodi!"); | ||
| 623 | |||
| 624 | m_instanceData = static_cast<AddonInstance_Peripheral*>(instance); | ||
| 625 | m_instanceData->toAddon->addonInstance = this; | ||
| 626 | |||
| 627 | m_instanceData->toAddon->get_capabilities = ADDON_GetCapabilities; | ||
| 628 | m_instanceData->toAddon->perform_device_scan = ADDON_PerformDeviceScan; | ||
| 629 | m_instanceData->toAddon->free_scan_results = ADDON_FreeScanResults; | ||
| 630 | m_instanceData->toAddon->get_events = ADDON_GetEvents; | ||
| 631 | m_instanceData->toAddon->free_events = ADDON_FreeEvents; | ||
| 632 | m_instanceData->toAddon->send_event = ADDON_SendEvent; | ||
| 633 | |||
| 634 | m_instanceData->toAddon->get_joystick_info = ADDON_GetJoystickInfo; | ||
| 635 | m_instanceData->toAddon->free_joystick_info = ADDON_FreeJoystickInfo; | ||
| 636 | m_instanceData->toAddon->get_features = ADDON_GetFeatures; | ||
| 637 | m_instanceData->toAddon->free_features = ADDON_FreeFeatures; | ||
| 638 | m_instanceData->toAddon->map_features = ADDON_MapFeatures; | ||
| 639 | m_instanceData->toAddon->get_ignored_primitives = ADDON_GetIgnoredPrimitives; | ||
| 640 | m_instanceData->toAddon->free_primitives = ADDON_FreePrimitives; | ||
| 641 | m_instanceData->toAddon->set_ignored_primitives = ADDON_SetIgnoredPrimitives; | ||
| 642 | m_instanceData->toAddon->save_button_map = ADDON_SaveButtonMap; | ||
| 643 | m_instanceData->toAddon->revert_button_map = ADDON_RevertButtonMap; | ||
| 644 | m_instanceData->toAddon->reset_button_map = ADDON_ResetButtonMap; | ||
| 645 | m_instanceData->toAddon->power_off_joystick = ADDON_PowerOffJoystick; | ||
| 646 | } | ||
| 647 | |||
| 648 | inline static void ADDON_GetCapabilities(const AddonInstance_Peripheral* addonInstance, | ||
| 649 | PERIPHERAL_CAPABILITIES* capabilities) | ||
| 650 | { | ||
| 651 | if (!addonInstance || !capabilities) | ||
| 652 | return; | ||
| 653 | |||
| 654 | kodi::addon::PeripheralCapabilities peripheralCapabilities(capabilities); | ||
| 655 | static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance) | ||
| 656 | ->GetCapabilities(peripheralCapabilities); | ||
| 657 | } | ||
| 658 | |||
| 659 | inline static PERIPHERAL_ERROR ADDON_PerformDeviceScan( | ||
| 660 | const AddonInstance_Peripheral* addonInstance, | ||
| 661 | unsigned int* peripheral_count, | ||
| 662 | PERIPHERAL_INFO** scan_results) | ||
| 663 | { | ||
| 664 | if (!addonInstance || !peripheral_count || !scan_results) | ||
| 665 | return PERIPHERAL_ERROR_INVALID_PARAMETERS; | ||
| 666 | |||
| 667 | std::vector<std::shared_ptr<kodi::addon::Peripheral>> peripherals; | ||
| 668 | PERIPHERAL_ERROR err = static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance) | ||
| 669 | ->PerformDeviceScan(peripherals); | ||
| 670 | if (err == PERIPHERAL_NO_ERROR) | ||
| 671 | { | ||
| 672 | *peripheral_count = static_cast<unsigned int>(peripherals.size()); | ||
| 673 | kodi::addon::Peripherals::ToStructs(peripherals, scan_results); | ||
| 674 | } | ||
| 675 | |||
| 676 | return err; | ||
| 677 | } | ||
| 678 | |||
| 679 | inline static void ADDON_FreeScanResults(const AddonInstance_Peripheral* addonInstance, | ||
| 680 | unsigned int peripheral_count, | ||
| 681 | PERIPHERAL_INFO* scan_results) | ||
| 682 | { | ||
| 683 | if (!addonInstance) | ||
| 684 | return; | ||
| 685 | |||
| 686 | kodi::addon::Peripherals::FreeStructs(peripheral_count, scan_results); | ||
| 687 | } | ||
| 688 | |||
| 689 | inline static PERIPHERAL_ERROR ADDON_GetEvents(const AddonInstance_Peripheral* addonInstance, | ||
| 690 | unsigned int* event_count, | ||
| 691 | PERIPHERAL_EVENT** events) | ||
| 692 | { | ||
| 693 | if (!addonInstance || !event_count || !events) | ||
| 694 | return PERIPHERAL_ERROR_INVALID_PARAMETERS; | ||
| 695 | |||
| 696 | std::vector<kodi::addon::PeripheralEvent> peripheralEvents; | ||
| 697 | PERIPHERAL_ERROR err = static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance) | ||
| 698 | ->GetEvents(peripheralEvents); | ||
| 699 | if (err == PERIPHERAL_NO_ERROR) | ||
| 700 | { | ||
| 701 | *event_count = static_cast<unsigned int>(peripheralEvents.size()); | ||
| 702 | kodi::addon::PeripheralEvents::ToStructs(peripheralEvents, events); | ||
| 703 | } | ||
| 704 | |||
| 705 | return err; | ||
| 706 | } | ||
| 707 | |||
| 708 | inline static void ADDON_FreeEvents(const AddonInstance_Peripheral* addonInstance, | ||
| 709 | unsigned int event_count, | ||
| 710 | PERIPHERAL_EVENT* events) | ||
| 711 | { | ||
| 712 | if (!addonInstance) | ||
| 713 | return; | ||
| 714 | |||
| 715 | kodi::addon::PeripheralEvents::FreeStructs(event_count, events); | ||
| 716 | } | ||
| 717 | |||
| 718 | inline static bool ADDON_SendEvent(const AddonInstance_Peripheral* addonInstance, | ||
| 719 | const PERIPHERAL_EVENT* event) | ||
| 720 | { | ||
| 721 | if (!addonInstance || !event) | ||
| 722 | return false; | ||
| 723 | return static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance) | ||
| 724 | ->SendEvent(kodi::addon::PeripheralEvent(*event)); | ||
| 725 | } | ||
| 726 | |||
| 727 | |||
| 728 | inline static PERIPHERAL_ERROR ADDON_GetJoystickInfo( | ||
| 729 | const AddonInstance_Peripheral* addonInstance, unsigned int index, JOYSTICK_INFO* info) | ||
| 730 | { | ||
| 731 | if (!addonInstance || !info) | ||
| 732 | return PERIPHERAL_ERROR_INVALID_PARAMETERS; | ||
| 733 | |||
| 734 | kodi::addon::Joystick addonInfo; | ||
| 735 | PERIPHERAL_ERROR err = static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance) | ||
| 736 | ->GetJoystickInfo(index, addonInfo); | ||
| 737 | if (err == PERIPHERAL_NO_ERROR) | ||
| 738 | { | ||
| 739 | addonInfo.ToStruct(*info); | ||
| 740 | } | ||
| 741 | |||
| 742 | return err; | ||
| 743 | } | ||
| 744 | |||
| 745 | inline static void ADDON_FreeJoystickInfo(const AddonInstance_Peripheral* addonInstance, | ||
| 746 | JOYSTICK_INFO* info) | ||
| 747 | { | ||
| 748 | if (!addonInstance) | ||
| 749 | return; | ||
| 750 | |||
| 751 | kodi::addon::Joystick::FreeStruct(*info); | ||
| 752 | } | ||
| 753 | |||
| 754 | inline static PERIPHERAL_ERROR ADDON_GetFeatures(const AddonInstance_Peripheral* addonInstance, | ||
| 755 | const JOYSTICK_INFO* joystick, | ||
| 756 | const char* controller_id, | ||
| 757 | unsigned int* feature_count, | ||
| 758 | JOYSTICK_FEATURE** features) | ||
| 759 | { | ||
| 760 | if (!addonInstance || !joystick || !controller_id || !feature_count || !features) | ||
| 761 | return PERIPHERAL_ERROR_INVALID_PARAMETERS; | ||
| 762 | |||
| 763 | kodi::addon::Joystick addonJoystick(*joystick); | ||
| 764 | std::vector<kodi::addon::JoystickFeature> featuresVector; | ||
| 765 | |||
| 766 | PERIPHERAL_ERROR err = static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance) | ||
| 767 | ->GetFeatures(addonJoystick, controller_id, featuresVector); | ||
| 768 | if (err == PERIPHERAL_NO_ERROR) | ||
| 769 | { | ||
| 770 | *feature_count = static_cast<unsigned int>(featuresVector.size()); | ||
| 771 | kodi::addon::JoystickFeatures::ToStructs(featuresVector, features); | ||
| 772 | } | ||
| 773 | |||
| 774 | return err; | ||
| 775 | } | ||
| 776 | |||
| 777 | inline static void ADDON_FreeFeatures(const AddonInstance_Peripheral* addonInstance, | ||
| 778 | unsigned int feature_count, | ||
| 779 | JOYSTICK_FEATURE* features) | ||
| 780 | { | ||
| 781 | if (!addonInstance) | ||
| 782 | return; | ||
| 783 | |||
| 784 | kodi::addon::JoystickFeatures::FreeStructs(feature_count, features); | ||
| 785 | } | ||
| 786 | |||
| 787 | inline static PERIPHERAL_ERROR ADDON_MapFeatures(const AddonInstance_Peripheral* addonInstance, | ||
| 788 | const JOYSTICK_INFO* joystick, | ||
| 789 | const char* controller_id, | ||
| 790 | unsigned int feature_count, | ||
| 791 | const JOYSTICK_FEATURE* features) | ||
| 792 | { | ||
| 793 | if (!addonInstance || !joystick || !controller_id || (feature_count > 0 && !features)) | ||
| 794 | return PERIPHERAL_ERROR_INVALID_PARAMETERS; | ||
| 795 | |||
| 796 | kodi::addon::Joystick addonJoystick(*joystick); | ||
| 797 | std::vector<kodi::addon::JoystickFeature> primitiveVector; | ||
| 798 | |||
| 799 | for (unsigned int i = 0; i < feature_count; i++) | ||
| 800 | primitiveVector.emplace_back(*(features + i)); | ||
| 801 | |||
| 802 | return static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance) | ||
| 803 | ->MapFeatures(addonJoystick, controller_id, primitiveVector); | ||
| 804 | } | ||
| 805 | |||
| 806 | inline static PERIPHERAL_ERROR ADDON_GetIgnoredPrimitives( | ||
| 807 | const AddonInstance_Peripheral* addonInstance, | ||
| 808 | const JOYSTICK_INFO* joystick, | ||
| 809 | unsigned int* primitive_count, | ||
| 810 | JOYSTICK_DRIVER_PRIMITIVE** primitives) | ||
| 811 | { | ||
| 812 | if (!addonInstance || !joystick || !primitive_count || !primitives) | ||
| 813 | return PERIPHERAL_ERROR_INVALID_PARAMETERS; | ||
| 814 | |||
| 815 | kodi::addon::Joystick addonJoystick(*joystick); | ||
| 816 | std::vector<kodi::addon::DriverPrimitive> primitiveVector; | ||
| 817 | |||
| 818 | PERIPHERAL_ERROR err = static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance) | ||
| 819 | ->GetIgnoredPrimitives(addonJoystick, primitiveVector); | ||
| 820 | if (err == PERIPHERAL_NO_ERROR) | ||
| 821 | { | ||
| 822 | *primitive_count = static_cast<unsigned int>(primitiveVector.size()); | ||
| 823 | kodi::addon::DriverPrimitives::ToStructs(primitiveVector, primitives); | ||
| 824 | } | ||
| 825 | |||
| 826 | return err; | ||
| 827 | } | ||
| 828 | |||
| 829 | inline static void ADDON_FreePrimitives(const AddonInstance_Peripheral* addonInstance, | ||
| 830 | unsigned int primitive_count, | ||
| 831 | JOYSTICK_DRIVER_PRIMITIVE* primitives) | ||
| 832 | { | ||
| 833 | if (!addonInstance) | ||
| 834 | return; | ||
| 835 | |||
| 836 | kodi::addon::DriverPrimitives::FreeStructs(primitive_count, primitives); | ||
| 837 | } | ||
| 838 | |||
| 839 | inline static PERIPHERAL_ERROR ADDON_SetIgnoredPrimitives( | ||
| 840 | const AddonInstance_Peripheral* addonInstance, | ||
| 841 | const JOYSTICK_INFO* joystick, | ||
| 842 | unsigned int primitive_count, | ||
| 843 | const JOYSTICK_DRIVER_PRIMITIVE* primitives) | ||
| 844 | { | ||
| 845 | if (!addonInstance || !joystick || (primitive_count > 0 && !primitives)) | ||
| 846 | return PERIPHERAL_ERROR_INVALID_PARAMETERS; | ||
| 847 | |||
| 848 | kodi::addon::Joystick addonJoystick(*joystick); | ||
| 849 | std::vector<kodi::addon::DriverPrimitive> primitiveVector; | ||
| 850 | |||
| 851 | for (unsigned int i = 0; i < primitive_count; i++) | ||
| 852 | primitiveVector.emplace_back(*(primitives + i)); | ||
| 853 | |||
| 854 | return static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance) | ||
| 855 | ->SetIgnoredPrimitives(addonJoystick, primitiveVector); | ||
| 856 | } | ||
| 857 | |||
| 858 | inline static void ADDON_SaveButtonMap(const AddonInstance_Peripheral* addonInstance, | ||
| 859 | const JOYSTICK_INFO* joystick) | ||
| 860 | { | ||
| 861 | if (!addonInstance || !joystick) | ||
| 862 | return; | ||
| 863 | |||
| 864 | kodi::addon::Joystick addonJoystick(*joystick); | ||
| 865 | static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance) | ||
| 866 | ->SaveButtonMap(addonJoystick); | ||
| 867 | } | ||
| 868 | |||
| 869 | inline static void ADDON_RevertButtonMap(const AddonInstance_Peripheral* addonInstance, | ||
| 870 | const JOYSTICK_INFO* joystick) | ||
| 871 | { | ||
| 872 | if (!addonInstance || !joystick) | ||
| 873 | return; | ||
| 874 | |||
| 875 | kodi::addon::Joystick addonJoystick(*joystick); | ||
| 876 | static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance) | ||
| 877 | ->RevertButtonMap(addonJoystick); | ||
| 878 | } | ||
| 879 | |||
| 880 | inline static void ADDON_ResetButtonMap(const AddonInstance_Peripheral* addonInstance, | ||
| 881 | const JOYSTICK_INFO* joystick, | ||
| 882 | const char* controller_id) | ||
| 883 | { | ||
| 884 | if (!addonInstance || !joystick || !controller_id) | ||
| 885 | return; | ||
| 886 | |||
| 887 | kodi::addon::Joystick addonJoystick(*joystick); | ||
| 888 | static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance) | ||
| 889 | ->ResetButtonMap(addonJoystick, controller_id); | ||
| 890 | } | ||
| 891 | |||
| 892 | inline static void ADDON_PowerOffJoystick(const AddonInstance_Peripheral* addonInstance, | ||
| 893 | unsigned int index) | ||
| 894 | { | ||
| 895 | if (!addonInstance) | ||
| 896 | return; | ||
| 897 | |||
| 898 | static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance) | ||
| 899 | ->PowerOffJoystick(index); | ||
| 900 | } | ||
| 901 | |||
| 902 | AddonInstance_Peripheral* m_instanceData; | ||
| 903 | }; | ||
| 904 | |||
| 905 | } /* namespace addon */ | ||
| 906 | } /* namespace kodi */ | ||
| 907 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h new file mode 100644 index 0000000..4902fcb --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h | |||
| @@ -0,0 +1,470 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | #include "../c-api/addon-instance/screensaver.h" | ||
| 13 | #include "../gui/renderHelper.h" | ||
| 14 | |||
| 15 | #ifdef __cplusplus | ||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace addon | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================== | ||
| 22 | /// @addtogroup cpp_kodi_addon_screensaver | ||
| 23 | /// @brief \cpp_class{ kodi::addon::CInstanceScreensaver } | ||
| 24 | /// **Screensaver add-on instance** | ||
| 25 | /// | ||
| 26 | /// A screensaver is a Kodi addon that fills the screen with moving images or | ||
| 27 | /// patterns when the computer is not in use. Initially designed to prevent | ||
| 28 | /// phosphor burn-in on CRT and plasma computer monitors (hence the name), | ||
| 29 | /// screensavers are now used primarily for entertainment, security or to | ||
| 30 | /// display system status information. | ||
| 31 | /// | ||
| 32 | /// Include the header @ref Screensaver.h "#include <kodi/addon-instance/ScreenSaver.h>" | ||
| 33 | /// to use this class. | ||
| 34 | /// | ||
| 35 | /// This interface allows the creating of screensavers for Kodi, based upon | ||
| 36 | /// **DirectX** or/and **OpenGL** rendering with `C++` code. | ||
| 37 | /// | ||
| 38 | /// The interface is small and easy usable. It has three functions: | ||
| 39 | /// | ||
| 40 | /// * <b><c>Start()</c></b> - Called on creation | ||
| 41 | /// * <b><c>Render()</c></b> - Called at render time | ||
| 42 | /// * <b><c>Stop()</c></b> - Called when the screensaver has no work | ||
| 43 | /// | ||
| 44 | /// Additionally, there are several \ref cpp_kodi_addon_screensaver_CB "other functions" | ||
| 45 | /// available in which the child class can ask about the current hardware, | ||
| 46 | /// including the device, display and several other parts. | ||
| 47 | /// | ||
| 48 | /// ---------------------------------------------------------------------------- | ||
| 49 | /// | ||
| 50 | /// Here is an example of what the <b>`addon.xml.in`</b> would look like for an | ||
| 51 | /// screensaver addon: | ||
| 52 | /// | ||
| 53 | /// ~~~~~~~~~~~~~{.xml} | ||
| 54 | /// <?xml version="1.0" encoding="UTF-8"?> | ||
| 55 | /// <addon | ||
| 56 | /// id="screensaver.myspecialnamefor" | ||
| 57 | /// version="1.0.0" | ||
| 58 | /// name="My special screensaver addon" | ||
| 59 | /// provider-name="Your Name"> | ||
| 60 | /// <requires>@ADDON_DEPENDS@</requires> | ||
| 61 | /// <extension | ||
| 62 | /// point="xbmc.ui.screensaver" | ||
| 63 | /// library_@PLATFORM@="@LIBRARY_FILENAME@"/> | ||
| 64 | /// <extension point="xbmc.addon.metadata"> | ||
| 65 | /// <summary lang="en_GB">My screensaver addon</summary> | ||
| 66 | /// <description lang="en_GB">My screensaver addon description</description> | ||
| 67 | /// <platform>@PLATFORM@</platform> | ||
| 68 | /// </extension> | ||
| 69 | /// </addon> | ||
| 70 | /// ~~~~~~~~~~~~~ | ||
| 71 | /// | ||
| 72 | /// Description to screensaver related addon.xml values: | ||
| 73 | /// | Name | Description | ||
| 74 | /// |:------------------------------|---------------------------------------- | ||
| 75 | /// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"xbmc.ui.screensaver"</b>. | ||
| 76 | /// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build. | ||
| 77 | /// | ||
| 78 | /// @remark For more detailed description of the <b>`addon.xml`</b>, see also https://kodi.wiki/view/Addon.xml. | ||
| 79 | /// | ||
| 80 | /// | ||
| 81 | /// -------------------------------------------------------------------------- | ||
| 82 | /// | ||
| 83 | /// **Here is an example of the minimum required code to start a screensaver:** | ||
| 84 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 85 | /// #include <kodi/addon-instance/Screensaver.h> | ||
| 86 | /// | ||
| 87 | /// class CMyScreenSaver : public kodi::addon::CAddonBase, | ||
| 88 | /// public kodi::addon::CInstanceScreensaver | ||
| 89 | /// { | ||
| 90 | /// public: | ||
| 91 | /// CMyScreenSaver(); | ||
| 92 | /// | ||
| 93 | /// bool Start() override; | ||
| 94 | /// void Render() override; | ||
| 95 | /// }; | ||
| 96 | /// | ||
| 97 | /// CMyScreenSaver::CMyScreenSaver() | ||
| 98 | /// { | ||
| 99 | /// ... | ||
| 100 | /// } | ||
| 101 | /// | ||
| 102 | /// bool CMyScreenSaver::Start() | ||
| 103 | /// { | ||
| 104 | /// ... | ||
| 105 | /// return true; | ||
| 106 | /// } | ||
| 107 | /// | ||
| 108 | /// void CMyScreenSaver::Render() | ||
| 109 | /// { | ||
| 110 | /// ... | ||
| 111 | /// } | ||
| 112 | /// | ||
| 113 | /// ADDONCREATOR(CMyScreenSaver) | ||
| 114 | /// ~~~~~~~~~~~~~ | ||
| 115 | /// | ||
| 116 | /// | ||
| 117 | /// -------------------------------------------------------------------------- | ||
| 118 | /// | ||
| 119 | /// | ||
| 120 | /// **Here is another example where the screensaver is used together with | ||
| 121 | /// other instance types:** | ||
| 122 | /// | ||
| 123 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 124 | /// #include <kodi/addon-instance/Screensaver.h> | ||
| 125 | /// | ||
| 126 | /// class CMyScreenSaver : public kodi::addon::CInstanceScreensaver | ||
| 127 | /// { | ||
| 128 | /// public: | ||
| 129 | /// CMyScreenSaver(KODI_HANDLE instance, const std::string& version); | ||
| 130 | /// | ||
| 131 | /// bool Start() override; | ||
| 132 | /// void Render() override; | ||
| 133 | /// }; | ||
| 134 | /// | ||
| 135 | /// CMyScreenSaver::CMyScreenSaver(KODI_HANDLE instance, const std::string& version) | ||
| 136 | /// : CInstanceScreensaver(instance, version) | ||
| 137 | /// { | ||
| 138 | /// ... | ||
| 139 | /// } | ||
| 140 | /// | ||
| 141 | /// bool CMyScreenSaver::Start() | ||
| 142 | /// { | ||
| 143 | /// ... | ||
| 144 | /// return true; | ||
| 145 | /// } | ||
| 146 | /// | ||
| 147 | /// void CMyScreenSaver::Render() | ||
| 148 | /// { | ||
| 149 | /// ... | ||
| 150 | /// } | ||
| 151 | /// | ||
| 152 | /// | ||
| 153 | /// //---------------------------------------------------------------------- | ||
| 154 | /// | ||
| 155 | /// class CMyAddon : public kodi::addon::CAddonBase | ||
| 156 | /// { | ||
| 157 | /// public: | ||
| 158 | /// CMyAddon() = default; | ||
| 159 | /// ADDON_STATUS CreateInstance(int instanceType, | ||
| 160 | /// const std::string& instanceID, | ||
| 161 | /// KODI_HANDLE instance, | ||
| 162 | /// const std::string& version, | ||
| 163 | /// KODI_HANDLE& addonInstance) override; | ||
| 164 | /// }; | ||
| 165 | /// | ||
| 166 | /// // If you use only one instance in your add-on, can be instanceType and | ||
| 167 | /// // instanceID ignored | ||
| 168 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 169 | /// const std::string& instanceID, | ||
| 170 | /// KODI_HANDLE instance, | ||
| 171 | /// const std::string& version, | ||
| 172 | /// KODI_HANDLE& addonInstance) | ||
| 173 | /// { | ||
| 174 | /// if (instanceType == ADDON_INSTANCE_SCREENSAVER) | ||
| 175 | /// { | ||
| 176 | /// kodi::Log(ADDON_LOG_INFO, "Creating my Screensaver"); | ||
| 177 | /// addonInstance = new CMyScreenSaver(instance, version); | ||
| 178 | /// return ADDON_STATUS_OK; | ||
| 179 | /// } | ||
| 180 | /// else if (...) | ||
| 181 | /// { | ||
| 182 | /// ... | ||
| 183 | /// } | ||
| 184 | /// return ADDON_STATUS_UNKNOWN; | ||
| 185 | /// } | ||
| 186 | /// | ||
| 187 | /// ADDONCREATOR(CMyAddon) | ||
| 188 | /// ~~~~~~~~~~~~~ | ||
| 189 | /// | ||
| 190 | /// The destruction of the example class `CMyScreenSaver` is called from | ||
| 191 | /// Kodi's header. Manually deleting the add-on instance is not required. | ||
| 192 | /// | ||
| 193 | class ATTRIBUTE_HIDDEN CInstanceScreensaver : public IAddonInstance | ||
| 194 | { | ||
| 195 | public: | ||
| 196 | //============================================================================ | ||
| 197 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 198 | /// @brief Screensaver class constructor. | ||
| 199 | /// | ||
| 200 | /// Used by an add-on that only supports screensavers. | ||
| 201 | /// | ||
| 202 | CInstanceScreensaver() | ||
| 203 | : IAddonInstance(ADDON_INSTANCE_SCREENSAVER, GetKodiTypeVersion(ADDON_INSTANCE_SCREENSAVER)) | ||
| 204 | { | ||
| 205 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 206 | throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation of more as one in single " | ||
| 207 | "instance way is not allowed!"); | ||
| 208 | |||
| 209 | SetAddonStruct(CAddonBase::m_interface->firstKodiInstance); | ||
| 210 | CAddonBase::m_interface->globalSingleInstance = this; | ||
| 211 | } | ||
| 212 | //---------------------------------------------------------------------------- | ||
| 213 | |||
| 214 | //============================================================================ | ||
| 215 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 216 | /// @brief Screensaver class constructor used to support multiple instance | ||
| 217 | /// types. | ||
| 218 | /// | ||
| 219 | /// @param[in] instance The instance value given to | ||
| 220 | /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>. | ||
| 221 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to | ||
| 222 | /// allow compatibility to older Kodi versions. | ||
| 223 | /// | ||
| 224 | /// @note Recommended to set <b>`kodiVersion`</b>. | ||
| 225 | /// | ||
| 226 | /// | ||
| 227 | /// -------------------------------------------------------------------------- | ||
| 228 | /// | ||
| 229 | /// **Here's example about the use of this:** | ||
| 230 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 231 | /// class CMyScreenSaver : public kodi::addon::CInstanceScreensaver | ||
| 232 | /// { | ||
| 233 | /// public: | ||
| 234 | /// CMyScreenSaver(KODI_HANDLE instance, const std::string& kodiVersion) | ||
| 235 | /// : kodi::addon::CInstanceScreensaver(instance, kodiVersion) | ||
| 236 | /// { | ||
| 237 | /// ... | ||
| 238 | /// } | ||
| 239 | /// | ||
| 240 | /// ... | ||
| 241 | /// }; | ||
| 242 | /// | ||
| 243 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 244 | /// const std::string& instanceID, | ||
| 245 | /// KODI_HANDLE instance, | ||
| 246 | /// const std::string& version, | ||
| 247 | /// KODI_HANDLE& addonInstance) | ||
| 248 | /// { | ||
| 249 | /// kodi::Log(ADDON_LOG_INFO, "Creating my screensaver"); | ||
| 250 | /// addonInstance = new CMyScreenSaver(instance, version); | ||
| 251 | /// return ADDON_STATUS_OK; | ||
| 252 | /// } | ||
| 253 | /// ~~~~~~~~~~~~~ | ||
| 254 | /// | ||
| 255 | explicit CInstanceScreensaver(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 256 | : IAddonInstance(ADDON_INSTANCE_SCREENSAVER, | ||
| 257 | !kodiVersion.empty() ? kodiVersion | ||
| 258 | : GetKodiTypeVersion(ADDON_INSTANCE_SCREENSAVER)) | ||
| 259 | { | ||
| 260 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 261 | throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation of multiple together " | ||
| 262 | "with single instance way is not allowed!"); | ||
| 263 | |||
| 264 | SetAddonStruct(instance); | ||
| 265 | } | ||
| 266 | //---------------------------------------------------------------------------- | ||
| 267 | |||
| 268 | //============================================================================ | ||
| 269 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 270 | /// @brief Destructor. | ||
| 271 | /// | ||
| 272 | ~CInstanceScreensaver() override = default; | ||
| 273 | //---------------------------------------------------------------------------- | ||
| 274 | |||
| 275 | //============================================================================ | ||
| 276 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 277 | /// @brief Used to notify the screensaver that it has been started. | ||
| 278 | /// | ||
| 279 | /// @return true if the screensaver was started successfully, false otherwise | ||
| 280 | /// | ||
| 281 | virtual bool Start() { return true; } | ||
| 282 | //---------------------------------------------------------------------------- | ||
| 283 | |||
| 284 | //============================================================================ | ||
| 285 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 286 | /// @brief Used to inform the screensaver that the rendering control was | ||
| 287 | /// stopped. | ||
| 288 | /// | ||
| 289 | virtual void Stop() {} | ||
| 290 | //---------------------------------------------------------------------------- | ||
| 291 | |||
| 292 | //============================================================================ | ||
| 293 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 294 | /// @brief Used to indicate when the add-on should render | ||
| 295 | /// | ||
| 296 | virtual void Render() {} | ||
| 297 | //---------------------------------------------------------------------------- | ||
| 298 | |||
| 299 | //============================================================================ | ||
| 300 | /// @defgroup cpp_kodi_addon_screensaver_CB Information functions | ||
| 301 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 302 | /// @brief **To get info about the device, display and several other parts** | ||
| 303 | /// | ||
| 304 | ///@{ | ||
| 305 | |||
| 306 | //============================================================================ | ||
| 307 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 308 | /// @brief Device that represents the display adapter. | ||
| 309 | /// | ||
| 310 | /// @return A pointer to the device | ||
| 311 | /// | ||
| 312 | /// @note This is only available on **DirectX**, It us unused (`nullptr`) on | ||
| 313 | /// **OpenGL** | ||
| 314 | /// | ||
| 315 | /// This value can also be becomed by @ref kodi::gui::GetHWContext() and is | ||
| 316 | /// recommended to use. | ||
| 317 | /// | ||
| 318 | ///------------------------------------------------------------------------- | ||
| 319 | /// | ||
| 320 | /// **Example:** | ||
| 321 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 322 | /// #include <d3d11_1.h> | ||
| 323 | /// .. | ||
| 324 | /// // Note: Device() there is used inside addon child class about | ||
| 325 | /// // kodi::addon::CInstanceVisualization | ||
| 326 | /// ID3D11DeviceContext1* context = static_cast<ID3D11DeviceContext1*>(kodi::addon::CInstanceVisualization::Device()); | ||
| 327 | /// .. | ||
| 328 | /// ~~~~~~~~~~~~~ | ||
| 329 | /// | ||
| 330 | inline kodi::HardwareContext Device() { return m_instanceData->props->device; } | ||
| 331 | //---------------------------------------------------------------------------- | ||
| 332 | |||
| 333 | //============================================================================ | ||
| 334 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 335 | /// @brief Returns the X position of the rendering window. | ||
| 336 | /// | ||
| 337 | /// @return The X position, in pixels | ||
| 338 | /// | ||
| 339 | inline int X() { return m_instanceData->props->x; } | ||
| 340 | //---------------------------------------------------------------------------- | ||
| 341 | |||
| 342 | //============================================================================ | ||
| 343 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 344 | /// @brief Returns the Y position of the rendering window. | ||
| 345 | /// | ||
| 346 | /// @return The Y position, in pixels | ||
| 347 | /// | ||
| 348 | inline int Y() { return m_instanceData->props->y; } | ||
| 349 | //---------------------------------------------------------------------------- | ||
| 350 | |||
| 351 | //============================================================================ | ||
| 352 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 353 | /// @brief Returns the width of the rendering window. | ||
| 354 | /// | ||
| 355 | /// @return The width, in pixels | ||
| 356 | /// | ||
| 357 | inline int Width() { return m_instanceData->props->width; } | ||
| 358 | //---------------------------------------------------------------------------- | ||
| 359 | |||
| 360 | //============================================================================ | ||
| 361 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 362 | /// @brief Returns the height of the rendering window. | ||
| 363 | /// | ||
| 364 | /// @return The height, in pixels | ||
| 365 | /// | ||
| 366 | inline int Height() { return m_instanceData->props->height; } | ||
| 367 | //---------------------------------------------------------------------------- | ||
| 368 | |||
| 369 | //============================================================================ | ||
| 370 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 371 | /// @brief Pixel aspect ratio (often abbreviated PAR) is a ratio that | ||
| 372 | /// describes how the width of a pixel compares to the height of that pixel. | ||
| 373 | /// | ||
| 374 | /// @return The pixel aspect ratio used by the display | ||
| 375 | /// | ||
| 376 | inline float PixelRatio() { return m_instanceData->props->pixelRatio; } | ||
| 377 | //---------------------------------------------------------------------------- | ||
| 378 | |||
| 379 | //============================================================================ | ||
| 380 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 381 | /// @brief Used to get the name of the add-on defined in `addon.xml`. | ||
| 382 | /// | ||
| 383 | /// @return The add-on name | ||
| 384 | /// | ||
| 385 | inline std::string Name() { return m_instanceData->props->name; } | ||
| 386 | //---------------------------------------------------------------------------- | ||
| 387 | |||
| 388 | //============================================================================ | ||
| 389 | /// | ||
| 390 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 391 | /// @brief Used to get the full path where the add-on is installed. | ||
| 392 | /// | ||
| 393 | /// @return The add-on installation path | ||
| 394 | /// | ||
| 395 | inline std::string Presets() { return m_instanceData->props->presets; } | ||
| 396 | //---------------------------------------------------------------------------- | ||
| 397 | |||
| 398 | //============================================================================ | ||
| 399 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 400 | /// @brief Used to get the full path to the add-on's user profile. | ||
| 401 | /// | ||
| 402 | /// @note The trailing folder (consisting of the add-on's ID) is not created | ||
| 403 | /// by default. If it is needed, you must call kodi::vfs::CreateDirectory() | ||
| 404 | /// to create the folder. | ||
| 405 | /// | ||
| 406 | /// @return Path to the user profile | ||
| 407 | /// | ||
| 408 | inline std::string Profile() { return m_instanceData->props->profile; } | ||
| 409 | //---------------------------------------------------------------------------- | ||
| 410 | |||
| 411 | ///@} | ||
| 412 | |||
| 413 | private: | ||
| 414 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 415 | { | ||
| 416 | if (instance == nullptr) | ||
| 417 | throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation with empty addon " | ||
| 418 | "structure not allowed, table must be given from Kodi!"); | ||
| 419 | |||
| 420 | m_instanceData = static_cast<AddonInstance_Screensaver*>(instance); | ||
| 421 | m_instanceData->toAddon->addonInstance = this; | ||
| 422 | m_instanceData->toAddon->Start = ADDON_Start; | ||
| 423 | m_instanceData->toAddon->Stop = ADDON_Stop; | ||
| 424 | m_instanceData->toAddon->Render = ADDON_Render; | ||
| 425 | } | ||
| 426 | |||
| 427 | inline static bool ADDON_Start(AddonInstance_Screensaver* instance) | ||
| 428 | { | ||
| 429 | CInstanceScreensaver* thisClass = | ||
| 430 | static_cast<CInstanceScreensaver*>(instance->toAddon->addonInstance); | ||
| 431 | thisClass->m_renderHelper = kodi::gui::GetRenderHelper(); | ||
| 432 | return thisClass->Start(); | ||
| 433 | } | ||
| 434 | |||
| 435 | inline static void ADDON_Stop(AddonInstance_Screensaver* instance) | ||
| 436 | { | ||
| 437 | CInstanceScreensaver* thisClass = | ||
| 438 | static_cast<CInstanceScreensaver*>(instance->toAddon->addonInstance); | ||
| 439 | thisClass->Stop(); | ||
| 440 | thisClass->m_renderHelper = nullptr; | ||
| 441 | } | ||
| 442 | |||
| 443 | inline static void ADDON_Render(AddonInstance_Screensaver* instance) | ||
| 444 | { | ||
| 445 | CInstanceScreensaver* thisClass = | ||
| 446 | static_cast<CInstanceScreensaver*>(instance->toAddon->addonInstance); | ||
| 447 | |||
| 448 | if (!thisClass->m_renderHelper) | ||
| 449 | return; | ||
| 450 | thisClass->m_renderHelper->Begin(); | ||
| 451 | thisClass->Render(); | ||
| 452 | thisClass->m_renderHelper->End(); | ||
| 453 | } | ||
| 454 | |||
| 455 | /* | ||
| 456 | * Background render helper holds here and in addon base. | ||
| 457 | * In addon base also to have for the others, and stored here for the worst | ||
| 458 | * case where this class is independent from base and base becomes closed | ||
| 459 | * before. | ||
| 460 | * | ||
| 461 | * This is on Kodi with GL unused and the calls to there are empty (no work) | ||
| 462 | * On Kodi with Direct X where angle is present becomes this used. | ||
| 463 | */ | ||
| 464 | std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper; | ||
| 465 | AddonInstance_Screensaver* m_instanceData; | ||
| 466 | }; | ||
| 467 | |||
| 468 | } /* namespace addon */ | ||
| 469 | } /* namespace kodi */ | ||
| 470 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h index efd5de2..177bf72 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h | |||
| @@ -9,260 +9,146 @@ | |||
| 9 | 9 | ||
| 10 | #include "../AddonBase.h" | 10 | #include "../AddonBase.h" |
| 11 | #include "../Filesystem.h" | 11 | #include "../Filesystem.h" |
| 12 | 12 | #include "../c-api/addon-instance/vfs.h" | |
| 13 | #if !defined(_WIN32) | ||
| 14 | #include <sys/stat.h> | ||
| 15 | #if !defined(__stat64) | ||
| 16 | #if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) | ||
| 17 | #define __stat64 stat | ||
| 18 | #else | ||
| 19 | #define __stat64 stat64 | ||
| 20 | #endif | ||
| 21 | #endif | ||
| 22 | #endif | ||
| 23 | 13 | ||
| 24 | #ifdef __cplusplus | 14 | #ifdef __cplusplus |
| 25 | extern "C" | ||
| 26 | { | ||
| 27 | #endif /* __cplusplus */ | ||
| 28 | |||
| 29 | //============================================================================ | ||
| 30 | /// @ingroup cpp_kodi_addon_vfs_Defs | ||
| 31 | /// @brief **VFS add-on URL data**\n | ||
| 32 | /// This class is used to inform the addon of the desired wanted connection. | ||
| 33 | /// | ||
| 34 | /// Used on mostly all addon functions to identify related target. | ||
| 35 | /// | ||
| 36 | struct VFSURL | ||
| 37 | { | ||
| 38 | /// @brief Desired URL of the file system to be edited | ||
| 39 | /// | ||
| 40 | /// This includes all available parts of the access and is structured as | ||
| 41 | /// follows: | ||
| 42 | /// - <b>`<PROTOCOL>`://`<USERNAME>`:`<PASSWORD>``@``<HOSTNAME>`:`<PORT>`/`<FILENAME>`?`<OPTIONS>`</b> | ||
| 43 | const char* url; | ||
| 44 | |||
| 45 | /// @brief The associated domain name, which is optional and not available | ||
| 46 | /// in all cases. | ||
| 47 | const char* domain; | ||
| 48 | |||
| 49 | /// @brief This includes the network address (e.g. `192.168.0.123`) or if | ||
| 50 | /// the addon refers to file packages the path to it | ||
| 51 | /// (e.g. `/home/by_me/MyPacket.rar`). | ||
| 52 | const char* hostname; | ||
| 53 | |||
| 54 | /// @brief With this variable the desired path to a folder or file within | ||
| 55 | /// the hostname is given (e.g. `storage/videos/00001.ts`). | ||
| 56 | const char* filename; | ||
| 57 | |||
| 58 | /// @brief [Networking port](https://en.wikipedia.org/wiki/Port_(computer_networking)) | ||
| 59 | /// to use for protocol. | ||
| 60 | unsigned int port; | ||
| 61 | |||
| 62 | /// @brief Special options on opened URL, this can e.g. on RAR packages | ||
| 63 | /// <b>`?flags=8&nextvalue=123`</b> to inform about to not cache a read. | ||
| 64 | /// | ||
| 65 | /// Available options from Kodi: | ||
| 66 | /// | Value: | Description: | ||
| 67 | /// |-----------|------------------- | ||
| 68 | /// | flags=8 | Used on RAR packages so that no data is cached from the requested source. | ||
| 69 | /// | cache=no | Used on ZIP packages so that no data from the requested source is stored in the cache. However, this is currently not available from addons! | ||
| 70 | /// | ||
| 71 | /// In addition, other addons can use the URLs given by them to give options | ||
| 72 | /// that fit the respective VFS addon and allow special operations. | ||
| 73 | /// | ||
| 74 | /// @note This procedure is not yet standardized and is currently not | ||
| 75 | /// exactly available which are handed over. | ||
| 76 | const char* options; | ||
| 77 | |||
| 78 | /// @brief Desired username. | ||
| 79 | const char* username; | ||
| 80 | 15 | ||
| 81 | /// @brief Desired password. | 16 | namespace kodi |
| 82 | const char* password; | 17 | { |
| 83 | 18 | namespace addon | |
| 84 | /// @brief The complete URL is passed on here, but the user name and | 19 | { |
| 85 | /// password are not shown and only appear to there as `USERNAME:PASSWORD`. | ||
| 86 | /// | ||
| 87 | /// As example <b>`sftp://USERNAME:PASSWORD@192.168.178.123/storage/videos/00001.ts`</b>. | ||
| 88 | const char* redacted; | ||
| 89 | |||
| 90 | /// @brief The name which is taken as the basis by source and would be first | ||
| 91 | /// in folder view. | ||
| 92 | /// | ||
| 93 | /// As example on <b>`sftp://dudu:isprivate@192.168.178.123/storage/videos/00001.ts`</b> | ||
| 94 | /// becomes then <b>`storage`</b> used here. | ||
| 95 | const char* sharename; | ||
| 96 | 20 | ||
| 97 | /// @brief Protocol name used on this stream, e.g. <b>`sftp`</b>. | 21 | class CInstanceVFS; |
| 98 | const char* protocol; | ||
| 99 | }; | ||
| 100 | //---------------------------------------------------------------------------- | ||
| 101 | 22 | ||
| 102 | //============================================================================ | 23 | //============================================================================== |
| 103 | /// @ingroup cpp_kodi_addon_vfs_Defs | 24 | /// @ingroup cpp_kodi_addon_vfs_Defs |
| 104 | /// @brief <b>In/out value which is queried at @ref kodi::addon::CInstanceVFS::IoControl.</b>\n | 25 | /// @brief **VFS add-on file handle**\n |
| 105 | /// This declares the requested value on the addon, this gets or has to | 26 | /// This used to handle opened files of addon with related memory pointer about |
| 106 | /// transfer data depending on the value. | 27 | /// class or structure and to have on further file control functions available. |
| 107 | enum VFS_IOCTRL | 28 | /// |
| 108 | { | 29 | /// See @ref cpp_kodi_addon_vfs_filecontrol "file editing functions" for used |
| 109 | /// @brief For cases where not supported control becomes asked. | 30 | /// places. |
| 110 | /// | 31 | /// |
| 111 | /// @note Should normally not given to addon. | 32 | ///@{ |
| 112 | VFS_IOCTRL_INVALID = 0, | 33 | using VFSFileHandle = VFS_FILE_HANDLE; |
| 34 | ///@} | ||
| 35 | //------------------------------------------------------------------------------ | ||
| 113 | 36 | ||
| 114 | /// @brief @ref VFS_IOCTRL_NATIVE_DATA structure, containing what should be | 37 | //============================================================================== |
| 115 | /// passed to native ioctrl. | 38 | /// @defgroup cpp_kodi_addon_vfs_Defs_VFSUrl class VFSUrl |
| 116 | VFS_IOCTRL_NATIVE = 1, | 39 | /// @ingroup cpp_kodi_addon_vfs_Defs |
| 40 | /// @brief **VFS add-on URL data**\n | ||
| 41 | /// This class is used to inform the addon of the desired wanted connection. | ||
| 42 | /// | ||
| 43 | /// Used on mostly all addon functions to identify related target. | ||
| 44 | /// | ||
| 45 | /// ---------------------------------------------------------------------------- | ||
| 46 | /// | ||
| 47 | /// @copydetails cpp_kodi_addon_vfs_Defs_VFSUrl_Help | ||
| 48 | /// | ||
| 49 | ///@{ | ||
| 50 | class ATTRIBUTE_HIDDEN VFSUrl : public CStructHdl<VFSUrl, VFSURL> | ||
| 51 | { | ||
| 52 | /*! \cond PRIVATE */ | ||
| 53 | friend class CInstanceVFS; | ||
| 54 | /*! \endcond */ | ||
| 117 | 55 | ||
| 118 | /// @brief To check seek is possible. | 56 | public: |
| 119 | /// | 57 | /// @defgroup cpp_kodi_addon_vfs_Defs_VFSUrl_Help Value Help |
| 120 | //// Return 0 if known not to work, 1 if it should work on related calls. | 58 | /// @ingroup cpp_kodi_addon_vfs_Defs_VFSUrl |
| 121 | VFS_IOCTRL_SEEK_POSSIBLE = 2, | 59 | /// |
| 60 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_vfs_Defs_VFSUrl :</b> | ||
| 61 | /// | Name | Type | Get call | ||
| 62 | /// |------|------|---------- | ||
| 63 | /// | **URL** | `std::string` | @ref VFSUrl::GetURL "GetURL" | ||
| 64 | /// | **Domain name** | `std::string` | @ref VFSUrl::GetDomain "GetDomain" | ||
| 65 | /// | **Hostname** | `std::string` | @ref VFSUrl::GetHostname "GetHostname" | ||
| 66 | /// | **Filename** | `std::string` | @ref VFSUrl::GetFilename "GetFilename" | ||
| 67 | /// | **Network port** | `unsigned int` | @ref VFSUrl::GetPort "GetPort" | ||
| 68 | /// | **Special options** | `std::string` | @ref VFSUrl::GetOptions "GetOptions" | ||
| 69 | /// | **Username** | `std::string` | @ref VFSUrl::GetUsername "GetUsername" | ||
| 70 | /// | **Password** | `std::string` | @ref VFSUrl::GetPassword "GetPassword" | ||
| 71 | /// | **Get URL with user and password hidden** | `std::string` | @ref VFSUrl::GetRedacted "GetRedacted" | ||
| 72 | /// | **Sharename** | `std::string` | @ref VFSUrl::GetSharename "GetSharename" | ||
| 73 | /// | **Network protocol** | `std::string` | @ref VFSUrl::GetProtocol "GetProtocol" | ||
| 74 | /// | ||
| 122 | 75 | ||
| 123 | /// @brief @ref VFS_IOCTRL_CACHE_STATUS_DATA structure structure on related call | 76 | /// @addtogroup cpp_kodi_addon_vfs_Defs_VFSUrl |
| 124 | VFS_IOCTRL_CACHE_STATUS = 3, | 77 | ///@{ |
| 125 | 78 | ||
| 126 | /// @brief Unsigned int with speed limit for caching in bytes per second | 79 | /// @brief Desired URL of the file system to be edited |
| 127 | VFS_IOCTRL_CACHE_SETRATE = 4, | 80 | /// |
| 81 | /// This includes all available parts of the access and is structured as | ||
| 82 | /// follows: | ||
| 83 | /// - | ||
| 84 | /// <b>`<PROTOCOL>`://`<USERNAME>`:`<PASSWORD>``@``<HOSTNAME>`:`<PORT>`/`<FILENAME>`?`<OPTIONS>`</b> | ||
| 85 | std::string GetURL() const { return m_cStructure->url; } | ||
| 128 | 86 | ||
| 129 | /// @brief Enable/disable retry within the protocol handler (if supported) | 87 | /// @brief The associated domain name, which is optional and not available |
| 130 | VFS_IOCTRL_SET_RETRY = 16, | 88 | /// in all cases. |
| 131 | }; | 89 | std::string GetDomain() const { return m_cStructure->domain; } |
| 132 | //---------------------------------------------------------------------------- | ||
| 133 | 90 | ||
| 134 | //============================================================================ | 91 | /// @brief This includes the network address (e.g. `192.168.0.123`) or if |
| 135 | /// @ingroup cpp_kodi_addon_vfs_Defs | 92 | /// the addon refers to file packages the path to it |
| 136 | /// @brief <b>Structure used in @ref kodi::addon::CInstanceVFS::IoControl | 93 | /// (e.g. `/home/by_me/MyPacket.rar`). |
| 137 | /// if question value for @ref VFS_IOCTRL_NATIVE is set</b>\n | 94 | std::string GetHostname() const { return m_cStructure->hostname; } |
| 138 | /// With this structure, data is transmitted to the Kodi addon. | ||
| 139 | /// | ||
| 140 | /// This corresponds to POSIX systems with regard to [ioctl](https://en.wikipedia.org/wiki/Ioctl) | ||
| 141 | /// data (emulated with Windows). | ||
| 142 | struct VFS_IOCTRL_NATIVE_DATA | ||
| 143 | { | ||
| 144 | unsigned long int request; | ||
| 145 | void* param; | ||
| 146 | }; | ||
| 147 | //---------------------------------------------------------------------------- | ||
| 148 | 95 | ||
| 149 | //============================================================================ | 96 | /// @brief With this variable the desired path to a folder or file within |
| 150 | /// @ingroup cpp_kodi_addon_vfs_Defs | 97 | /// the hostname is given (e.g. `storage/videos/00001.ts`). |
| 151 | /// @brief <b>Structure used in @ref kodi::addon::CInstanceVFS::IoControl | 98 | std::string GetFilename() const { return m_cStructure->filename; } |
| 152 | /// if question value for @ref VFS_IOCTRL_CACHE_STATUS is set</b>\n | ||
| 153 | /// This data is filled by the addon and returned to Kodi | ||
| 154 | struct VFS_IOCTRL_CACHE_STATUS_DATA | ||
| 155 | { | ||
| 156 | /// @brief Number of bytes cached forward of current position. | ||
| 157 | uint64_t forward; | ||
| 158 | 99 | ||
| 159 | /// @brief Maximum number of bytes per second cache is allowed to fill. | 100 | /// @brief [Networking port](https://en.wikipedia.org/wiki/Port_(computer_networking)) |
| 160 | unsigned int maxrate; | 101 | /// to use for protocol. |
| 102 | unsigned int GetPort() const { return m_cStructure->port; } | ||
| 161 | 103 | ||
| 162 | /// @brief Average read rate from source file since last position change. | 104 | /// @brief Special options on opened URL, this can e.g. on RAR packages |
| 163 | unsigned int currate; | 105 | /// <b>`?flags=8&nextvalue=123`</b> to inform about to not cache a read. |
| 106 | /// | ||
| 107 | /// Available options from Kodi: | ||
| 108 | /// | Value: | Description: | ||
| 109 | /// |-----------|------------------- | ||
| 110 | /// | flags=8 | Used on RAR packages so that no data is cached from the requested source. | ||
| 111 | /// | cache=no | Used on ZIP packages so that no data from the requested source is stored in the cache. However, this is currently not available from addons! | ||
| 112 | /// | ||
| 113 | /// In addition, other addons can use the URLs given by them to give options | ||
| 114 | /// that fit the respective VFS addon and allow special operations. | ||
| 115 | /// | ||
| 116 | /// @note This procedure is not yet standardized and is currently not | ||
| 117 | /// exactly available which are handed over. | ||
| 118 | std::string GetOptions() const { return m_cStructure->options; } | ||
| 164 | 119 | ||
| 165 | /// @brief Cache low speed condition detected? | 120 | /// @brief Desired username. |
| 166 | bool lowspeed; | 121 | std::string GetUsername() const { return m_cStructure->username; } |
| 167 | }; | ||
| 168 | //---------------------------------------------------------------------------- | ||
| 169 | 122 | ||
| 170 | typedef struct VFSGetDirectoryCallbacks /* internal */ | 123 | /// @brief Desired password. |
| 171 | { | 124 | std::string GetPassword() const { return m_cStructure->password; } |
| 172 | bool (__cdecl* get_keyboard_input)(void* ctx, const char* heading, char** input, bool hidden_input); | ||
| 173 | void (__cdecl* set_error_dialog)(void* ctx, const char* heading, const char* line1, const char* line2, const char* line3); | ||
| 174 | void (__cdecl* require_authentication)(void* ctx, const char* url); | ||
| 175 | void* ctx; | ||
| 176 | } VFSGetDirectoryCallbacks; | ||
| 177 | 125 | ||
| 178 | typedef struct AddonProps_VFSEntry /* internal */ | 126 | /// @brief The complete URL is passed on here, but the user name and |
| 179 | { | 127 | /// password are not shown and only appear to there as `USERNAME:PASSWORD`. |
| 180 | int dummy; | 128 | /// |
| 181 | } AddonProps_VFSEntry; | 129 | /// As example <b>`sftp://USERNAME:PASSWORD@192.168.178.123/storage/videos/00001.ts`</b>. |
| 130 | std::string GetRedacted() const { return m_cStructure->redacted; } | ||
| 182 | 131 | ||
| 183 | typedef struct AddonToKodiFuncTable_VFSEntry /* internal */ | 132 | /// @brief The name which is taken as the basis by source and would be first |
| 184 | { | 133 | /// in folder view. |
| 185 | KODI_HANDLE kodiInstance; | 134 | /// |
| 186 | } AddonToKodiFuncTable_VFSEntry; | 135 | /// As example on <b>`sftp://dudu:isprivate@192.168.178.123/storage/videos/00001.ts`</b> |
| 136 | /// becomes then <b>`storage`</b> used here. | ||
| 137 | std::string GetSharename() const { return m_cStructure->sharename; } | ||
| 187 | 138 | ||
| 188 | struct AddonInstance_VFSEntry; | 139 | /// @brief Protocol name used on this stream, e.g. <b>`sftp`</b>. |
| 189 | typedef struct KodiToAddonFuncTable_VFSEntry /* internal */ | 140 | std::string GetProtocol() const { return m_cStructure->protocol; } |
| 190 | { | ||
| 191 | KODI_HANDLE addonInstance; | ||
| 192 | |||
| 193 | void*(__cdecl* open)(const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url); | ||
| 194 | void*(__cdecl* open_for_write)(const struct AddonInstance_VFSEntry* instance, | ||
| 195 | const struct VFSURL* url, | ||
| 196 | bool overwrite); | ||
| 197 | ssize_t(__cdecl* read)(const struct AddonInstance_VFSEntry* instance, | ||
| 198 | void* context, | ||
| 199 | void* buffer, | ||
| 200 | size_t buf_size); | ||
| 201 | ssize_t(__cdecl* write)(const struct AddonInstance_VFSEntry* instance, | ||
| 202 | void* context, | ||
| 203 | const void* buffer, | ||
| 204 | size_t buf_size); | ||
| 205 | int64_t(__cdecl* seek)(const struct AddonInstance_VFSEntry* instance, | ||
| 206 | void* context, | ||
| 207 | int64_t position, | ||
| 208 | int whence); | ||
| 209 | int(__cdecl* truncate)(const struct AddonInstance_VFSEntry* instance, | ||
| 210 | void* context, | ||
| 211 | int64_t size); | ||
| 212 | int64_t(__cdecl* get_length)(const struct AddonInstance_VFSEntry* instance, void* context); | ||
| 213 | int64_t(__cdecl* get_position)(const struct AddonInstance_VFSEntry* instance, void* context); | ||
| 214 | int(__cdecl* get_chunk_size)(const struct AddonInstance_VFSEntry* instance, void* context); | ||
| 215 | int(__cdecl* io_control)(const struct AddonInstance_VFSEntry* instance, | ||
| 216 | void* context, | ||
| 217 | enum VFS_IOCTRL request, | ||
| 218 | void* param); | ||
| 219 | int(__cdecl* stat)(const struct AddonInstance_VFSEntry* instance, | ||
| 220 | const struct VFSURL* url, | ||
| 221 | struct __stat64* buffer); | ||
| 222 | bool(__cdecl* close)(const struct AddonInstance_VFSEntry* instance, void* context); | ||
| 223 | bool(__cdecl* exists)(const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url); | ||
| 224 | void(__cdecl* clear_out_idle)(const struct AddonInstance_VFSEntry* instance); | ||
| 225 | void(__cdecl* disconnect_all)(const struct AddonInstance_VFSEntry* instance); | ||
| 226 | bool(__cdecl* delete_it)(const struct AddonInstance_VFSEntry* instance, | ||
| 227 | const struct VFSURL* url); | ||
| 228 | bool(__cdecl* rename)(const struct AddonInstance_VFSEntry* instance, | ||
| 229 | const struct VFSURL* url, | ||
| 230 | const struct VFSURL* url2); | ||
| 231 | bool(__cdecl* directory_exists)(const struct AddonInstance_VFSEntry* instance, | ||
| 232 | const struct VFSURL* url); | ||
| 233 | bool(__cdecl* remove_directory)(const struct AddonInstance_VFSEntry* instance, | ||
| 234 | const struct VFSURL* url); | ||
| 235 | bool(__cdecl* create_directory)(const struct AddonInstance_VFSEntry* instance, | ||
| 236 | const struct VFSURL* url); | ||
| 237 | bool(__cdecl* get_directory)(const struct AddonInstance_VFSEntry* instance, | ||
| 238 | const struct VFSURL* url, | ||
| 239 | struct VFSDirEntry** entries, | ||
| 240 | int* num_entries, | ||
| 241 | VFSGetDirectoryCallbacks* callbacks); | ||
| 242 | bool(__cdecl* contains_files)(const struct AddonInstance_VFSEntry* instance, | ||
| 243 | const struct VFSURL* url, | ||
| 244 | struct VFSDirEntry** entries, | ||
| 245 | int* num_entries, | ||
| 246 | char* rootpath); | ||
| 247 | void(__cdecl* free_directory)(const struct AddonInstance_VFSEntry* instance, | ||
| 248 | struct VFSDirEntry* entries, | ||
| 249 | int num_entries); | ||
| 250 | } KodiToAddonFuncTable_VFSEntry; | ||
| 251 | |||
| 252 | typedef struct AddonInstance_VFSEntry /* internal */ | ||
| 253 | { | ||
| 254 | AddonProps_VFSEntry* props; | ||
| 255 | AddonToKodiFuncTable_VFSEntry* toKodi; | ||
| 256 | KodiToAddonFuncTable_VFSEntry* toAddon; | ||
| 257 | } AddonInstance_VFSEntry; | ||
| 258 | 141 | ||
| 259 | #ifdef __cplusplus | 142 | ///@} |
| 260 | } /* extern "C" */ | ||
| 261 | 143 | ||
| 262 | namespace kodi | 144 | private: |
| 263 | { | 145 | VFSUrl() = delete; |
| 264 | namespace addon | 146 | VFSUrl(const VFSUrl& channel) = delete; |
| 265 | { | 147 | VFSUrl(const VFSURL* channel) : CStructHdl(channel) {} |
| 148 | VFSUrl(VFSURL* channel) : CStructHdl(channel) {} | ||
| 149 | }; | ||
| 150 | ///@} | ||
| 151 | //------------------------------------------------------------------------------ | ||
| 266 | 152 | ||
| 267 | //############################################################################## | 153 | //############################################################################## |
| 268 | /// @defgroup cpp_kodi_addon_vfs_Defs Definitions, structures and enumerators | 154 | /// @defgroup cpp_kodi_addon_vfs_Defs Definitions, structures and enumerators |
| @@ -499,14 +385,14 @@ namespace addon | |||
| 499 | /// }; | 385 | /// }; |
| 500 | /// | 386 | /// |
| 501 | /// CMyVFS::CMyVFS(KODI_HANDLE instance, const std::string& kodiVersion) | 387 | /// CMyVFS::CMyVFS(KODI_HANDLE instance, const std::string& kodiVersion) |
| 502 | /// : CInstanceVFS(instance, kodiVersion) | 388 | /// : kodi::addon::CInstanceVFS(instance, kodiVersion) |
| 503 | /// { | 389 | /// { |
| 504 | /// ... | 390 | /// ... |
| 505 | /// } | 391 | /// } |
| 506 | /// | 392 | /// |
| 507 | /// ... | 393 | /// ... |
| 508 | /// | 394 | /// |
| 509 | /// /*----------------------------------------------------------------------*/ | 395 | /// //---------------------------------------------------------------------- |
| 510 | /// | 396 | /// |
| 511 | /// class CMyAddon : public kodi::addon::CAddonBase | 397 | /// class CMyAddon : public kodi::addon::CAddonBase |
| 512 | /// { | 398 | /// { |
| @@ -529,7 +415,7 @@ namespace addon | |||
| 529 | /// { | 415 | /// { |
| 530 | /// if (instanceType == ADDON_INSTANCE_VFS) | 416 | /// if (instanceType == ADDON_INSTANCE_VFS) |
| 531 | /// { | 417 | /// { |
| 532 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my VFS instance"); | 418 | /// kodi::Log(ADDON_LOG_INFO, "Creating my VFS instance"); |
| 533 | /// addonInstance = new CMyVFS(instance, version); | 419 | /// addonInstance = new CMyVFS(instance, version); |
| 534 | /// return ADDON_STATUS_OK; | 420 | /// return ADDON_STATUS_OK; |
| 535 | /// } | 421 | /// } |
| @@ -546,12 +432,11 @@ namespace addon | |||
| 546 | /// The destruction of the example class `CMyVFS` is called from | 432 | /// The destruction of the example class `CMyVFS` is called from |
| 547 | /// Kodi's header. Manually deleting the add-on instance is not required. | 433 | /// Kodi's header. Manually deleting the add-on instance is not required. |
| 548 | /// | 434 | /// |
| 549 | //---------------------------------------------------------------------------- | 435 | //------------------------------------------------------------------------------ |
| 550 | class ATTRIBUTE_HIDDEN CInstanceVFS : public IAddonInstance | 436 | class ATTRIBUTE_HIDDEN CInstanceVFS : public IAddonInstance |
| 551 | { | 437 | { |
| 552 | public: | 438 | public: |
| 553 | //========================================================================== | 439 | //============================================================================ |
| 554 | /// | ||
| 555 | /// @ingroup cpp_kodi_addon_vfs | 440 | /// @ingroup cpp_kodi_addon_vfs |
| 556 | /// @brief VFS class constructor used to support multiple instance | 441 | /// @brief VFS class constructor used to support multiple instance |
| 557 | /// types | 442 | /// types |
| @@ -577,18 +462,16 @@ public: | |||
| 577 | 462 | ||
| 578 | SetAddonStruct(instance); | 463 | SetAddonStruct(instance); |
| 579 | } | 464 | } |
| 580 | //-------------------------------------------------------------------------- | 465 | //---------------------------------------------------------------------------- |
| 581 | 466 | ||
| 582 | //========================================================================== | 467 | //============================================================================ |
| 583 | /// | ||
| 584 | /// @ingroup cpp_kodi_addon_vfs | 468 | /// @ingroup cpp_kodi_addon_vfs |
| 585 | /// @brief Destructor | 469 | /// @brief Destructor |
| 586 | /// | 470 | /// |
| 587 | ~CInstanceVFS() override = default; | 471 | ~CInstanceVFS() override = default; |
| 588 | //-------------------------------------------------------------------------- | 472 | //---------------------------------------------------------------------------- |
| 589 | 473 | ||
| 590 | //========================================================================== | 474 | //============================================================================ |
| 591 | /// | ||
| 592 | /// @defgroup cpp_kodi_addon_vfs_general 1. General access functions | 475 | /// @defgroup cpp_kodi_addon_vfs_general 1. General access functions |
| 593 | /// @ingroup cpp_kodi_addon_vfs | 476 | /// @ingroup cpp_kodi_addon_vfs |
| 594 | /// @brief **General access functions** | 477 | /// @brief **General access functions** |
| @@ -597,8 +480,7 @@ public: | |||
| 597 | /// locations and file system queries. | 480 | /// locations and file system queries. |
| 598 | /// | 481 | /// |
| 599 | 482 | ||
| 600 | //========================================================================== | 483 | //============================================================================ |
| 601 | /// | ||
| 602 | /// @defgroup cpp_kodi_addon_vfs_filecontrol 2. File editing functions | 484 | /// @defgroup cpp_kodi_addon_vfs_filecontrol 2. File editing functions |
| 603 | /// @ingroup cpp_kodi_addon_vfs | 485 | /// @ingroup cpp_kodi_addon_vfs |
| 604 | /// @brief **File editing functions.** | 486 | /// @brief **File editing functions.** |
| @@ -608,17 +490,22 @@ public: | |||
| 608 | /// | 490 | /// |
| 609 | 491 | ||
| 610 | //@{ | 492 | //@{ |
| 611 | //========================================================================== | 493 | //============================================================================ |
| 612 | /// | ||
| 613 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | 494 | /// @ingroup cpp_kodi_addon_vfs_filecontrol |
| 614 | /// @brief Open a file for input | 495 | /// @brief Open a file for input |
| 615 | /// | 496 | /// |
| 616 | /// @param[in] url The URL of the file | 497 | /// @param[in] url The URL of the file |
| 617 | /// @return Context for the opened file | 498 | /// @return Context for the opened file |
| 618 | virtual void* Open(const VFSURL& url) { return nullptr; } | ||
| 619 | |||
| 620 | //========================================================================== | ||
| 621 | /// | 499 | /// |
| 500 | /// | ||
| 501 | /// ---------------------------------------------------------------------------- | ||
| 502 | /// | ||
| 503 | /// @copydetails cpp_kodi_addon_vfs_Defs_VFSUrl_Help | ||
| 504 | /// | ||
| 505 | virtual kodi::addon::VFSFileHandle Open(const kodi::addon::VFSUrl& url) { return nullptr; } | ||
| 506 | //---------------------------------------------------------------------------- | ||
| 507 | |||
| 508 | //============================================================================ | ||
| 622 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | 509 | /// @ingroup cpp_kodi_addon_vfs_filecontrol |
| 623 | /// @brief Open a file for output | 510 | /// @brief Open a file for output |
| 624 | /// | 511 | /// |
| @@ -626,22 +513,23 @@ public: | |||
| 626 | /// @param[in] overWrite Whether or not to overwrite an existing file | 513 | /// @param[in] overWrite Whether or not to overwrite an existing file |
| 627 | /// @return Context for the opened file | 514 | /// @return Context for the opened file |
| 628 | /// | 515 | /// |
| 629 | virtual void* OpenForWrite(const VFSURL& url, bool overWrite) { return nullptr; } | 516 | virtual kodi::addon::VFSFileHandle OpenForWrite(const kodi::addon::VFSUrl& url, bool overWrite) |
| 630 | //-------------------------------------------------------------------------- | 517 | { |
| 518 | return nullptr; | ||
| 519 | } | ||
| 520 | //---------------------------------------------------------------------------- | ||
| 631 | 521 | ||
| 632 | //========================================================================== | 522 | //============================================================================ |
| 633 | /// | ||
| 634 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | 523 | /// @ingroup cpp_kodi_addon_vfs_filecontrol |
| 635 | /// @brief Close a file | 524 | /// @brief Close a file |
| 636 | /// | 525 | /// |
| 637 | /// @param[in] context The context of the file | 526 | /// @param[in] context The context of the file |
| 638 | /// @return True on success, false on failure | 527 | /// @return True on success, false on failure |
| 639 | /// | 528 | /// |
| 640 | virtual bool Close(void* context) { return false; } | 529 | virtual bool Close(kodi::addon::VFSFileHandle context) { return false; } |
| 641 | //-------------------------------------------------------------------------- | 530 | //---------------------------------------------------------------------------- |
| 642 | 531 | ||
| 643 | //========================================================================== | 532 | //============================================================================ |
| 644 | /// | ||
| 645 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | 533 | /// @ingroup cpp_kodi_addon_vfs_filecontrol |
| 646 | /// @brief Read from a file | 534 | /// @brief Read from a file |
| 647 | /// | 535 | /// |
| @@ -650,11 +538,13 @@ public: | |||
| 650 | /// @param[in] uiBufSize Number of bytes to read | 538 | /// @param[in] uiBufSize Number of bytes to read |
| 651 | /// @return Number of bytes read | 539 | /// @return Number of bytes read |
| 652 | /// | 540 | /// |
| 653 | virtual ssize_t Read(void* context, void* buffer, size_t uiBufSize) { return -1; } | 541 | virtual ssize_t Read(kodi::addon::VFSFileHandle context, uint8_t* buffer, size_t uiBufSize) |
| 654 | //-------------------------------------------------------------------------- | 542 | { |
| 543 | return -1; | ||
| 544 | } | ||
| 545 | //---------------------------------------------------------------------------- | ||
| 655 | 546 | ||
| 656 | //========================================================================== | 547 | //============================================================================ |
| 657 | /// | ||
| 658 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | 548 | /// @ingroup cpp_kodi_addon_vfs_filecontrol |
| 659 | /// @brief Write to a file | 549 | /// @brief Write to a file |
| 660 | /// | 550 | /// |
| @@ -663,24 +553,33 @@ public: | |||
| 663 | /// @param[in] uiBufSize Number of bytes to write | 553 | /// @param[in] uiBufSize Number of bytes to write |
| 664 | /// @return Number of bytes written | 554 | /// @return Number of bytes written |
| 665 | /// | 555 | /// |
| 666 | virtual ssize_t Write(void* context, const void* buffer, size_t uiBufSize) { return -1; } | 556 | virtual ssize_t Write(kodi::addon::VFSFileHandle context, const uint8_t* buffer, size_t uiBufSize) |
| 667 | //-------------------------------------------------------------------------- | 557 | { |
| 558 | return -1; | ||
| 559 | } | ||
| 560 | //---------------------------------------------------------------------------- | ||
| 668 | 561 | ||
| 669 | //========================================================================== | 562 | //============================================================================ |
| 670 | /// | ||
| 671 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | 563 | /// @ingroup cpp_kodi_addon_vfs_filecontrol |
| 672 | /// @brief Seek in a file | 564 | /// @brief Seek in a file |
| 673 | /// | 565 | /// |
| 674 | /// @param[in] context The context of the file | 566 | /// @param[in] context The context of the file |
| 675 | /// @param[in] position The position to seek to | 567 | /// @param[in] position The position to seek to |
| 676 | /// @param[in] whence Position in file 'position' is relative to (SEEK_CUR, SEEK_SET, SEEK_END) | 568 | /// @param[in] whence Position in file 'position' is relative to (SEEK_CUR, SEEK_SET, SEEK_END): |
| 569 | /// | Value | int | Description | | ||
| 570 | /// |:--------:|:---:|:----------------------------------------------------| | ||
| 571 | /// | SEEK_SET | 0 | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence. | ||
| 572 | /// | SEEK_CUR | 1 | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes." | ||
| 573 | /// | SEEK_END | 2 | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion. | ||
| 677 | /// @return Offset in file after seek | 574 | /// @return Offset in file after seek |
| 678 | /// | 575 | /// |
| 679 | virtual int64_t Seek(void* context, int64_t position, int whence) { return -1; } | 576 | virtual int64_t Seek(kodi::addon::VFSFileHandle context, int64_t position, int whence) |
| 680 | //-------------------------------------------------------------------------- | 577 | { |
| 578 | return -1; | ||
| 579 | } | ||
| 580 | //---------------------------------------------------------------------------- | ||
| 681 | 581 | ||
| 682 | //========================================================================== | 582 | //============================================================================ |
| 683 | /// | ||
| 684 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | 583 | /// @ingroup cpp_kodi_addon_vfs_filecontrol |
| 685 | /// @brief Truncate a file | 584 | /// @brief Truncate a file |
| 686 | /// | 585 | /// |
| @@ -688,59 +587,91 @@ public: | |||
| 688 | /// @param[in] size The size to truncate the file to | 587 | /// @param[in] size The size to truncate the file to |
| 689 | /// @return 0 on success, -1 on error | 588 | /// @return 0 on success, -1 on error |
| 690 | /// | 589 | /// |
| 691 | virtual int Truncate(void* context, int64_t size) { return -1; } | 590 | virtual int Truncate(kodi::addon::VFSFileHandle context, int64_t size) { return -1; } |
| 692 | //-------------------------------------------------------------------------- | 591 | //---------------------------------------------------------------------------- |
| 693 | 592 | ||
| 694 | //========================================================================== | 593 | //============================================================================ |
| 695 | /// | ||
| 696 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | 594 | /// @ingroup cpp_kodi_addon_vfs_filecontrol |
| 697 | /// @brief Get total size of a file | 595 | /// @brief Get total size of a file |
| 698 | /// | 596 | /// |
| 699 | /// @param[in] context The context of the file | 597 | /// @param[in] context The context of the file |
| 700 | /// @return Total file size | 598 | /// @return Total file size |
| 701 | /// | 599 | /// |
| 702 | virtual int64_t GetLength(void* context) { return 0; } | 600 | virtual int64_t GetLength(kodi::addon::VFSFileHandle context) { return 0; } |
| 703 | //-------------------------------------------------------------------------- | 601 | //---------------------------------------------------------------------------- |
| 704 | 602 | ||
| 705 | //========================================================================== | 603 | //============================================================================ |
| 706 | /// | ||
| 707 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | 604 | /// @ingroup cpp_kodi_addon_vfs_filecontrol |
| 708 | /// @brief Get current position in a file | 605 | /// @brief Get current position in a file |
| 709 | /// | 606 | /// |
| 710 | /// @param[in] context The context of the file | 607 | /// @param[in] context The context of the file |
| 711 | /// @return Current position | 608 | /// @return Current position |
| 712 | /// | 609 | /// |
| 713 | virtual int64_t GetPosition(void* context) { return 0; } | 610 | virtual int64_t GetPosition(kodi::addon::VFSFileHandle context) { return 0; } |
| 714 | //-------------------------------------------------------------------------- | 611 | //---------------------------------------------------------------------------- |
| 715 | 612 | ||
| 716 | //========================================================================== | 613 | //============================================================================ |
| 717 | /// | ||
| 718 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | 614 | /// @ingroup cpp_kodi_addon_vfs_filecontrol |
| 719 | /// @brief Get chunk size of a file | 615 | /// @brief Get chunk size of a file |
| 720 | /// | 616 | /// |
| 721 | /// @param[in] context The context of the file | 617 | /// @param[in] context The context of the file |
| 722 | /// @return Chunk size | 618 | /// @return Chunk size |
| 723 | /// | 619 | /// |
| 724 | virtual int GetChunkSize(void* context) { return 1; } | 620 | virtual int GetChunkSize(kodi::addon::VFSFileHandle context) { return 1; } |
| 725 | //-------------------------------------------------------------------------- | 621 | //---------------------------------------------------------------------------- |
| 726 | 622 | ||
| 727 | //========================================================================== | 623 | //============================================================================ |
| 624 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | ||
| 625 | /// @brief To check seek possible on current stream by file. | ||
| 728 | /// | 626 | /// |
| 627 | /// @return true if seek possible, false if not | ||
| 628 | /// | ||
| 629 | virtual bool IoControlGetSeekPossible(kodi::addon::VFSFileHandle context) { return false; } | ||
| 630 | //---------------------------------------------------------------------------- | ||
| 631 | |||
| 632 | //============================================================================ | ||
| 729 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | 633 | /// @ingroup cpp_kodi_addon_vfs_filecontrol |
| 730 | /// @brief Perform an IO-control on the file | 634 | /// @brief To check a running stream on file for state of his cache. |
| 635 | /// | ||
| 636 | /// @param[in] status Information about current cache status | ||
| 637 | /// @return true if successfull done, false otherwise | ||
| 731 | /// | 638 | /// |
| 732 | /// @param[in] context The context of the file | ||
| 733 | /// @param[in] request The requested IO-control | ||
| 734 | /// @param[in] param Parameter attached to the IO-control | ||
| 735 | /// @return -1 on error, >= 0 on success | ||
| 736 | /// | 639 | /// |
| 737 | virtual int IoControl(void* context, VFS_IOCTRL request, void* param) { return -1; } | 640 | /// @copydetails cpp_kodi_vfs_Defs_CacheStatus_Help |
| 738 | //-------------------------------------------------------------------------- | 641 | /// |
| 642 | virtual bool IoControlGetCacheStatus(kodi::addon::VFSFileHandle context, | ||
| 643 | kodi::vfs::CacheStatus& status) | ||
| 644 | { | ||
| 645 | return false; | ||
| 646 | } | ||
| 647 | //---------------------------------------------------------------------------- | ||
| 648 | |||
| 649 | //============================================================================ | ||
| 650 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | ||
| 651 | /// @brief Unsigned int with speed limit for caching in bytes per second. | ||
| 652 | /// | ||
| 653 | /// @param[in] rate Cache rate size to use | ||
| 654 | /// @return true if successfull done, false otherwise | ||
| 655 | /// | ||
| 656 | virtual bool IoControlSetCacheRate(kodi::addon::VFSFileHandle context, unsigned int rate) | ||
| 657 | { | ||
| 658 | return false; | ||
| 659 | } | ||
| 660 | //---------------------------------------------------------------------------- | ||
| 661 | |||
| 662 | //============================================================================ | ||
| 663 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | ||
| 664 | /// @brief Enable/disable retry within the protocol handler (if supported). | ||
| 665 | /// | ||
| 666 | /// @param[in] retry To set the retry, true for use, false for not | ||
| 667 | /// @return true if successfull done, false otherwise | ||
| 668 | /// | ||
| 669 | virtual bool IoControlSetRetry(kodi::addon::VFSFileHandle context, bool retry) { return false; } | ||
| 670 | //---------------------------------------------------------------------------- | ||
| 739 | //@} | 671 | //@} |
| 740 | 672 | ||
| 741 | //@{ | 673 | //@{ |
| 742 | //========================================================================== | 674 | //============================================================================ |
| 743 | /// | ||
| 744 | /// @ingroup cpp_kodi_addon_vfs_general | 675 | /// @ingroup cpp_kodi_addon_vfs_general |
| 745 | /// @brief Stat a file | 676 | /// @brief Stat a file |
| 746 | /// | 677 | /// |
| @@ -748,49 +679,49 @@ public: | |||
| 748 | /// @param[in] buffer The buffer to store results in | 679 | /// @param[in] buffer The buffer to store results in |
| 749 | /// @return -1 on error, 0 otherwise | 680 | /// @return -1 on error, 0 otherwise |
| 750 | /// | 681 | /// |
| 751 | virtual int Stat(const VFSURL& url, struct __stat64* buffer) { return 0; } | ||
| 752 | //-------------------------------------------------------------------------- | ||
| 753 | |||
| 754 | //========================================================================== | ||
| 755 | /// | 682 | /// |
| 683 | /// ---------------------------------------------------------------------------- | ||
| 684 | /// | ||
| 685 | /// @copydetails cpp_kodi_addon_vfs_Defs_VFSUrl_Help | ||
| 686 | /// | ||
| 687 | virtual int Stat(const kodi::addon::VFSUrl& url, kodi::vfs::FileStatus& buffer) { return 0; } | ||
| 688 | //---------------------------------------------------------------------------- | ||
| 689 | |||
| 690 | //============================================================================ | ||
| 756 | /// @ingroup cpp_kodi_addon_vfs_general | 691 | /// @ingroup cpp_kodi_addon_vfs_general |
| 757 | /// @brief Check for file existence | 692 | /// @brief Check for file existence |
| 758 | /// | 693 | /// |
| 759 | /// @param[in] url The URL of the file | 694 | /// @param[in] url The URL of the file |
| 760 | /// @return True if file exists, false otherwise | 695 | /// @return True if file exists, false otherwise |
| 761 | /// | 696 | /// |
| 762 | virtual bool Exists(const VFSURL& url) { return false; } | 697 | virtual bool Exists(const kodi::addon::VFSUrl& url) { return false; } |
| 763 | //-------------------------------------------------------------------------- | 698 | //---------------------------------------------------------------------------- |
| 764 | 699 | ||
| 765 | //========================================================================== | 700 | //============================================================================ |
| 766 | /// | ||
| 767 | /// @ingroup cpp_kodi_addon_vfs_general | 701 | /// @ingroup cpp_kodi_addon_vfs_general |
| 768 | /// @brief Clear out any idle connections | 702 | /// @brief Clear out any idle connections |
| 769 | /// | 703 | /// |
| 770 | virtual void ClearOutIdle() {} | 704 | virtual void ClearOutIdle() {} |
| 771 | //-------------------------------------------------------------------------- | 705 | //---------------------------------------------------------------------------- |
| 772 | 706 | ||
| 773 | //========================================================================== | 707 | //============================================================================ |
| 774 | /// | ||
| 775 | /// @ingroup cpp_kodi_addon_vfs_general | 708 | /// @ingroup cpp_kodi_addon_vfs_general |
| 776 | /// @brief Disconnect all connections | 709 | /// @brief Disconnect all connections |
| 777 | /// | 710 | /// |
| 778 | virtual void DisconnectAll() {} | 711 | virtual void DisconnectAll() {} |
| 779 | //-------------------------------------------------------------------------- | 712 | //---------------------------------------------------------------------------- |
| 780 | 713 | ||
| 781 | //========================================================================== | 714 | //============================================================================ |
| 782 | /// | ||
| 783 | /// @ingroup cpp_kodi_addon_vfs_general | 715 | /// @ingroup cpp_kodi_addon_vfs_general |
| 784 | /// @brief Delete a file | 716 | /// @brief Delete a file |
| 785 | /// | 717 | /// |
| 786 | /// @param[in] url The URL of the file | 718 | /// @param[in] url The URL of the file |
| 787 | /// @return True if deletion was successful, false otherwise | 719 | /// @return True if deletion was successful, false otherwise |
| 788 | /// | 720 | /// |
| 789 | virtual bool Delete(const VFSURL& url) { return false; } | 721 | virtual bool Delete(const kodi::addon::VFSUrl& url) { return false; } |
| 790 | //-------------------------------------------------------------------------- | 722 | //---------------------------------------------------------------------------- |
| 791 | 723 | ||
| 792 | //========================================================================== | 724 | //============================================================================ |
| 793 | /// | ||
| 794 | /// @ingroup cpp_kodi_addon_vfs_general | 725 | /// @ingroup cpp_kodi_addon_vfs_general |
| 795 | /// @brief Rename a file | 726 | /// @brief Rename a file |
| 796 | /// | 727 | /// |
| @@ -798,45 +729,44 @@ public: | |||
| 798 | /// @param[in] url2 The URL of the destination file | 729 | /// @param[in] url2 The URL of the destination file |
| 799 | /// @return True if deletion was successful, false otherwise | 730 | /// @return True if deletion was successful, false otherwise |
| 800 | /// | 731 | /// |
| 801 | virtual bool Rename(const VFSURL& url, const VFSURL& url2) { return false; } | 732 | virtual bool Rename(const kodi::addon::VFSUrl& url, const kodi::addon::VFSUrl& url2) |
| 802 | //-------------------------------------------------------------------------- | 733 | { |
| 734 | return false; | ||
| 735 | } | ||
| 736 | //---------------------------------------------------------------------------- | ||
| 803 | 737 | ||
| 804 | //========================================================================== | 738 | //============================================================================ |
| 805 | /// | ||
| 806 | /// @ingroup cpp_kodi_addon_vfs_general | 739 | /// @ingroup cpp_kodi_addon_vfs_general |
| 807 | /// @brief Check for directory existence | 740 | /// @brief Check for directory existence |
| 808 | /// | 741 | /// |
| 809 | /// @param[in] url The URL of the file | 742 | /// @param[in] url The URL of the file |
| 810 | /// @return True if directory exists, false otherwise | 743 | /// @return True if directory exists, false otherwise |
| 811 | /// | 744 | /// |
| 812 | virtual bool DirectoryExists(const VFSURL& url) { return false; } | 745 | virtual bool DirectoryExists(const kodi::addon::VFSUrl& url) { return false; } |
| 813 | //-------------------------------------------------------------------------- | 746 | //---------------------------------------------------------------------------- |
| 814 | 747 | ||
| 815 | //========================================================================== | 748 | //============================================================================ |
| 816 | /// | ||
| 817 | /// @ingroup cpp_kodi_addon_vfs_general | 749 | /// @ingroup cpp_kodi_addon_vfs_general |
| 818 | /// @brief Remove a directory | 750 | /// @brief Remove a directory |
| 819 | /// | 751 | /// |
| 820 | /// @param[in] url The URL of the directory | 752 | /// @param[in] url The URL of the directory |
| 821 | /// @return True if removal was successful, false otherwise | 753 | /// @return True if removal was successful, false otherwise |
| 822 | /// | 754 | /// |
| 823 | virtual bool RemoveDirectory(const VFSURL& url) { return false; } | 755 | virtual bool RemoveDirectory(const kodi::addon::VFSUrl& url) { return false; } |
| 824 | //-------------------------------------------------------------------------- | 756 | //---------------------------------------------------------------------------- |
| 825 | 757 | ||
| 826 | //========================================================================== | 758 | //============================================================================ |
| 827 | /// | ||
| 828 | /// @ingroup cpp_kodi_addon_vfs_general | 759 | /// @ingroup cpp_kodi_addon_vfs_general |
| 829 | /// @brief Create a directory | 760 | /// @brief Create a directory |
| 830 | /// | 761 | /// |
| 831 | /// @param[in] url The URL of the file | 762 | /// @param[in] url The URL of the file |
| 832 | /// @return True if creation was successful, false otherwise | 763 | /// @return True if creation was successful, false otherwise |
| 833 | /// | 764 | /// |
| 834 | virtual bool CreateDirectory(const VFSURL& url) { return false; } | 765 | virtual bool CreateDirectory(const kodi::addon::VFSUrl& url) { return false; } |
| 835 | //-------------------------------------------------------------------------- | 766 | //---------------------------------------------------------------------------- |
| 836 | 767 | ||
| 837 | //========================================================================== | 768 | //============================================================================ |
| 838 | /// | 769 | /// @defgroup cpp_kodi_addon_vfs_general_cb_GetDirectory Callbacks GetDirectory() |
| 839 | /// @defgroup cpp_kodi_addon_vfs_general_cb_GetDirectory **Callbacks GetDirectory()** | ||
| 840 | /// @ingroup cpp_kodi_addon_vfs_general | 770 | /// @ingroup cpp_kodi_addon_vfs_general |
| 841 | /// @brief Callback functions on GetDirectory() | 771 | /// @brief Callback functions on GetDirectory() |
| 842 | /// | 772 | /// |
| @@ -853,7 +783,9 @@ public: | |||
| 853 | /// | 783 | /// |
| 854 | /// ... | 784 | /// ... |
| 855 | /// | 785 | /// |
| 856 | /// bool CMyVFS::GetDirectory(const VFSURL& url, std::vector<kodi::vfs::CDirEntry>& items, CVFSCallbacks callbacks) | 786 | /// bool CMyVFS::GetDirectory(const kodi::addon::VFSUrl& url, |
| 787 | /// std::vector<kodi::vfs::CDirEntry>& items, | ||
| 788 | /// CVFSCallbacks callbacks) | ||
| 857 | /// { | 789 | /// { |
| 858 | /// std::string neededString; | 790 | /// std::string neededString; |
| 859 | /// callbacks.GetKeyboardInput("Test", neededString, true); | 791 | /// callbacks.GetKeyboardInput("Test", neededString, true); |
| @@ -925,10 +857,9 @@ public: | |||
| 925 | private: | 857 | private: |
| 926 | const VFSGetDirectoryCallbacks* m_cb; | 858 | const VFSGetDirectoryCallbacks* m_cb; |
| 927 | }; | 859 | }; |
| 928 | //-------------------------------------------------------------------------- | 860 | //---------------------------------------------------------------------------- |
| 929 | 861 | ||
| 930 | //========================================================================== | 862 | //============================================================================ |
| 931 | /// | ||
| 932 | /// @ingroup cpp_kodi_addon_vfs_general | 863 | /// @ingroup cpp_kodi_addon_vfs_general |
| 933 | /// @brief List a directory | 864 | /// @brief List a directory |
| 934 | /// | 865 | /// |
| @@ -952,16 +883,15 @@ public: | |||
| 952 | /// | CVFSCallbacks::SetErrorDialog | @copybrief CVFSCallbacks::SetErrorDialog @copydetails CVFSCallbacks::SetErrorDialog | 883 | /// | CVFSCallbacks::SetErrorDialog | @copybrief CVFSCallbacks::SetErrorDialog @copydetails CVFSCallbacks::SetErrorDialog |
| 953 | /// | CVFSCallbacks::RequireAuthentication | @copybrief CVFSCallbacks::RequireAuthentication @copydetails CVFSCallbacks::RequireAuthentication | 884 | /// | CVFSCallbacks::RequireAuthentication | @copybrief CVFSCallbacks::RequireAuthentication @copydetails CVFSCallbacks::RequireAuthentication |
| 954 | /// | 885 | /// |
| 955 | virtual bool GetDirectory(const VFSURL& url, | 886 | virtual bool GetDirectory(const kodi::addon::VFSUrl& url, |
| 956 | std::vector<kodi::vfs::CDirEntry>& entries, | 887 | std::vector<kodi::vfs::CDirEntry>& entries, |
| 957 | CVFSCallbacks callbacks) | 888 | CVFSCallbacks callbacks) |
| 958 | { | 889 | { |
| 959 | return false; | 890 | return false; |
| 960 | } | 891 | } |
| 961 | //-------------------------------------------------------------------------- | 892 | //---------------------------------------------------------------------------- |
| 962 | 893 | ||
| 963 | //========================================================================== | 894 | //============================================================================ |
| 964 | /// | ||
| 965 | /// @ingroup cpp_kodi_addon_vfs_general | 895 | /// @ingroup cpp_kodi_addon_vfs_general |
| 966 | /// @brief Check if file should be presented as a directory (multiple streams) | 896 | /// @brief Check if file should be presented as a directory (multiple streams) |
| 967 | /// | 897 | /// |
| @@ -972,13 +902,13 @@ public: | |||
| 972 | /// @param[out] rootPath Path to root directory if multiple entries | 902 | /// @param[out] rootPath Path to root directory if multiple entries |
| 973 | /// @return Context for the directory listing | 903 | /// @return Context for the directory listing |
| 974 | /// | 904 | /// |
| 975 | virtual bool ContainsFiles(const VFSURL& url, | 905 | virtual bool ContainsFiles(const kodi::addon::VFSUrl& url, |
| 976 | std::vector<kodi::vfs::CDirEntry>& entries, | 906 | std::vector<kodi::vfs::CDirEntry>& entries, |
| 977 | std::string& rootPath) | 907 | std::string& rootPath) |
| 978 | { | 908 | { |
| 979 | return false; | 909 | return false; |
| 980 | } | 910 | } |
| 981 | //-------------------------------------------------------------------------- | 911 | //---------------------------------------------------------------------------- |
| 982 | //@} | 912 | //@} |
| 983 | 913 | ||
| 984 | private: | 914 | private: |
| @@ -999,7 +929,10 @@ private: | |||
| 999 | m_instanceData->toAddon->get_length = ADDON_GetLength; | 929 | m_instanceData->toAddon->get_length = ADDON_GetLength; |
| 1000 | m_instanceData->toAddon->get_position = ADDON_GetPosition; | 930 | m_instanceData->toAddon->get_position = ADDON_GetPosition; |
| 1001 | m_instanceData->toAddon->get_chunk_size = ADDON_GetChunkSize; | 931 | m_instanceData->toAddon->get_chunk_size = ADDON_GetChunkSize; |
| 1002 | m_instanceData->toAddon->io_control = ADDON_IoControl; | 932 | m_instanceData->toAddon->io_control_get_seek_possible = ADDON_IoControlGetSeekPossible; |
| 933 | m_instanceData->toAddon->io_control_get_cache_status = ADDON_IoControlGetCacheStatus; | ||
| 934 | m_instanceData->toAddon->io_control_set_cache_rate = ADDON_IoControlSetCacheRate; | ||
| 935 | m_instanceData->toAddon->io_control_set_retry = ADDON_IoControlSetRetry; | ||
| 1003 | m_instanceData->toAddon->stat = ADDON_Stat; | 936 | m_instanceData->toAddon->stat = ADDON_Stat; |
| 1004 | m_instanceData->toAddon->close = ADDON_Close; | 937 | m_instanceData->toAddon->close = ADDON_Close; |
| 1005 | m_instanceData->toAddon->exists = ADDON_Exists; | 938 | m_instanceData->toAddon->exists = ADDON_Exists; |
| @@ -1015,22 +948,23 @@ private: | |||
| 1015 | m_instanceData->toAddon->contains_files = ADDON_ContainsFiles; | 948 | m_instanceData->toAddon->contains_files = ADDON_ContainsFiles; |
| 1016 | } | 949 | } |
| 1017 | 950 | ||
| 1018 | inline static void* ADDON_Open(const AddonInstance_VFSEntry* instance, const VFSURL* url) | 951 | inline static VFS_FILE_HANDLE ADDON_Open(const AddonInstance_VFSEntry* instance, |
| 952 | const VFSURL* url) | ||
| 1019 | { | 953 | { |
| 1020 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Open(*url); | 954 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Open(url); |
| 1021 | } | 955 | } |
| 1022 | 956 | ||
| 1023 | inline static void* ADDON_OpenForWrite(const AddonInstance_VFSEntry* instance, | 957 | inline static VFS_FILE_HANDLE ADDON_OpenForWrite(const AddonInstance_VFSEntry* instance, |
| 1024 | const VFSURL* url, | 958 | const VFSURL* url, |
| 1025 | bool overWrite) | 959 | bool overWrite) |
| 1026 | { | 960 | { |
| 1027 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | 961 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) |
| 1028 | ->OpenForWrite(*url, overWrite); | 962 | ->OpenForWrite(url, overWrite); |
| 1029 | } | 963 | } |
| 1030 | 964 | ||
| 1031 | inline static ssize_t ADDON_Read(const AddonInstance_VFSEntry* instance, | 965 | inline static ssize_t ADDON_Read(const AddonInstance_VFSEntry* instance, |
| 1032 | void* context, | 966 | VFS_FILE_HANDLE context, |
| 1033 | void* buffer, | 967 | uint8_t* buffer, |
| 1034 | size_t uiBufSize) | 968 | size_t uiBufSize) |
| 1035 | { | 969 | { |
| 1036 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | 970 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) |
| @@ -1038,8 +972,8 @@ private: | |||
| 1038 | } | 972 | } |
| 1039 | 973 | ||
| 1040 | inline static ssize_t ADDON_Write(const AddonInstance_VFSEntry* instance, | 974 | inline static ssize_t ADDON_Write(const AddonInstance_VFSEntry* instance, |
| 1041 | void* context, | 975 | VFS_FILE_HANDLE context, |
| 1042 | const void* buffer, | 976 | const uint8_t* buffer, |
| 1043 | size_t uiBufSize) | 977 | size_t uiBufSize) |
| 1044 | { | 978 | { |
| 1045 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | 979 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) |
| @@ -1047,7 +981,7 @@ private: | |||
| 1047 | } | 981 | } |
| 1048 | 982 | ||
| 1049 | inline static int64_t ADDON_Seek(const AddonInstance_VFSEntry* instance, | 983 | inline static int64_t ADDON_Seek(const AddonInstance_VFSEntry* instance, |
| 1050 | void* context, | 984 | VFS_FILE_HANDLE context, |
| 1051 | int64_t position, | 985 | int64_t position, |
| 1052 | int whence) | 986 | int whence) |
| 1053 | { | 987 | { |
| @@ -1056,51 +990,78 @@ private: | |||
| 1056 | } | 990 | } |
| 1057 | 991 | ||
| 1058 | inline static int ADDON_Truncate(const AddonInstance_VFSEntry* instance, | 992 | inline static int ADDON_Truncate(const AddonInstance_VFSEntry* instance, |
| 1059 | void* context, | 993 | VFS_FILE_HANDLE context, |
| 1060 | int64_t size) | 994 | int64_t size) |
| 1061 | { | 995 | { |
| 1062 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Truncate(context, size); | 996 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Truncate(context, size); |
| 1063 | } | 997 | } |
| 1064 | 998 | ||
| 1065 | inline static int64_t ADDON_GetLength(const AddonInstance_VFSEntry* instance, void* context) | 999 | inline static int64_t ADDON_GetLength(const AddonInstance_VFSEntry* instance, |
| 1000 | VFS_FILE_HANDLE context) | ||
| 1066 | { | 1001 | { |
| 1067 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetLength(context); | 1002 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetLength(context); |
| 1068 | } | 1003 | } |
| 1069 | 1004 | ||
| 1070 | inline static int64_t ADDON_GetPosition(const AddonInstance_VFSEntry* instance, void* context) | 1005 | inline static int64_t ADDON_GetPosition(const AddonInstance_VFSEntry* instance, |
| 1006 | VFS_FILE_HANDLE context) | ||
| 1071 | { | 1007 | { |
| 1072 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetPosition(context); | 1008 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetPosition(context); |
| 1073 | } | 1009 | } |
| 1074 | 1010 | ||
| 1075 | inline static int ADDON_GetChunkSize(const AddonInstance_VFSEntry* instance, void* context) | 1011 | inline static int ADDON_GetChunkSize(const AddonInstance_VFSEntry* instance, |
| 1012 | VFS_FILE_HANDLE context) | ||
| 1076 | { | 1013 | { |
| 1077 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetChunkSize(context); | 1014 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetChunkSize(context); |
| 1078 | } | 1015 | } |
| 1079 | 1016 | ||
| 1080 | inline static int ADDON_IoControl(const AddonInstance_VFSEntry* instance, | 1017 | inline static bool ADDON_IoControlGetSeekPossible(const AddonInstance_VFSEntry* instance, |
| 1081 | void* context, | 1018 | VFS_FILE_HANDLE context) |
| 1082 | enum VFS_IOCTRL request, | 1019 | { |
| 1083 | void* param) | 1020 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) |
| 1021 | ->IoControlGetSeekPossible(context); | ||
| 1022 | } | ||
| 1023 | |||
| 1024 | inline static bool ADDON_IoControlGetCacheStatus(const struct AddonInstance_VFSEntry* instance, | ||
| 1025 | VFS_FILE_HANDLE context, | ||
| 1026 | VFS_CACHE_STATUS_DATA* status) | ||
| 1027 | { | ||
| 1028 | kodi::vfs::CacheStatus cppStatus(status); | ||
| 1029 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | ||
| 1030 | ->IoControlGetCacheStatus(context, cppStatus); | ||
| 1031 | } | ||
| 1032 | |||
| 1033 | inline static bool ADDON_IoControlSetCacheRate(const struct AddonInstance_VFSEntry* instance, | ||
| 1034 | VFS_FILE_HANDLE context, | ||
| 1035 | unsigned int rate) | ||
| 1036 | { | ||
| 1037 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | ||
| 1038 | ->IoControlSetCacheRate(context, rate); | ||
| 1039 | } | ||
| 1040 | |||
| 1041 | inline static bool ADDON_IoControlSetRetry(const struct AddonInstance_VFSEntry* instance, | ||
| 1042 | VFS_FILE_HANDLE context, | ||
| 1043 | bool retry) | ||
| 1084 | { | 1044 | { |
| 1085 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | 1045 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) |
| 1086 | ->IoControl(context, request, param); | 1046 | ->IoControlSetRetry(context, retry); |
| 1087 | } | 1047 | } |
| 1088 | 1048 | ||
| 1089 | inline static int ADDON_Stat(const AddonInstance_VFSEntry* instance, | 1049 | inline static int ADDON_Stat(const AddonInstance_VFSEntry* instance, |
| 1090 | const VFSURL* url, | 1050 | const VFSURL* url, |
| 1091 | struct __stat64* buffer) | 1051 | struct STAT_STRUCTURE* buffer) |
| 1092 | { | 1052 | { |
| 1093 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Stat(*url, buffer); | 1053 | kodi::vfs::FileStatus cppBuffer(buffer); |
| 1054 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Stat(url, cppBuffer); | ||
| 1094 | } | 1055 | } |
| 1095 | 1056 | ||
| 1096 | inline static bool ADDON_Close(const AddonInstance_VFSEntry* instance, void* context) | 1057 | inline static bool ADDON_Close(const AddonInstance_VFSEntry* instance, VFS_FILE_HANDLE context) |
| 1097 | { | 1058 | { |
| 1098 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Close(context); | 1059 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Close(context); |
| 1099 | } | 1060 | } |
| 1100 | 1061 | ||
| 1101 | inline static bool ADDON_Exists(const AddonInstance_VFSEntry* instance, const VFSURL* url) | 1062 | inline static bool ADDON_Exists(const AddonInstance_VFSEntry* instance, const VFSURL* url) |
| 1102 | { | 1063 | { |
| 1103 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Exists(*url); | 1064 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Exists(url); |
| 1104 | } | 1065 | } |
| 1105 | 1066 | ||
| 1106 | inline static void ADDON_ClearOutIdle(const AddonInstance_VFSEntry* instance) | 1067 | inline static void ADDON_ClearOutIdle(const AddonInstance_VFSEntry* instance) |
| @@ -1115,32 +1076,32 @@ private: | |||
| 1115 | 1076 | ||
| 1116 | inline static bool ADDON_Delete(const AddonInstance_VFSEntry* instance, const VFSURL* url) | 1077 | inline static bool ADDON_Delete(const AddonInstance_VFSEntry* instance, const VFSURL* url) |
| 1117 | { | 1078 | { |
| 1118 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Delete(*url); | 1079 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Delete(url); |
| 1119 | } | 1080 | } |
| 1120 | 1081 | ||
| 1121 | inline static bool ADDON_Rename(const AddonInstance_VFSEntry* instance, | 1082 | inline static bool ADDON_Rename(const AddonInstance_VFSEntry* instance, |
| 1122 | const VFSURL* url, | 1083 | const VFSURL* url, |
| 1123 | const VFSURL* url2) | 1084 | const VFSURL* url2) |
| 1124 | { | 1085 | { |
| 1125 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Rename(*url, *url2); | 1086 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Rename(url, url2); |
| 1126 | } | 1087 | } |
| 1127 | 1088 | ||
| 1128 | inline static bool ADDON_DirectoryExists(const AddonInstance_VFSEntry* instance, | 1089 | inline static bool ADDON_DirectoryExists(const AddonInstance_VFSEntry* instance, |
| 1129 | const VFSURL* url) | 1090 | const VFSURL* url) |
| 1130 | { | 1091 | { |
| 1131 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->DirectoryExists(*url); | 1092 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->DirectoryExists(url); |
| 1132 | } | 1093 | } |
| 1133 | 1094 | ||
| 1134 | inline static bool ADDON_RemoveDirectory(const AddonInstance_VFSEntry* instance, | 1095 | inline static bool ADDON_RemoveDirectory(const AddonInstance_VFSEntry* instance, |
| 1135 | const VFSURL* url) | 1096 | const VFSURL* url) |
| 1136 | { | 1097 | { |
| 1137 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->RemoveDirectory(*url); | 1098 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->RemoveDirectory(url); |
| 1138 | } | 1099 | } |
| 1139 | 1100 | ||
| 1140 | inline static bool ADDON_CreateDirectory(const AddonInstance_VFSEntry* instance, | 1101 | inline static bool ADDON_CreateDirectory(const AddonInstance_VFSEntry* instance, |
| 1141 | const VFSURL* url) | 1102 | const VFSURL* url) |
| 1142 | { | 1103 | { |
| 1143 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->CreateDirectory(*url); | 1104 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->CreateDirectory(url); |
| 1144 | } | 1105 | } |
| 1145 | 1106 | ||
| 1146 | inline static bool ADDON_GetDirectory(const AddonInstance_VFSEntry* instance, | 1107 | inline static bool ADDON_GetDirectory(const AddonInstance_VFSEntry* instance, |
| @@ -1151,7 +1112,7 @@ private: | |||
| 1151 | { | 1112 | { |
| 1152 | std::vector<kodi::vfs::CDirEntry> addonEntries; | 1113 | std::vector<kodi::vfs::CDirEntry> addonEntries; |
| 1153 | bool ret = static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | 1114 | bool ret = static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) |
| 1154 | ->GetDirectory(*url, addonEntries, CVFSCallbacks(callbacks)); | 1115 | ->GetDirectory(url, addonEntries, CVFSCallbacks(callbacks)); |
| 1155 | if (ret) | 1116 | if (ret) |
| 1156 | { | 1117 | { |
| 1157 | VFSDirEntry* entries = | 1118 | VFSDirEntry* entries = |
| @@ -1218,7 +1179,7 @@ private: | |||
| 1218 | std::string cppRootPath; | 1179 | std::string cppRootPath; |
| 1219 | std::vector<kodi::vfs::CDirEntry> addonEntries; | 1180 | std::vector<kodi::vfs::CDirEntry> addonEntries; |
| 1220 | bool ret = static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | 1181 | bool ret = static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) |
| 1221 | ->ContainsFiles(*url, addonEntries, cppRootPath); | 1182 | ->ContainsFiles(url, addonEntries, cppRootPath); |
| 1222 | if (ret) | 1183 | if (ret) |
| 1223 | { | 1184 | { |
| 1224 | strncpy(rootpath, cppRootPath.c_str(), ADDON_STANDARD_STRING_LENGTH); | 1185 | strncpy(rootpath, cppRootPath.c_str(), ADDON_STANDARD_STRING_LENGTH); |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h index 54246f0..12893db 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h | |||
| @@ -18,8 +18,6 @@ | |||
| 18 | #include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" | 18 | #include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" |
| 19 | #endif | 19 | #endif |
| 20 | 20 | ||
| 21 | namespace kodi { namespace addon { class CInstanceVideoCodec; } } | ||
| 22 | |||
| 23 | extern "C" | 21 | extern "C" |
| 24 | { | 22 | { |
| 25 | enum VIDEOCODEC_FORMAT | 23 | enum VIDEOCODEC_FORMAT |
| @@ -80,7 +78,7 @@ extern "C" | |||
| 80 | 78 | ||
| 81 | int64_t pts; | 79 | int64_t pts; |
| 82 | 80 | ||
| 83 | KODI_HANDLE buffer; //< will be passed in release_frame_buffer | 81 | KODI_HANDLE videoBufferHandle; //< will be passed in release_frame_buffer |
| 84 | }; | 82 | }; |
| 85 | 83 | ||
| 86 | enum VIDEOCODEC_RETVAL | 84 | enum VIDEOCODEC_RETVAL |
| @@ -102,7 +100,7 @@ extern "C" | |||
| 102 | struct AddonInstance_VideoCodec; | 100 | struct AddonInstance_VideoCodec; |
| 103 | typedef struct KodiToAddonFuncTable_VideoCodec | 101 | typedef struct KodiToAddonFuncTable_VideoCodec |
| 104 | { | 102 | { |
| 105 | kodi::addon::CInstanceVideoCodec* addonInstance; | 103 | KODI_HANDLE addonInstance; |
| 106 | 104 | ||
| 107 | //! \brief Opens a codec | 105 | //! \brief Opens a codec |
| 108 | bool (__cdecl* open) (const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData); | 106 | bool (__cdecl* open) (const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData); |
| @@ -132,9 +130,9 @@ extern "C" | |||
| 132 | 130 | ||
| 133 | typedef struct AddonInstance_VideoCodec | 131 | typedef struct AddonInstance_VideoCodec |
| 134 | { | 132 | { |
| 135 | AddonProps_VideoCodec props; | 133 | AddonProps_VideoCodec* props; |
| 136 | AddonToKodiFuncTable_VideoCodec toKodi; | 134 | AddonToKodiFuncTable_VideoCodec* toKodi; |
| 137 | KodiToAddonFuncTable_VideoCodec toAddon; | 135 | KodiToAddonFuncTable_VideoCodec* toAddon; |
| 138 | } AddonInstance_VideoCodec; | 136 | } AddonInstance_VideoCodec; |
| 139 | } | 137 | } |
| 140 | 138 | ||
| @@ -184,13 +182,15 @@ namespace kodi | |||
| 184 | //! \copydoc CInstanceVideoCodec::GetFrameBuffer | 182 | //! \copydoc CInstanceVideoCodec::GetFrameBuffer |
| 185 | bool GetFrameBuffer(VIDEOCODEC_PICTURE &picture) | 183 | bool GetFrameBuffer(VIDEOCODEC_PICTURE &picture) |
| 186 | { | 184 | { |
| 187 | return m_instanceData->toKodi.get_frame_buffer(m_instanceData->toKodi.kodiInstance, &picture); | 185 | return m_instanceData->toKodi->get_frame_buffer(m_instanceData->toKodi->kodiInstance, |
| 186 | &picture); | ||
| 188 | } | 187 | } |
| 189 | 188 | ||
| 190 | //! \copydoc CInstanceVideoCodec::ReleaseFrameBuffer | 189 | //! \copydoc CInstanceVideoCodec::ReleaseFrameBuffer |
| 191 | void ReleaseFrameBuffer(void *buffer) | 190 | void ReleaseFrameBuffer(void *buffer) |
| 192 | { | 191 | { |
| 193 | return m_instanceData->toKodi.release_frame_buffer(m_instanceData->toKodi.kodiInstance, buffer); | 192 | return m_instanceData->toKodi->release_frame_buffer(m_instanceData->toKodi->kodiInstance, |
| 193 | buffer); | ||
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | private: | 196 | private: |
| @@ -201,43 +201,46 @@ namespace kodi | |||
| 201 | 201 | ||
| 202 | m_instanceData = static_cast<AddonInstance_VideoCodec*>(instance); | 202 | m_instanceData = static_cast<AddonInstance_VideoCodec*>(instance); |
| 203 | 203 | ||
| 204 | m_instanceData->toAddon.addonInstance = this; | 204 | m_instanceData->toAddon->addonInstance = this; |
| 205 | m_instanceData->toAddon.open = ADDON_Open; | 205 | m_instanceData->toAddon->open = ADDON_Open; |
| 206 | m_instanceData->toAddon.reconfigure = ADDON_Reconfigure; | 206 | m_instanceData->toAddon->reconfigure = ADDON_Reconfigure; |
| 207 | m_instanceData->toAddon.add_data = ADDON_AddData; | 207 | m_instanceData->toAddon->add_data = ADDON_AddData; |
| 208 | m_instanceData->toAddon.get_picture = ADDON_GetPicture; | 208 | m_instanceData->toAddon->get_picture = ADDON_GetPicture; |
| 209 | m_instanceData->toAddon.get_name = ADDON_GetName; | 209 | m_instanceData->toAddon->get_name = ADDON_GetName; |
| 210 | m_instanceData->toAddon.reset = ADDON_Reset; | 210 | m_instanceData->toAddon->reset = ADDON_Reset; |
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | inline static bool ADDON_Open(const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData) | 213 | inline static bool ADDON_Open(const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData) |
| 214 | { | 214 | { |
| 215 | return instance->toAddon.addonInstance->Open(*initData); | 215 | return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->Open(*initData); |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | inline static bool ADDON_Reconfigure(const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData) | 218 | inline static bool ADDON_Reconfigure(const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData) |
| 219 | { | 219 | { |
| 220 | return instance->toAddon.addonInstance->Reconfigure(*initData); | 220 | return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance) |
| 221 | ->Reconfigure(*initData); | ||
| 221 | } | 222 | } |
| 222 | 223 | ||
| 223 | inline static bool ADDON_AddData(const AddonInstance_VideoCodec* instance, const DemuxPacket *packet) | 224 | inline static bool ADDON_AddData(const AddonInstance_VideoCodec* instance, const DemuxPacket *packet) |
| 224 | { | 225 | { |
| 225 | return instance->toAddon.addonInstance->AddData(*packet); | 226 | return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance) |
| 227 | ->AddData(*packet); | ||
| 226 | } | 228 | } |
| 227 | 229 | ||
| 228 | inline static VIDEOCODEC_RETVAL ADDON_GetPicture(const AddonInstance_VideoCodec* instance, VIDEOCODEC_PICTURE *picture) | 230 | inline static VIDEOCODEC_RETVAL ADDON_GetPicture(const AddonInstance_VideoCodec* instance, VIDEOCODEC_PICTURE *picture) |
| 229 | { | 231 | { |
| 230 | return instance->toAddon.addonInstance->GetPicture(*picture); | 232 | return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance) |
| 233 | ->GetPicture(*picture); | ||
| 231 | } | 234 | } |
| 232 | 235 | ||
| 233 | inline static const char *ADDON_GetName(const AddonInstance_VideoCodec* instance) | 236 | inline static const char *ADDON_GetName(const AddonInstance_VideoCodec* instance) |
| 234 | { | 237 | { |
| 235 | return instance->toAddon.addonInstance->GetName(); | 238 | return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->GetName(); |
| 236 | } | 239 | } |
| 237 | 240 | ||
| 238 | inline static void ADDON_Reset(const AddonInstance_VideoCodec* instance) | 241 | inline static void ADDON_Reset(const AddonInstance_VideoCodec* instance) |
| 239 | { | 242 | { |
| 240 | return instance->toAddon.addonInstance->Reset(); | 243 | return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->Reset(); |
| 241 | } | 244 | } |
| 242 | 245 | ||
| 243 | AddonInstance_VideoCodec* m_instanceData; | 246 | AddonInstance_VideoCodec* m_instanceData; |
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h new file mode 100644 index 0000000..7b1db65 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h | |||
| @@ -0,0 +1,992 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | #include "../c-api/addon-instance/visualization.h" | ||
| 13 | #include "../gui/renderHelper.h" | ||
| 14 | |||
| 15 | #ifdef __cplusplus | ||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace addon | ||
| 19 | { | ||
| 20 | |||
| 21 | |||
| 22 | //============================================================================== | ||
| 23 | /// @defgroup cpp_kodi_addon_visualization_Defs_VisualizationTrack class VisualizationTrack | ||
| 24 | /// @ingroup cpp_kodi_addon_visualization_Defs | ||
| 25 | /// @brief **Info tag data structure**\n | ||
| 26 | /// Representation of available information of processed audio file. | ||
| 27 | /// | ||
| 28 | /// This is used to store all the necessary data of audio stream and to have on | ||
| 29 | /// e.g. GUI for information. | ||
| 30 | /// | ||
| 31 | /// Called from @ref kodi::addon::CInstanceVisualization::UpdateTrack() with the | ||
| 32 | /// information of the currently-playing song. | ||
| 33 | /// | ||
| 34 | /// ---------------------------------------------------------------------------- | ||
| 35 | /// | ||
| 36 | /// @copydetails cpp_kodi_addon_visualization_Defs_VisualizationTrack_Help | ||
| 37 | /// | ||
| 38 | ///@{ | ||
| 39 | class VisualizationTrack | ||
| 40 | { | ||
| 41 | /*! \cond PRIVATE */ | ||
| 42 | friend class CInstanceVisualization; | ||
| 43 | /*! \endcond */ | ||
| 44 | |||
| 45 | public: | ||
| 46 | /*! \cond PRIVATE */ | ||
| 47 | VisualizationTrack() = default; | ||
| 48 | VisualizationTrack(const VisualizationTrack& tag) | ||
| 49 | { | ||
| 50 | *this = tag; | ||
| 51 | } | ||
| 52 | |||
| 53 | VisualizationTrack& operator=(const VisualizationTrack& right) | ||
| 54 | { | ||
| 55 | if (&right == this) | ||
| 56 | return *this; | ||
| 57 | |||
| 58 | m_title = right.m_title; | ||
| 59 | m_artist = right.m_artist; | ||
| 60 | m_album = right.m_album; | ||
| 61 | m_albumArtist = right.m_albumArtist; | ||
| 62 | m_genre = right.m_genre; | ||
| 63 | m_comment = right.m_comment; | ||
| 64 | m_lyrics = right.m_lyrics; | ||
| 65 | |||
| 66 | m_trackNumber = right.m_trackNumber; | ||
| 67 | m_discNumber = right.m_discNumber; | ||
| 68 | m_duration = right.m_duration; | ||
| 69 | m_year = right.m_year; | ||
| 70 | m_rating = right.m_rating; | ||
| 71 | return *this; | ||
| 72 | } | ||
| 73 | /*! \endcond */ | ||
| 74 | |||
| 75 | /// @defgroup cpp_kodi_addon_visualization_Defs_VisualizationTrack_Help Value Help | ||
| 76 | /// @ingroup cpp_kodi_addon_visualization_Defs_VisualizationTrack | ||
| 77 | /// | ||
| 78 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_visualization_Defs_VisualizationTrack :</b> | ||
| 79 | /// | Name | Type | Set call | Get call | ||
| 80 | /// |------|------|----------|---------- | ||
| 81 | /// | **Title of the current song.** | `std::string` | @ref VisualizationTrack::SetTitle "SetTitle" | @ref VisualizationTrack::GetTitle "GetTitle" | ||
| 82 | /// | **Artist names, as a single string** | `std::string` | @ref VisualizationTrack::SetArtist "SetArtist" | @ref VisualizationTrack::GetArtist "GetArtist" | ||
| 83 | /// | **Album that the current song is from.** | `std::string` | @ref VisualizationTrack::SetAlbum "SetAlbum" | @ref VisualizationTrack::GetAlbum "GetAlbum" | ||
| 84 | /// | **Album artist names, as a single string** | `std::string` | @ref VisualizationTrack::SetAlbumArtist "SetAlbumArtist" | @ref VisualizationTrack::GetAlbumArtist "GetAlbumArtist" | ||
| 85 | /// | **The genre name from the music tag, if present** | `std::string` | @ref VisualizationTrack::SetGenre "SetGenre" | @ref VisualizationTrack::GetGenre "GetGenre" | ||
| 86 | /// | **Duration of the current song, in seconds** | `int` | @ref VisualizationTrack::SetDuration "SetDuration" | @ref VisualizationTrack::GetDuration "GetDuration" | ||
| 87 | /// | **Track number of the current song** | `int` | @ref VisualizationTrack::SetTrack "SetTrack" | @ref VisualizationTrack::GetTrack "GetTrack" | ||
| 88 | /// | **Disc number of the current song stored in the ID tag info** | `int` | @ref VisualizationTrack::SetDisc "SetDisc" | @ref VisualizationTrack::GetDisc "GetDisc" | ||
| 89 | /// | **Year that the current song was released** | `int` | @ref VisualizationTrack::SetYear "SetYear" | @ref VisualizationTrack::GetYear "GetYear" | ||
| 90 | /// | **Lyrics of the current song, if available** | `std::string` | @ref VisualizationTrack::SetLyrics "SetLyrics" | @ref VisualizationTrack::GetLyrics "GetLyrics" | ||
| 91 | /// | **The user-defined rating of the current song** | `int` | @ref VisualizationTrack::SetRating "SetRating" | @ref VisualizationTrack::GetRating "GetRating" | ||
| 92 | /// | **Comment of the current song stored in the ID tag info** | `std::string` | @ref VisualizationTrack::SetComment "SetComment" | @ref VisualizationTrack::GetComment "GetComment" | ||
| 93 | /// | ||
| 94 | |||
| 95 | /// @addtogroup cpp_kodi_addon_visualization_Defs_VisualizationTrack | ||
| 96 | ///@{ | ||
| 97 | |||
| 98 | /// @brief Set title of the current song. | ||
| 99 | void SetTitle(const std::string& title) { m_title = title; } | ||
| 100 | |||
| 101 | /// @brief Get title of the current song. | ||
| 102 | const std::string& GetTitle() const { return m_title; } | ||
| 103 | |||
| 104 | /// @brief Set artist names, as a single string- | ||
| 105 | void SetArtist(const std::string& artist) { m_artist = artist; } | ||
| 106 | |||
| 107 | /// @brief Get artist names, as a single string- | ||
| 108 | const std::string& GetArtist() const { return m_artist; } | ||
| 109 | |||
| 110 | /// @brief Set Album that the current song is from. | ||
| 111 | void SetAlbum(const std::string& album) { m_album = album; } | ||
| 112 | |||
| 113 | /// @brief Get Album that the current song is from. | ||
| 114 | const std::string& GetAlbum() const { return m_album; } | ||
| 115 | |||
| 116 | /// @brief Set album artist names, as a single stringalbum artist name | ||
| 117 | void SetAlbumArtist(const std::string& albumArtist) { m_albumArtist = albumArtist; } | ||
| 118 | |||
| 119 | /// @brief Get album artist names, as a single string- | ||
| 120 | const std::string& GetAlbumArtist() const { return m_albumArtist; } | ||
| 121 | |||
| 122 | /// @brief Set genre name from music as string if present. | ||
| 123 | void SetGenre(const std::string& genre) { m_genre = genre; } | ||
| 124 | |||
| 125 | /// @brief Get genre name from music as string if present. | ||
| 126 | const std::string& GetGenre() const { return m_genre; } | ||
| 127 | |||
| 128 | /// @brief Set the duration of music as integer from info. | ||
| 129 | void SetDuration(int duration) { m_duration = duration; } | ||
| 130 | |||
| 131 | /// @brief Get the duration of music as integer from info. | ||
| 132 | int GetDuration() const { return m_duration; } | ||
| 133 | |||
| 134 | /// @brief Set track number (if present) from music info as integer. | ||
| 135 | void SetTrack(int trackNumber) { m_trackNumber = trackNumber; } | ||
| 136 | |||
| 137 | /// @brief Get track number (if present). | ||
| 138 | int GetTrack() const { return m_trackNumber; } | ||
| 139 | |||
| 140 | /// @brief Set disk number (if present) from music info as integer. | ||
| 141 | void SetDisc(int discNumber) { m_discNumber = discNumber; } | ||
| 142 | |||
| 143 | /// @brief Get disk number (if present) | ||
| 144 | int GetDisc() const { return m_discNumber; } | ||
| 145 | |||
| 146 | /// @brief Set year that the current song was released. | ||
| 147 | void SetYear(int year) { m_year = year; } | ||
| 148 | |||
| 149 | /// @brief Get year that the current song was released. | ||
| 150 | int GetYear() const { return m_year; } | ||
| 151 | |||
| 152 | /// @brief Set string from lyrics. | ||
| 153 | void SetLyrics(const std::string& lyrics) { m_lyrics = lyrics; } | ||
| 154 | |||
| 155 | /// @brief Get string from lyrics. | ||
| 156 | const std::string& GetLyrics() const { return m_lyrics; } | ||
| 157 | |||
| 158 | /// @brief Set the user-defined rating of the current song. | ||
| 159 | void SetRating(int rating) { m_rating = rating; } | ||
| 160 | |||
| 161 | /// @brief Get the user-defined rating of the current song. | ||
| 162 | int GetRating() const { return m_rating; } | ||
| 163 | |||
| 164 | /// @brief Set additional information comment (if present). | ||
| 165 | void SetComment(const std::string& comment) { m_comment = comment; } | ||
| 166 | |||
| 167 | /// @brief Get additional information comment (if present). | ||
| 168 | const std::string& GetComment() const { return m_comment; } | ||
| 169 | |||
| 170 | ///@} | ||
| 171 | |||
| 172 | private: | ||
| 173 | VisualizationTrack(const VIS_TRACK* tag) | ||
| 174 | { | ||
| 175 | if (!tag) | ||
| 176 | return; | ||
| 177 | |||
| 178 | m_title = tag->title ? tag->title : ""; | ||
| 179 | m_artist = tag->artist ? tag->artist : ""; | ||
| 180 | m_album = tag->album ? tag->album : ""; | ||
| 181 | m_albumArtist = tag->albumArtist ? tag->albumArtist : ""; | ||
| 182 | m_genre = tag->genre ? tag->genre : ""; | ||
| 183 | m_comment = tag->comment ? tag->comment : ""; | ||
| 184 | m_lyrics = tag->lyrics ? tag->lyrics : ""; | ||
| 185 | |||
| 186 | m_trackNumber = tag->trackNumber; | ||
| 187 | m_discNumber = tag->discNumber; | ||
| 188 | m_duration = tag->duration; | ||
| 189 | m_year = tag->year; | ||
| 190 | m_rating = tag->rating; | ||
| 191 | } | ||
| 192 | |||
| 193 | std::string m_title; | ||
| 194 | std::string m_artist; | ||
| 195 | std::string m_album; | ||
| 196 | std::string m_albumArtist; | ||
| 197 | std::string m_genre; | ||
| 198 | std::string m_comment; | ||
| 199 | std::string m_lyrics; | ||
| 200 | |||
| 201 | int m_trackNumber = 0; | ||
| 202 | int m_discNumber = 0; | ||
| 203 | int m_duration = 0; | ||
| 204 | int m_year = 0; | ||
| 205 | int m_rating = 0; | ||
| 206 | }; | ||
| 207 | ///@} | ||
| 208 | //------------------------------------------------------------------------------ | ||
| 209 | |||
| 210 | //============================================================================== | ||
| 211 | /// @defgroup cpp_kodi_addon_visualization_Defs Definitions, structures and enumerators | ||
| 212 | /// @ingroup cpp_kodi_addon_visualization | ||
| 213 | /// @brief **Visualization add-on instance definition values**\n | ||
| 214 | /// All visualization functions associated data structures. | ||
| 215 | /// | ||
| 216 | /// Used to exchange the available options between Kodi and addon. | ||
| 217 | /// | ||
| 218 | |||
| 219 | //============================================================================== | ||
| 220 | /// @addtogroup cpp_kodi_addon_visualization | ||
| 221 | /// @brief \cpp_class{ kodi::addon::CInstanceVisualization } | ||
| 222 | /// **Visualization add-on instance**\n | ||
| 223 | /// [Music visualization](https://en.wikipedia.org/wiki/Music_visualization), | ||
| 224 | /// or music visualisation, is a feature in Kodi that generates animated | ||
| 225 | /// imagery based on a piece of music. The imagery is usually generated and | ||
| 226 | /// rendered in real time synchronized to the music. | ||
| 227 | /// | ||
| 228 | /// Visualization techniques range from simple ones (e.g., a simulation of an | ||
| 229 | /// oscilloscope display) to elaborate ones, which often include a plurality | ||
| 230 | /// of composited effects. The changes in the music's loudness and frequency | ||
| 231 | /// spectrum are among the properties used as input to the visualization. | ||
| 232 | /// | ||
| 233 | /// Include the header @ref Visualization.h "#include <kodi/addon-instance/Visualization.h>" | ||
| 234 | /// to use this class. | ||
| 235 | /// | ||
| 236 | /// This interface allows the creation of visualizations for Kodi, based upon | ||
| 237 | /// **DirectX** or/and **OpenGL** rendering with `C++` code. | ||
| 238 | /// | ||
| 239 | /// Additionally, there are several @ref cpp_kodi_addon_visualization_CB "other functions" | ||
| 240 | /// available in which the child class can ask about the current hardware, | ||
| 241 | /// including the device, display and several other parts. | ||
| 242 | /// | ||
| 243 | /// ---------------------------------------------------------------------------- | ||
| 244 | /// | ||
| 245 | /// **Here's an example on addon.xml:** | ||
| 246 | /// ~~~~~~~~~~~~~{.xml} | ||
| 247 | /// <?xml version="1.0" encoding="UTF-8"?> | ||
| 248 | /// <addon | ||
| 249 | /// id="visualization.myspecialnamefor" | ||
| 250 | /// version="1.0.0" | ||
| 251 | /// name="My special visualization addon" | ||
| 252 | /// provider-name="Your Name"> | ||
| 253 | /// <requires>@ADDON_DEPENDS@</requires> | ||
| 254 | /// <extension | ||
| 255 | /// point="xbmc.player.musicviz" | ||
| 256 | /// library_@PLATFORM@="@LIBRARY_FILENAME@"/> | ||
| 257 | /// <extension point="xbmc.addon.metadata"> | ||
| 258 | /// <summary lang="en_GB">My visualization addon addon</summary> | ||
| 259 | /// <description lang="en_GB">My visualization addon description</description> | ||
| 260 | /// <platform>@PLATFORM@</platform> | ||
| 261 | /// </extension> | ||
| 262 | /// </addon> | ||
| 263 | /// ~~~~~~~~~~~~~ | ||
| 264 | /// | ||
| 265 | /// Description to visualization related addon.xml values: | ||
| 266 | /// | Name | Description | ||
| 267 | /// |:------------------------------|---------------------------------------- | ||
| 268 | /// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"xbmc.player.musicviz"</b>. | ||
| 269 | /// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build. | ||
| 270 | /// | ||
| 271 | /// -------------------------------------------------------------------------- | ||
| 272 | /// | ||
| 273 | /// **Here is an example of the minimum required code to start a visualization:** | ||
| 274 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 275 | /// #include <kodi/addon-instance/Visualization.h> | ||
| 276 | /// | ||
| 277 | /// class CMyVisualization : public kodi::addon::CAddonBase, | ||
| 278 | /// public kodi::addon::CInstanceVisualization | ||
| 279 | /// { | ||
| 280 | /// public: | ||
| 281 | /// CMyVisualization(); | ||
| 282 | /// | ||
| 283 | /// bool Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) override; | ||
| 284 | /// void AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength) override; | ||
| 285 | /// void Render() override; | ||
| 286 | /// }; | ||
| 287 | /// | ||
| 288 | /// CMyVisualization::CMyVisualization() | ||
| 289 | /// { | ||
| 290 | /// ... | ||
| 291 | /// } | ||
| 292 | /// | ||
| 293 | /// bool CMyVisualization::Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) | ||
| 294 | /// { | ||
| 295 | /// ... | ||
| 296 | /// return true; | ||
| 297 | /// } | ||
| 298 | /// | ||
| 299 | /// void CMyVisualization::AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength) | ||
| 300 | /// { | ||
| 301 | /// ... | ||
| 302 | /// } | ||
| 303 | /// | ||
| 304 | /// void CMyVisualization::Render() | ||
| 305 | /// { | ||
| 306 | /// ... | ||
| 307 | /// } | ||
| 308 | /// | ||
| 309 | /// ADDONCREATOR(CMyVisualization) | ||
| 310 | /// ~~~~~~~~~~~~~ | ||
| 311 | /// | ||
| 312 | /// | ||
| 313 | /// -------------------------------------------------------------------------- | ||
| 314 | /// | ||
| 315 | /// | ||
| 316 | /// **Here is another example where the visualization is used together with | ||
| 317 | /// other instance types:** | ||
| 318 | /// | ||
| 319 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 320 | /// #include <kodi/addon-instance/Visualization.h> | ||
| 321 | /// | ||
| 322 | /// class CMyVisualization : public kodi::addon::CInstanceVisualization | ||
| 323 | /// { | ||
| 324 | /// public: | ||
| 325 | /// CMyVisualization(KODI_HANDLE instance, const std::string& version); | ||
| 326 | /// | ||
| 327 | /// bool Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) override; | ||
| 328 | /// void AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength) override; | ||
| 329 | /// void Render() override; | ||
| 330 | /// }; | ||
| 331 | /// | ||
| 332 | /// CMyVisualization::CMyVisualization(KODI_HANDLE instance, const std::string& version) | ||
| 333 | /// : kodi::addon::CInstanceAudioDecoder(instance, version) | ||
| 334 | /// { | ||
| 335 | /// ... | ||
| 336 | /// } | ||
| 337 | /// | ||
| 338 | /// bool CMyVisualization::Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) | ||
| 339 | /// { | ||
| 340 | /// ... | ||
| 341 | /// return true; | ||
| 342 | /// } | ||
| 343 | /// | ||
| 344 | /// void CMyVisualization::AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength) | ||
| 345 | /// { | ||
| 346 | /// ... | ||
| 347 | /// } | ||
| 348 | /// | ||
| 349 | /// void CMyVisualization::Render() | ||
| 350 | /// { | ||
| 351 | /// ... | ||
| 352 | /// } | ||
| 353 | /// | ||
| 354 | /// | ||
| 355 | /// //---------------------------------------------------------------------- | ||
| 356 | /// | ||
| 357 | /// class CMyAddon : public kodi::addon::CAddonBase | ||
| 358 | /// { | ||
| 359 | /// public: | ||
| 360 | /// CMyAddon() { } | ||
| 361 | /// ADDON_STATUS CreateInstance(int instanceType, | ||
| 362 | /// const std::string& instanceID, | ||
| 363 | /// KODI_HANDLE instance, | ||
| 364 | /// const std::string& version, | ||
| 365 | /// KODI_HANDLE& addonInstance) override; | ||
| 366 | /// }; | ||
| 367 | /// | ||
| 368 | /// // If you use only one instance in your add-on, can be instanceType and | ||
| 369 | /// // instanceID ignored | ||
| 370 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 371 | /// const std::string& instanceID, | ||
| 372 | /// KODI_HANDLE instance, | ||
| 373 | /// const std::string& version, | ||
| 374 | /// KODI_HANDLE& addonInstance) | ||
| 375 | /// { | ||
| 376 | /// if (instanceType == ADDON_INSTANCE_VISUALIZATION) | ||
| 377 | /// { | ||
| 378 | /// kodi::Log(ADDON_LOG_INFO, "Creating my visualization"); | ||
| 379 | /// addonInstance = new CMyVisualization(instance, version); | ||
| 380 | /// return ADDON_STATUS_OK; | ||
| 381 | /// } | ||
| 382 | /// else if (...) | ||
| 383 | /// { | ||
| 384 | /// ... | ||
| 385 | /// } | ||
| 386 | /// return ADDON_STATUS_UNKNOWN; | ||
| 387 | /// } | ||
| 388 | /// | ||
| 389 | /// ADDONCREATOR(CMyAddon) | ||
| 390 | /// ~~~~~~~~~~~~~ | ||
| 391 | /// | ||
| 392 | /// The destruction of the example class `CMyVisualization` is called from | ||
| 393 | /// Kodi's header. Manually deleting the add-on instance is not required. | ||
| 394 | /// | ||
| 395 | class ATTRIBUTE_HIDDEN CInstanceVisualization : public IAddonInstance | ||
| 396 | { | ||
| 397 | public: | ||
| 398 | //============================================================================ | ||
| 399 | /// | ||
| 400 | /// @ingroup cpp_kodi_addon_visualization | ||
| 401 | /// @brief Visualization class constructor | ||
| 402 | /// | ||
| 403 | /// Used by an add-on that only supports visualizations. | ||
| 404 | /// | ||
| 405 | CInstanceVisualization() | ||
| 406 | : IAddonInstance(ADDON_INSTANCE_VISUALIZATION, GetKodiTypeVersion(ADDON_INSTANCE_VISUALIZATION)) | ||
| 407 | { | ||
| 408 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 409 | throw std::logic_error( | ||
| 410 | "kodi::addon::CInstanceVisualization: Cannot create multiple instances of add-on."); | ||
| 411 | |||
| 412 | SetAddonStruct(CAddonBase::m_interface->firstKodiInstance); | ||
| 413 | CAddonBase::m_interface->globalSingleInstance = this; | ||
| 414 | } | ||
| 415 | //---------------------------------------------------------------------------- | ||
| 416 | |||
| 417 | //========================================================================== | ||
| 418 | /// @ingroup cpp_kodi_addon_visualization | ||
| 419 | /// @brief Visualization class constructor used to support multiple instance | ||
| 420 | /// types. | ||
| 421 | /// | ||
| 422 | /// @param[in] instance The instance value given to | ||
| 423 | /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>. | ||
| 424 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to | ||
| 425 | /// allow compatibility to older Kodi versions. | ||
| 426 | /// | ||
| 427 | /// @note Recommended to set <b>`kodiVersion`</b>. | ||
| 428 | /// | ||
| 429 | /// | ||
| 430 | /// -------------------------------------------------------------------------- | ||
| 431 | /// | ||
| 432 | /// **Here's example about the use of this:** | ||
| 433 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 434 | /// class CMyVisualization : public kodi::addon::CInstanceAudioDecoder | ||
| 435 | /// { | ||
| 436 | /// public: | ||
| 437 | /// CMyVisualization(KODI_HANDLE instance, const std::string& kodiVersion) | ||
| 438 | /// : kodi::addon::CInstanceAudioDecoder(instance, kodiVersion) | ||
| 439 | /// { | ||
| 440 | /// ... | ||
| 441 | /// } | ||
| 442 | /// | ||
| 443 | /// ... | ||
| 444 | /// }; | ||
| 445 | /// | ||
| 446 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 447 | /// const std::string& instanceID, | ||
| 448 | /// KODI_HANDLE instance, | ||
| 449 | /// const std::string& version, | ||
| 450 | /// KODI_HANDLE& addonInstance) | ||
| 451 | /// { | ||
| 452 | /// kodi::Log(ADDON_LOG_INFO, "Creating my visualization"); | ||
| 453 | /// addonInstance = new CMyVisualization(instance, version); | ||
| 454 | /// return ADDON_STATUS_OK; | ||
| 455 | /// } | ||
| 456 | /// ~~~~~~~~~~~~~ | ||
| 457 | /// | ||
| 458 | explicit CInstanceVisualization(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 459 | : IAddonInstance(ADDON_INSTANCE_VISUALIZATION, | ||
| 460 | !kodiVersion.empty() ? kodiVersion | ||
| 461 | : GetKodiTypeVersion(ADDON_INSTANCE_VISUALIZATION)) | ||
| 462 | { | ||
| 463 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 464 | throw std::logic_error("kodi::addon::CInstanceVisualization: Creation of multiple together " | ||
| 465 | "with single instance way is not allowed!"); | ||
| 466 | |||
| 467 | SetAddonStruct(instance); | ||
| 468 | } | ||
| 469 | //---------------------------------------------------------------------------- | ||
| 470 | |||
| 471 | //============================================================================ | ||
| 472 | /// @ingroup cpp_kodi_addon_visualization | ||
| 473 | /// @brief Destructor. | ||
| 474 | /// | ||
| 475 | ~CInstanceVisualization() override = default; | ||
| 476 | //---------------------------------------------------------------------------- | ||
| 477 | |||
| 478 | //============================================================================ | ||
| 479 | /// @ingroup cpp_kodi_addon_visualization | ||
| 480 | /// @brief Used to notify the visualization that a new song has been started. | ||
| 481 | /// | ||
| 482 | /// @param[in] channels Number of channels in the stream | ||
| 483 | /// @param[in] samplesPerSec Samples per second of stream | ||
| 484 | /// @param[in] bitsPerSample Number of bits in one sample | ||
| 485 | /// @param[in] songName The name of the currently-playing song | ||
| 486 | /// @return true if start successful done | ||
| 487 | /// | ||
| 488 | virtual bool Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) | ||
| 489 | { | ||
| 490 | return true; | ||
| 491 | } | ||
| 492 | //---------------------------------------------------------------------------- | ||
| 493 | |||
| 494 | //============================================================================ | ||
| 495 | /// @ingroup cpp_kodi_addon_visualization | ||
| 496 | /// @brief Used to inform the visualization that the rendering control was | ||
| 497 | /// stopped. | ||
| 498 | /// | ||
| 499 | virtual void Stop() {} | ||
| 500 | //---------------------------------------------------------------------------- | ||
| 501 | |||
| 502 | //============================================================================ | ||
| 503 | /// @ingroup cpp_kodi_addon_visualization | ||
| 504 | /// @brief Pass audio data to the visualization. | ||
| 505 | /// | ||
| 506 | /// @param[in] audioData The raw audio data | ||
| 507 | /// @param[in] audioDataLength Length of the audioData array | ||
| 508 | /// @param[in] freqData The [FFT](https://en.wikipedia.org/wiki/Fast_Fourier_transform) | ||
| 509 | /// of the audio data | ||
| 510 | /// @param[in] freqDataLength Length of frequency data array | ||
| 511 | /// | ||
| 512 | /// Values **freqData** and **freqDataLength** are used if GetInfo() returns | ||
| 513 | /// true for the `wantsFreq` parameter. Otherwise, **freqData** is set to | ||
| 514 | /// `nullptr` and **freqDataLength** is `0`. | ||
| 515 | /// | ||
| 516 | virtual void AudioData(const float* audioData, | ||
| 517 | int audioDataLength, | ||
| 518 | float* freqData, | ||
| 519 | int freqDataLength) | ||
| 520 | { | ||
| 521 | } | ||
| 522 | //---------------------------------------------------------------------------- | ||
| 523 | |||
| 524 | //============================================================================ | ||
| 525 | /// @ingroup cpp_kodi_addon_visualization | ||
| 526 | /// @brief Used to inform Kodi that the rendered region is dirty and need an | ||
| 527 | /// update. | ||
| 528 | /// | ||
| 529 | /// @return True if dirty | ||
| 530 | /// | ||
| 531 | virtual bool IsDirty() { return true; } | ||
| 532 | //---------------------------------------------------------------------------- | ||
| 533 | |||
| 534 | //============================================================================ | ||
| 535 | /// @ingroup cpp_kodi_addon_visualization | ||
| 536 | /// @brief Used to indicate when the add-on should render. | ||
| 537 | /// | ||
| 538 | virtual void Render() {} | ||
| 539 | //---------------------------------------------------------------------------- | ||
| 540 | |||
| 541 | //============================================================================ | ||
| 542 | /// @ingroup cpp_kodi_addon_visualization | ||
| 543 | /// @brief Used to get the number of buffers from the current visualization. | ||
| 544 | /// | ||
| 545 | /// @param[out] wantsFreq Indicates whether the add-on wants FFT data. If set | ||
| 546 | /// to true, the **freqData** and **freqDataLength** | ||
| 547 | /// parameters of @ref AudioData() are used | ||
| 548 | /// @param[out] syncDelay The number of buffers to delay before calling | ||
| 549 | /// @ref AudioData() | ||
| 550 | /// | ||
| 551 | /// @note If this function is not implemented, it will default to | ||
| 552 | /// `wantsFreq` = false and `syncDelay` = 0. | ||
| 553 | /// | ||
| 554 | virtual void GetInfo(bool& wantsFreq, int& syncDelay) | ||
| 555 | { | ||
| 556 | wantsFreq = false; | ||
| 557 | syncDelay = 0; | ||
| 558 | } | ||
| 559 | //---------------------------------------------------------------------------- | ||
| 560 | |||
| 561 | //============================================================================ | ||
| 562 | /// @ingroup cpp_kodi_addon_visualization | ||
| 563 | /// @brief Used to get a list of visualization presets the user can select. | ||
| 564 | /// from | ||
| 565 | /// | ||
| 566 | /// @param[out] presets The vector list containing the names of presets that | ||
| 567 | /// the user can select | ||
| 568 | /// @return Return true if successful, or false if there are no presets to | ||
| 569 | /// choose from | ||
| 570 | /// | ||
| 571 | virtual bool GetPresets(std::vector<std::string>& presets) { return false; } | ||
| 572 | //---------------------------------------------------------------------------- | ||
| 573 | |||
| 574 | //============================================================================ | ||
| 575 | /// @ingroup cpp_kodi_addon_visualization | ||
| 576 | /// @brief Get the index of the current preset. | ||
| 577 | /// | ||
| 578 | /// @return Index number of the current preset | ||
| 579 | /// | ||
| 580 | virtual int GetActivePreset() { return -1; } | ||
| 581 | //---------------------------------------------------------------------------- | ||
| 582 | |||
| 583 | //============================================================================ | ||
| 584 | /// @ingroup cpp_kodi_addon_visualization | ||
| 585 | /// @brief Check if the add-on is locked to the current preset. | ||
| 586 | /// | ||
| 587 | /// @return True if locked to the current preset | ||
| 588 | /// | ||
| 589 | virtual bool IsLocked() { return false; } | ||
| 590 | //---------------------------------------------------------------------------- | ||
| 591 | |||
| 592 | //============================================================================ | ||
| 593 | /// @ingroup cpp_kodi_addon_visualization | ||
| 594 | /// @brief Load the previous visualization preset. | ||
| 595 | /// | ||
| 596 | /// @return Return true if the previous preset was loaded | ||
| 597 | /// | ||
| 598 | virtual bool PrevPreset() { return false; } | ||
| 599 | //---------------------------------------------------------------------------- | ||
| 600 | |||
| 601 | //============================================================================ | ||
| 602 | /// @ingroup cpp_kodi_addon_visualization | ||
| 603 | /// @brief Load the next visualization preset. | ||
| 604 | /// | ||
| 605 | /// @return Return true if the next preset was loaded | ||
| 606 | /// | ||
| 607 | virtual bool NextPreset() { return false; } | ||
| 608 | //---------------------------------------------------------------------------- | ||
| 609 | |||
| 610 | //============================================================================ | ||
| 611 | /// @ingroup cpp_kodi_addon_visualization | ||
| 612 | /// @brief Load a visualization preset. | ||
| 613 | /// | ||
| 614 | /// This function is called after a new preset is selected. | ||
| 615 | /// | ||
| 616 | /// @param[in] select Preset index to use | ||
| 617 | /// @return Return true if the preset is loaded | ||
| 618 | /// | ||
| 619 | virtual bool LoadPreset(int select) { return false; } | ||
| 620 | //---------------------------------------------------------------------------- | ||
| 621 | |||
| 622 | //============================================================================ | ||
| 623 | /// @ingroup cpp_kodi_addon_visualization | ||
| 624 | /// @brief Switch to a new random preset. | ||
| 625 | /// | ||
| 626 | /// @return Return true if a random preset was loaded | ||
| 627 | /// | ||
| 628 | virtual bool RandomPreset() { return false; } | ||
| 629 | //---------------------------------------------------------------------------- | ||
| 630 | |||
| 631 | //============================================================================ | ||
| 632 | /// @ingroup cpp_kodi_addon_visualization | ||
| 633 | /// @brief Lock the current visualization preset, preventing it from changing. | ||
| 634 | /// | ||
| 635 | /// @param[in] lockUnlock If set to true, the preset should be locked | ||
| 636 | /// @return Return true if the current preset is locked | ||
| 637 | /// | ||
| 638 | virtual bool LockPreset(bool lockUnlock) { return false; } | ||
| 639 | //---------------------------------------------------------------------------- | ||
| 640 | |||
| 641 | //============================================================================ | ||
| 642 | /// @ingroup cpp_kodi_addon_visualization | ||
| 643 | /// @brief Used to increase/decrease the visualization preset rating. | ||
| 644 | /// | ||
| 645 | /// @param[in] plusMinus If set to true the rating is increased, otherwise | ||
| 646 | /// decreased | ||
| 647 | /// @return Return true if the rating is modified | ||
| 648 | /// | ||
| 649 | virtual bool RatePreset(bool plusMinus) { return false; } | ||
| 650 | //---------------------------------------------------------------------------- | ||
| 651 | |||
| 652 | //============================================================================ | ||
| 653 | /// @ingroup cpp_kodi_addon_visualization | ||
| 654 | /// @brief Inform the visualization of the current album art image. | ||
| 655 | /// | ||
| 656 | /// @param[in] albumart Path to the current album art image | ||
| 657 | /// @return Return true if the image is used | ||
| 658 | /// | ||
| 659 | virtual bool UpdateAlbumart(std::string albumart) { return false; } | ||
| 660 | //---------------------------------------------------------------------------- | ||
| 661 | |||
| 662 | //============================================================================ | ||
| 663 | /// @ingroup cpp_kodi_addon_visualization | ||
| 664 | /// @brief Inform the visualization of the current track's tag information. | ||
| 665 | /// | ||
| 666 | /// @param[in] track Visualization track information structure | ||
| 667 | /// @return Return true if the track information is used | ||
| 668 | /// | ||
| 669 | /// -------------------------------------------------------------------------- | ||
| 670 | /// | ||
| 671 | /// @copydetails cpp_kodi_addon_visualization_Defs_VisualizationTrack_Help | ||
| 672 | /// | ||
| 673 | ///------------------------------------------------------------------------- | ||
| 674 | /// | ||
| 675 | /// **Example:** | ||
| 676 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 677 | /// | ||
| 678 | /// #include <kodi/addon-instance/Visualization.h> | ||
| 679 | /// | ||
| 680 | /// class CMyVisualization : public kodi::addon::CInstanceVisualization | ||
| 681 | /// { | ||
| 682 | /// public: | ||
| 683 | /// CMyVisualization(KODI_HANDLE instance, const std::string& version); | ||
| 684 | /// | ||
| 685 | /// ... | ||
| 686 | /// | ||
| 687 | /// private: | ||
| 688 | /// kodi::addon::VisualizationTrack m_runningTrack; | ||
| 689 | /// }; | ||
| 690 | /// | ||
| 691 | /// bool CMyVisualization::UpdateTrack(const kodi::addon::VisualizationTrack& track) | ||
| 692 | /// { | ||
| 693 | /// m_runningTrack = track; | ||
| 694 | /// return true; | ||
| 695 | /// } | ||
| 696 | /// | ||
| 697 | /// ~~~~~~~~~~~~~ | ||
| 698 | /// | ||
| 699 | virtual bool UpdateTrack(const kodi::addon::VisualizationTrack& track) { return false; } | ||
| 700 | //---------------------------------------------------------------------------- | ||
| 701 | |||
| 702 | //============================================================================ | ||
| 703 | /// @defgroup cpp_kodi_addon_visualization_CB Information functions | ||
| 704 | /// @ingroup cpp_kodi_addon_visualization | ||
| 705 | /// @brief **To get info about the device, display and several other parts**\n | ||
| 706 | /// These are functions to query any values or to transfer them to Kodi. | ||
| 707 | /// | ||
| 708 | ///@{ | ||
| 709 | |||
| 710 | //============================================================================ | ||
| 711 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 712 | /// @brief To transfer available presets on addon. | ||
| 713 | /// | ||
| 714 | /// Used if @ref GetPresets not possible to use, e.g. where available presets | ||
| 715 | /// are only known during @ref Start call. | ||
| 716 | /// | ||
| 717 | /// @param[in] presets List to store available presets. | ||
| 718 | /// | ||
| 719 | /// @note The function should only be called once, if possible | ||
| 720 | /// | ||
| 721 | inline void TransferPresets(const std::vector<std::string>& presets) | ||
| 722 | { | ||
| 723 | m_instanceData->toKodi->clear_presets(m_instanceData->toKodi->kodiInstance); | ||
| 724 | for (auto it : presets) | ||
| 725 | m_instanceData->toKodi->transfer_preset(m_instanceData->toKodi->kodiInstance, it.c_str()); | ||
| 726 | } | ||
| 727 | //---------------------------------------------------------------------------- | ||
| 728 | |||
| 729 | //============================================================================ | ||
| 730 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 731 | /// @brief Device that represents the display adapter. | ||
| 732 | /// | ||
| 733 | /// @return A pointer to the used device with @ref cpp_kodi_Defs_HardwareContext "HardwareContext" | ||
| 734 | /// | ||
| 735 | /// @note This is only available on **DirectX**, It us unused (`nullptr`) on | ||
| 736 | /// **OpenGL** | ||
| 737 | /// | ||
| 738 | ///------------------------------------------------------------------------- | ||
| 739 | /// | ||
| 740 | /// **Example:** | ||
| 741 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 742 | /// #include <d3d11_1.h> | ||
| 743 | /// .. | ||
| 744 | /// // Note: Device() there is used inside addon child class about | ||
| 745 | /// // kodi::addon::CInstanceVisualization | ||
| 746 | /// ID3D11DeviceContext1* context = static_cast<ID3D11DeviceContext1*>(kodi::addon::CInstanceVisualization::Device()); | ||
| 747 | /// .. | ||
| 748 | /// ~~~~~~~~~~~~~ | ||
| 749 | /// | ||
| 750 | inline kodi::HardwareContext Device() { return m_instanceData->props->device; } | ||
| 751 | //---------------------------------------------------------------------------- | ||
| 752 | |||
| 753 | //============================================================================ | ||
| 754 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 755 | /// @brief Returns the X position of the rendering window. | ||
| 756 | /// | ||
| 757 | /// @return The X position, in pixels | ||
| 758 | /// | ||
| 759 | inline int X() { return m_instanceData->props->x; } | ||
| 760 | //---------------------------------------------------------------------------- | ||
| 761 | |||
| 762 | //============================================================================ | ||
| 763 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 764 | /// @brief Returns the Y position of the rendering window. | ||
| 765 | /// | ||
| 766 | /// @return The Y position, in pixels | ||
| 767 | /// | ||
| 768 | inline int Y() { return m_instanceData->props->y; } | ||
| 769 | //---------------------------------------------------------------------------- | ||
| 770 | |||
| 771 | //============================================================================ | ||
| 772 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 773 | /// @brief Returns the width of the rendering window. | ||
| 774 | /// | ||
| 775 | /// @return The width, in pixels | ||
| 776 | /// | ||
| 777 | inline int Width() { return m_instanceData->props->width; } | ||
| 778 | //---------------------------------------------------------------------------- | ||
| 779 | |||
| 780 | //============================================================================ | ||
| 781 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 782 | /// @brief Returns the height of the rendering window. | ||
| 783 | /// | ||
| 784 | /// @return The height, in pixels | ||
| 785 | /// | ||
| 786 | inline int Height() { return m_instanceData->props->height; } | ||
| 787 | //---------------------------------------------------------------------------- | ||
| 788 | |||
| 789 | //============================================================================ | ||
| 790 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 791 | /// @brief Pixel aspect ratio (often abbreviated PAR) is a ratio that | ||
| 792 | /// describes how the width of a pixel compares to the height of that pixel. | ||
| 793 | /// | ||
| 794 | /// @return The pixel aspect ratio used by the display | ||
| 795 | /// | ||
| 796 | inline float PixelRatio() { return m_instanceData->props->pixelRatio; } | ||
| 797 | //---------------------------------------------------------------------------- | ||
| 798 | |||
| 799 | //============================================================================ | ||
| 800 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 801 | /// @brief Used to get the name of the add-on defined in `addon.xml`. | ||
| 802 | /// | ||
| 803 | /// @return The add-on name | ||
| 804 | /// | ||
| 805 | inline std::string Name() { return m_instanceData->props->name; } | ||
| 806 | //---------------------------------------------------------------------------- | ||
| 807 | |||
| 808 | //============================================================================ | ||
| 809 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 810 | /// @brief Used to get the full path where the add-on is installed. | ||
| 811 | /// | ||
| 812 | /// @return The add-on installation path | ||
| 813 | /// | ||
| 814 | inline std::string Presets() { return m_instanceData->props->presets; } | ||
| 815 | //---------------------------------------------------------------------------- | ||
| 816 | |||
| 817 | //============================================================================ | ||
| 818 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 819 | /// @brief Used to get the full path to the add-on's user profile. | ||
| 820 | /// | ||
| 821 | /// @note The trailing folder (consisting of the add-on's ID) is not created | ||
| 822 | /// by default. If it is needed, you must call kodi::vfs::CreateDirectory() | ||
| 823 | /// to create the folder. | ||
| 824 | /// | ||
| 825 | /// @return Path to the user profile | ||
| 826 | /// | ||
| 827 | inline std::string Profile() { return m_instanceData->props->profile; } | ||
| 828 | //---------------------------------------------------------------------------- | ||
| 829 | |||
| 830 | ///@} | ||
| 831 | |||
| 832 | private: | ||
| 833 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 834 | { | ||
| 835 | if (instance == nullptr) | ||
| 836 | throw std::logic_error("kodi::addon::CInstanceVisualization: Null pointer instance passed."); | ||
| 837 | |||
| 838 | m_instanceData = static_cast<AddonInstance_Visualization*>(instance); | ||
| 839 | m_instanceData->toAddon->addonInstance = this; | ||
| 840 | m_instanceData->toAddon->start = ADDON_Start; | ||
| 841 | m_instanceData->toAddon->stop = ADDON_Stop; | ||
| 842 | m_instanceData->toAddon->audio_data = ADDON_AudioData; | ||
| 843 | m_instanceData->toAddon->is_dirty = ADDON_IsDirty; | ||
| 844 | m_instanceData->toAddon->render = ADDON_Render; | ||
| 845 | m_instanceData->toAddon->get_info = ADDON_GetInfo; | ||
| 846 | m_instanceData->toAddon->prev_preset = ADDON_PrevPreset; | ||
| 847 | m_instanceData->toAddon->next_preset = ADDON_NextPreset; | ||
| 848 | m_instanceData->toAddon->load_preset = ADDON_LoadPreset; | ||
| 849 | m_instanceData->toAddon->random_preset = ADDON_RandomPreset; | ||
| 850 | m_instanceData->toAddon->lock_preset = ADDON_LockPreset; | ||
| 851 | m_instanceData->toAddon->rate_preset = ADDON_RatePreset; | ||
| 852 | m_instanceData->toAddon->update_albumart = ADDON_UpdateAlbumart; | ||
| 853 | m_instanceData->toAddon->update_track = ADDON_UpdateTrack; | ||
| 854 | m_instanceData->toAddon->get_presets = ADDON_GetPresets; | ||
| 855 | m_instanceData->toAddon->get_active_preset = ADDON_GetActivePreset; | ||
| 856 | m_instanceData->toAddon->is_locked = ADDON_IsLocked; | ||
| 857 | } | ||
| 858 | |||
| 859 | inline static bool ADDON_Start(const AddonInstance_Visualization* addon, | ||
| 860 | int channels, | ||
| 861 | int samplesPerSec, | ||
| 862 | int bitsPerSample, | ||
| 863 | const char* songName) | ||
| 864 | { | ||
| 865 | CInstanceVisualization* thisClass = | ||
| 866 | static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance); | ||
| 867 | thisClass->m_renderHelper = kodi::gui::GetRenderHelper(); | ||
| 868 | return thisClass->Start(channels, samplesPerSec, bitsPerSample, songName); | ||
| 869 | } | ||
| 870 | |||
| 871 | inline static void ADDON_Stop(const AddonInstance_Visualization* addon) | ||
| 872 | { | ||
| 873 | CInstanceVisualization* thisClass = | ||
| 874 | static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance); | ||
| 875 | thisClass->Stop(); | ||
| 876 | thisClass->m_renderHelper = nullptr; | ||
| 877 | } | ||
| 878 | |||
| 879 | inline static void ADDON_AudioData(const AddonInstance_Visualization* addon, | ||
| 880 | const float* audioData, | ||
| 881 | int audioDataLength, | ||
| 882 | float* freqData, | ||
| 883 | int freqDataLength) | ||
| 884 | { | ||
| 885 | static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance) | ||
| 886 | ->AudioData(audioData, audioDataLength, freqData, freqDataLength); | ||
| 887 | } | ||
| 888 | |||
| 889 | inline static bool ADDON_IsDirty(const AddonInstance_Visualization* addon) | ||
| 890 | { | ||
| 891 | return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)->IsDirty(); | ||
| 892 | } | ||
| 893 | |||
| 894 | inline static void ADDON_Render(const AddonInstance_Visualization* addon) | ||
| 895 | { | ||
| 896 | CInstanceVisualization* thisClass = | ||
| 897 | static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance); | ||
| 898 | if (!thisClass->m_renderHelper) | ||
| 899 | return; | ||
| 900 | thisClass->m_renderHelper->Begin(); | ||
| 901 | thisClass->Render(); | ||
| 902 | thisClass->m_renderHelper->End(); | ||
| 903 | } | ||
| 904 | |||
| 905 | inline static void ADDON_GetInfo(const AddonInstance_Visualization* addon, VIS_INFO* info) | ||
| 906 | { | ||
| 907 | static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance) | ||
| 908 | ->GetInfo(info->bWantsFreq, info->iSyncDelay); | ||
| 909 | } | ||
| 910 | |||
| 911 | inline static unsigned int ADDON_GetPresets(const AddonInstance_Visualization* addon) | ||
| 912 | { | ||
| 913 | CInstanceVisualization* thisClass = | ||
| 914 | static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance); | ||
| 915 | std::vector<std::string> presets; | ||
| 916 | if (thisClass->GetPresets(presets)) | ||
| 917 | { | ||
| 918 | for (auto it : presets) | ||
| 919 | thisClass->m_instanceData->toKodi->transfer_preset(addon->toKodi->kodiInstance, it.c_str()); | ||
| 920 | } | ||
| 921 | |||
| 922 | return static_cast<unsigned int>(presets.size()); | ||
| 923 | } | ||
| 924 | |||
| 925 | inline static int ADDON_GetActivePreset(const AddonInstance_Visualization* addon) | ||
| 926 | { | ||
| 927 | return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)->GetActivePreset(); | ||
| 928 | } | ||
| 929 | |||
| 930 | inline static bool ADDON_PrevPreset(const AddonInstance_Visualization* addon) | ||
| 931 | { | ||
| 932 | return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)->PrevPreset(); | ||
| 933 | } | ||
| 934 | |||
| 935 | inline static bool ADDON_NextPreset(const AddonInstance_Visualization* addon) | ||
| 936 | { | ||
| 937 | return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)->NextPreset(); | ||
| 938 | } | ||
| 939 | |||
| 940 | inline static bool ADDON_LoadPreset(const AddonInstance_Visualization* addon, int select) | ||
| 941 | |||
| 942 | { | ||
| 943 | return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)->LoadPreset(select); | ||
| 944 | } | ||
| 945 | |||
| 946 | inline static bool ADDON_RandomPreset(const AddonInstance_Visualization* addon) | ||
| 947 | { | ||
| 948 | return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)->RandomPreset(); | ||
| 949 | } | ||
| 950 | |||
| 951 | inline static bool ADDON_LockPreset(const AddonInstance_Visualization* addon) | ||
| 952 | { | ||
| 953 | CInstanceVisualization* thisClass = | ||
| 954 | static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance); | ||
| 955 | thisClass->m_presetLockedByUser = !thisClass->m_presetLockedByUser; | ||
| 956 | return thisClass->LockPreset(thisClass->m_presetLockedByUser); | ||
| 957 | } | ||
| 958 | |||
| 959 | inline static bool ADDON_RatePreset(const AddonInstance_Visualization* addon, bool plus_minus) | ||
| 960 | { | ||
| 961 | return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance) | ||
| 962 | ->RatePreset(plus_minus); | ||
| 963 | } | ||
| 964 | |||
| 965 | inline static bool ADDON_IsLocked(const AddonInstance_Visualization* addon) | ||
| 966 | { | ||
| 967 | return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)->IsLocked(); | ||
| 968 | } | ||
| 969 | |||
| 970 | inline static bool ADDON_UpdateAlbumart(const AddonInstance_Visualization* addon, | ||
| 971 | const char* albumart) | ||
| 972 | { | ||
| 973 | return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance) | ||
| 974 | ->UpdateAlbumart(albumart); | ||
| 975 | } | ||
| 976 | |||
| 977 | inline static bool ADDON_UpdateTrack(const AddonInstance_Visualization* addon, | ||
| 978 | const VIS_TRACK* track) | ||
| 979 | { | ||
| 980 | VisualizationTrack cppTrack(track); | ||
| 981 | return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance) | ||
| 982 | ->UpdateTrack(cppTrack); | ||
| 983 | } | ||
| 984 | |||
| 985 | std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper; | ||
| 986 | bool m_presetLockedByUser = false; | ||
| 987 | AddonInstance_Visualization* m_instanceData; | ||
| 988 | }; | ||
| 989 | |||
| 990 | } /* namespace addon */ | ||
| 991 | } /* namespace kodi */ | ||
| 992 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/CMakeLists.txt new file mode 100644 index 0000000..d6fba69 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/CMakeLists.txt | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | set(HEADERS PeripheralUtils.h) | ||
| 2 | |||
| 3 | if(NOT ENABLE_STATIC_LIBS) | ||
| 4 | core_add_library(addons_kodi-dev-kit_include_kodi_addon-instance_peripheral) | ||
| 5 | endif() | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h new file mode 100644 index 0000000..febaeb9 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h | |||
| @@ -0,0 +1,1277 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../AddonBase.h" | ||
| 12 | #include "../../c-api/addon-instance/peripheral.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | #include <array> // Requires c++11 | ||
| 17 | #include <cstring> | ||
| 18 | #include <memory> | ||
| 19 | #include <string> | ||
| 20 | #include <utility> | ||
| 21 | #include <vector> | ||
| 22 | |||
| 23 | #define PERIPHERAL_SAFE_DELETE(x) \ | ||
| 24 | do \ | ||
| 25 | { \ | ||
| 26 | delete (x); \ | ||
| 27 | (x) = NULL; \ | ||
| 28 | } while (0) | ||
| 29 | #define PERIPHERAL_SAFE_DELETE_ARRAY(x) \ | ||
| 30 | do \ | ||
| 31 | { \ | ||
| 32 | delete[](x); \ | ||
| 33 | (x) = NULL; \ | ||
| 34 | } while (0) | ||
| 35 | |||
| 36 | namespace kodi | ||
| 37 | { | ||
| 38 | namespace addon | ||
| 39 | { | ||
| 40 | |||
| 41 | class CInstancePeripheral; | ||
| 42 | |||
| 43 | /*! | ||
| 44 | * Utility class to manipulate arrays of peripheral types. | ||
| 45 | */ | ||
| 46 | template<class THE_CLASS, typename THE_STRUCT> | ||
| 47 | class PeripheralVector | ||
| 48 | { | ||
| 49 | public: | ||
| 50 | static void ToStructs(const std::vector<THE_CLASS>& vecObjects, THE_STRUCT** pStructs) | ||
| 51 | { | ||
| 52 | if (!pStructs) | ||
| 53 | return; | ||
| 54 | |||
| 55 | if (vecObjects.empty()) | ||
| 56 | { | ||
| 57 | *pStructs = NULL; | ||
| 58 | } | ||
| 59 | else | ||
| 60 | { | ||
| 61 | (*pStructs) = new THE_STRUCT[vecObjects.size()]; | ||
| 62 | for (unsigned int i = 0; i < vecObjects.size(); i++) | ||
| 63 | vecObjects.at(i).ToStruct((*pStructs)[i]); | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | static void ToStructs(const std::vector<THE_CLASS*>& vecObjects, THE_STRUCT** pStructs) | ||
| 68 | { | ||
| 69 | if (!pStructs) | ||
| 70 | return; | ||
| 71 | |||
| 72 | if (vecObjects.empty()) | ||
| 73 | { | ||
| 74 | *pStructs = NULL; | ||
| 75 | } | ||
| 76 | else | ||
| 77 | { | ||
| 78 | *pStructs = new THE_STRUCT[vecObjects.size()]; | ||
| 79 | for (unsigned int i = 0; i < vecObjects.size(); i++) | ||
| 80 | vecObjects.at(i)->ToStruct((*pStructs)[i]); | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | static void ToStructs(const std::vector<std::shared_ptr<THE_CLASS>>& vecObjects, | ||
| 85 | THE_STRUCT** pStructs) | ||
| 86 | { | ||
| 87 | if (!pStructs) | ||
| 88 | return; | ||
| 89 | |||
| 90 | if (vecObjects.empty()) | ||
| 91 | { | ||
| 92 | *pStructs = NULL; | ||
| 93 | } | ||
| 94 | else | ||
| 95 | { | ||
| 96 | *pStructs = new THE_STRUCT[vecObjects.size()]; | ||
| 97 | for (unsigned int i = 0; i < vecObjects.size(); i++) | ||
| 98 | vecObjects.at(i)->ToStruct((*pStructs)[i]); | ||
| 99 | } | ||
| 100 | } | ||
| 101 | |||
| 102 | static void FreeStructs(unsigned int structCount, THE_STRUCT* structs) | ||
| 103 | { | ||
| 104 | if (structs) | ||
| 105 | { | ||
| 106 | for (unsigned int i = 0; i < structCount; i++) | ||
| 107 | THE_CLASS::FreeStruct(structs[i]); | ||
| 108 | } | ||
| 109 | PERIPHERAL_SAFE_DELETE_ARRAY(structs); | ||
| 110 | } | ||
| 111 | }; | ||
| 112 | |||
| 113 | //============================================================================== | ||
| 114 | /// @defgroup cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities class PeripheralCapabilities | ||
| 115 | /// @ingroup cpp_kodi_addon_peripheral_Defs_General | ||
| 116 | /// @brief **%Peripheral add-on capabilities**\n | ||
| 117 | /// This class is needed to tell Kodi which options are supported on the addon. | ||
| 118 | /// | ||
| 119 | /// If a capability is set to **true**, then the corresponding methods from | ||
| 120 | /// @ref cpp_kodi_addon_peripheral "kodi::addon::CInstancePeripheral" need to be | ||
| 121 | /// implemented. | ||
| 122 | /// | ||
| 123 | /// As default them all set to **false**. | ||
| 124 | /// | ||
| 125 | /// Used on @ref kodi::addon::CInstancePeripheral::GetCapabilities(). | ||
| 126 | /// | ||
| 127 | /// ---------------------------------------------------------------------------- | ||
| 128 | /// | ||
| 129 | /// @copydetails cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities_Help | ||
| 130 | /// | ||
| 131 | ///@{ | ||
| 132 | class PeripheralCapabilities : public CStructHdl<PeripheralCapabilities, PERIPHERAL_CAPABILITIES> | ||
| 133 | { | ||
| 134 | /*! \cond PRIVATE */ | ||
| 135 | friend class CInstancePeripheral; | ||
| 136 | /*! \endcond */ | ||
| 137 | |||
| 138 | public: | ||
| 139 | /*! \cond PRIVATE */ | ||
| 140 | PeripheralCapabilities() | ||
| 141 | { | ||
| 142 | m_cStructure->provides_joysticks = false; | ||
| 143 | m_cStructure->provides_joystick_rumble = false; | ||
| 144 | m_cStructure->provides_joystick_power_off = false; | ||
| 145 | m_cStructure->provides_buttonmaps = false; | ||
| 146 | } | ||
| 147 | |||
| 148 | PeripheralCapabilities(const PeripheralCapabilities& data) : CStructHdl(data) {} | ||
| 149 | /*! \endcond */ | ||
| 150 | |||
| 151 | /// @defgroup cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities_Help Value Help | ||
| 152 | /// @ingroup cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities | ||
| 153 | /// ---------------------------------------------------------------------------- | ||
| 154 | /// | ||
| 155 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities :</b> | ||
| 156 | /// | Name | Type | Set call | Get call | ||
| 157 | /// |------|------|----------|---------- | ||
| 158 | /// | **Provides joysticks** | `boolean` | @ref PeripheralCapabilities::SetProvidesJoysticks "SetProvidesJoysticks" | @ref PeripheralCapabilities::GetProvidesJoysticks "GetProvidesJoysticks" | ||
| 159 | /// | **Provides joystick rumble** | `boolean` | @ref PeripheralCapabilities::SetProvidesJoystickRumble "SetProvidesJoystickRumble" | @ref PeripheralCapabilities::GetProvidesJoystickRumble "GetProvidesJoystickRumble" | ||
| 160 | /// | **Provides joystick power off** | `boolean` | @ref PeripheralCapabilities::SetProvidesJoystickPowerOff "SetProvidesJoystickPowerOff" | @ref PeripheralCapabilities::GetProvidesJoystickPowerOff "GetProvidesJoystickPowerOff" | ||
| 161 | /// | **Provides button maps** | `boolean` | @ref PeripheralCapabilities::SetProvidesButtonmaps "SetProvidesButtonmaps" | @ref PeripheralCapabilities::GetProvidesButtonmaps "GetProvidesButtonmaps" | ||
| 162 | |||
| 163 | /// @addtogroup cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities | ||
| 164 | ///@{ | ||
| 165 | |||
| 166 | /// @brief Set true if the add-on provides joysticks. | ||
| 167 | void SetProvidesJoysticks(bool providesJoysticks) | ||
| 168 | { | ||
| 169 | m_cStructure->provides_joysticks = providesJoysticks; | ||
| 170 | } | ||
| 171 | |||
| 172 | /// @brief To get with @ref SetProvidesJoysticks changed values. | ||
| 173 | bool GetProvidesJoysticks() const { return m_cStructure->provides_joysticks; } | ||
| 174 | |||
| 175 | /// @brief Set true if the add-on provides joystick rumble. | ||
| 176 | void SetProvidesJoystickRumble(bool providesJoystickRumble) | ||
| 177 | { | ||
| 178 | m_cStructure->provides_joystick_rumble = providesJoystickRumble; | ||
| 179 | } | ||
| 180 | |||
| 181 | /// @brief To get with @ref SetProvidesJoystickRumble changed values. | ||
| 182 | bool GetProvidesJoystickRumble() const { return m_cStructure->provides_joystick_rumble; } | ||
| 183 | |||
| 184 | /// @brief Set true if the add-on provides power off about joystick. | ||
| 185 | void SetProvidesJoystickPowerOff(bool providesJoystickPowerOff) | ||
| 186 | { | ||
| 187 | m_cStructure->provides_joystick_power_off = providesJoystickPowerOff; | ||
| 188 | } | ||
| 189 | |||
| 190 | /// @brief To get with @ref SetProvidesJoystickPowerOff changed values. | ||
| 191 | bool GetProvidesJoystickPowerOff() const { return m_cStructure->provides_joystick_power_off; } | ||
| 192 | |||
| 193 | /// @brief Set true if the add-on provides button maps. | ||
| 194 | void SetProvidesButtonmaps(bool providesButtonmaps) | ||
| 195 | { | ||
| 196 | m_cStructure->provides_buttonmaps = providesButtonmaps; | ||
| 197 | } | ||
| 198 | |||
| 199 | /// @brief To get with @ref SetProvidesButtonmaps changed values. | ||
| 200 | bool GetProvidesButtonmaps() const { return m_cStructure->provides_buttonmaps; } | ||
| 201 | |||
| 202 | ///@} | ||
| 203 | |||
| 204 | private: | ||
| 205 | PeripheralCapabilities(const PERIPHERAL_CAPABILITIES* data) : CStructHdl(data) {} | ||
| 206 | PeripheralCapabilities(PERIPHERAL_CAPABILITIES* data) : CStructHdl(data) {} | ||
| 207 | }; | ||
| 208 | ///@} | ||
| 209 | //------------------------------------------------------------------------------ | ||
| 210 | |||
| 211 | //============================================================================== | ||
| 212 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral class Peripheral | ||
| 213 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Peripheral | ||
| 214 | /// @brief **Wrapper class providing peripheral information**\n | ||
| 215 | /// Classes can extend %Peripheral to inherit peripheral properties. | ||
| 216 | /// | ||
| 217 | /// Used on @ref kodi::addon::CInstancePeripheral::PerformDeviceScan(). | ||
| 218 | /// | ||
| 219 | /// ---------------------------------------------------------------------------- | ||
| 220 | /// | ||
| 221 | /// @copydetails cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral_Help | ||
| 222 | /// | ||
| 223 | ///@{ | ||
| 224 | class Peripheral | ||
| 225 | { | ||
| 226 | public: | ||
| 227 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral_Help Value Help | ||
| 228 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral | ||
| 229 | /// ---------------------------------------------------------------------------- | ||
| 230 | /// | ||
| 231 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral :</b> | ||
| 232 | /// | Name | Type | Set call | Get call | ||
| 233 | /// |------|------|----------|---------- | ||
| 234 | /// | **%Peripheral type** | @ref PERIPHERAL_TYPE | @ref Peripheral::SetType "SetType" | @ref Peripheral::Type "Type" | ||
| 235 | /// | **%Peripheral name** | `const std::string&` | @ref Peripheral::SetName "SetName" | @ref Peripheral::Name "Name" | ||
| 236 | /// | **%Peripheral vendor id** | `uint16_t` | @ref Peripheral::SetVendorID "SetVendorID" | @ref Peripheral::VendorID "VendorID" | ||
| 237 | /// | **%Peripheral product id** | `uint16_t` | @ref Peripheral::SetProductID "SetProductID" | @ref Peripheral::ProductID "ProductID" | ||
| 238 | /// | **%Peripheral index** | `unsigned int` | @ref Peripheral::SetIndex "SetIndex" | @ref Peripheral::Index "Index" | ||
| 239 | /// | ||
| 240 | /// Further are following included: | ||
| 241 | /// - @ref Peripheral::Peripheral "Peripheral(PERIPHERAL_TYPE type = PERIPHERAL_TYPE_UNKNOWN, const std::string& strName = \"\")": Class constructor. | ||
| 242 | /// - @ref Peripheral::IsVidPidKnown "IsVidPidKnown()": To check VID and PID are known. | ||
| 243 | /// | ||
| 244 | |||
| 245 | /// @addtogroup cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral | ||
| 246 | ///@{ | ||
| 247 | |||
| 248 | /// @brief Constructor. | ||
| 249 | /// | ||
| 250 | /// @param[in] type [optional] Peripheral type, or @ref PERIPHERAL_TYPE_UNKNOWN | ||
| 251 | /// as default | ||
| 252 | /// @param[in] strName [optional] Name of related peripheral | ||
| 253 | Peripheral(PERIPHERAL_TYPE type = PERIPHERAL_TYPE_UNKNOWN, const std::string& strName = "") | ||
| 254 | : m_type(type), m_strName(strName) | ||
| 255 | { | ||
| 256 | } | ||
| 257 | |||
| 258 | /// @brief Destructor. | ||
| 259 | virtual ~Peripheral(void) = default; | ||
| 260 | |||
| 261 | /// @brief Get peripheral type. | ||
| 262 | /// | ||
| 263 | /// @return Type defined with @ref PERIPHERAL_TYPE | ||
| 264 | PERIPHERAL_TYPE Type(void) const { return m_type; } | ||
| 265 | |||
| 266 | /// @brief Get peripheral name. | ||
| 267 | /// | ||
| 268 | /// @return Name string of peripheral | ||
| 269 | const std::string& Name(void) const { return m_strName; } | ||
| 270 | |||
| 271 | /// @brief Get peripheral vendor id. | ||
| 272 | /// | ||
| 273 | /// @return Vendor id | ||
| 274 | uint16_t VendorID(void) const { return m_vendorId; } | ||
| 275 | |||
| 276 | /// @brief Get peripheral product id. | ||
| 277 | /// | ||
| 278 | /// @return Product id | ||
| 279 | uint16_t ProductID(void) const { return m_productId; } | ||
| 280 | |||
| 281 | /// @brief Get peripheral index identifier. | ||
| 282 | /// | ||
| 283 | /// @return Index number | ||
| 284 | unsigned int Index(void) const { return m_index; } | ||
| 285 | |||
| 286 | /// @brief Check VID and PID are known. | ||
| 287 | /// | ||
| 288 | /// @return true if VID and PID are not 0 | ||
| 289 | /// | ||
| 290 | /// @note Derived property: VID and PID are `0x0000` if unknown | ||
| 291 | bool IsVidPidKnown(void) const { return m_vendorId != 0 || m_productId != 0; } | ||
| 292 | |||
| 293 | /// @brief Set peripheral type. | ||
| 294 | /// | ||
| 295 | /// @param[in] type Type to set | ||
| 296 | void SetType(PERIPHERAL_TYPE type) { m_type = type; } | ||
| 297 | |||
| 298 | /// @brief Set peripheral name. | ||
| 299 | /// | ||
| 300 | /// @param[in] strName Name to set | ||
| 301 | void SetName(const std::string& strName) { m_strName = strName; } | ||
| 302 | |||
| 303 | /// @brief Set peripheral vendor id. | ||
| 304 | /// | ||
| 305 | /// @param[in] vendorId Type to set | ||
| 306 | void SetVendorID(uint16_t vendorId) { m_vendorId = vendorId; } | ||
| 307 | |||
| 308 | /// @brief Set peripheral product identifier. | ||
| 309 | /// | ||
| 310 | /// @param[in] productId Type to set | ||
| 311 | void SetProductID(uint16_t productId) { m_productId = productId; } | ||
| 312 | |||
| 313 | /// @brief Set peripheral index. | ||
| 314 | /// | ||
| 315 | /// @param[in] index Type to set | ||
| 316 | void SetIndex(unsigned int index) { m_index = index; } | ||
| 317 | |||
| 318 | ///@} | ||
| 319 | |||
| 320 | explicit Peripheral(const PERIPHERAL_INFO& info) | ||
| 321 | : m_type(info.type), | ||
| 322 | m_strName(info.name ? info.name : ""), | ||
| 323 | m_vendorId(info.vendor_id), | ||
| 324 | m_productId(info.product_id), | ||
| 325 | m_index(info.index) | ||
| 326 | { | ||
| 327 | } | ||
| 328 | |||
| 329 | void ToStruct(PERIPHERAL_INFO& info) const | ||
| 330 | { | ||
| 331 | info.type = m_type; | ||
| 332 | info.name = new char[m_strName.size() + 1]; | ||
| 333 | info.vendor_id = m_vendorId; | ||
| 334 | info.product_id = m_productId; | ||
| 335 | info.index = m_index; | ||
| 336 | |||
| 337 | std::strcpy(info.name, m_strName.c_str()); | ||
| 338 | } | ||
| 339 | |||
| 340 | static void FreeStruct(PERIPHERAL_INFO& info) { PERIPHERAL_SAFE_DELETE_ARRAY(info.name); } | ||
| 341 | |||
| 342 | private: | ||
| 343 | PERIPHERAL_TYPE m_type; | ||
| 344 | std::string m_strName; | ||
| 345 | uint16_t m_vendorId = 0; | ||
| 346 | uint16_t m_productId = 0; | ||
| 347 | unsigned int m_index = 0; | ||
| 348 | }; | ||
| 349 | ///@} | ||
| 350 | //------------------------------------------------------------------------------ | ||
| 351 | |||
| 352 | typedef PeripheralVector<Peripheral, PERIPHERAL_INFO> Peripherals; | ||
| 353 | |||
| 354 | //============================================================================== | ||
| 355 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent class PeripheralEvent | ||
| 356 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Peripheral | ||
| 357 | /// @brief **Wrapper class for %peripheral events**\n | ||
| 358 | /// To handle data of change events between add-on and Kodi. | ||
| 359 | /// | ||
| 360 | /// Used on @ref kodi::addon::CInstancePeripheral::GetEvents() and | ||
| 361 | /// @ref kodi::addon::CInstancePeripheral::SendEvent(). | ||
| 362 | /// | ||
| 363 | /// ---------------------------------------------------------------------------- | ||
| 364 | /// | ||
| 365 | /// @copydetails cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent_Help | ||
| 366 | /// | ||
| 367 | ///@{ | ||
| 368 | class PeripheralEvent | ||
| 369 | { | ||
| 370 | public: | ||
| 371 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent_Help Value Help | ||
| 372 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent | ||
| 373 | /// ---------------------------------------------------------------------------- | ||
| 374 | /// | ||
| 375 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent :</b> | ||
| 376 | /// | Name | Type | Set call | Get call | ||
| 377 | /// |------|------|----------|---------- | ||
| 378 | /// | **%Peripheral event type** | @ref PERIPHERAL_EVENT_TYPE | @ref PeripheralEvent::SetType "SetType" | @ref PeripheralEvent::Type "Type" | ||
| 379 | /// | **%Peripheral index** | `unsigned int` | @ref PeripheralEvent::SetPeripheralIndex "SetPeripheralIndex" | @ref PeripheralEvent::PeripheralIndex "PeripheralIndex" | ||
| 380 | /// | **%Peripheral event driver index** | `unsigned int` | @ref PeripheralEvent::SetDriverIndex "SetDriverIndex" | @ref PeripheralEvent::DriverIndex "DriverIndex" | ||
| 381 | /// | **%Peripheral event button state** | @ref JOYSTICK_STATE_BUTTON | @ref PeripheralEvent::SetButtonState "SetButtonState" | @ref PeripheralEvent::ButtonState "ButtonState" | ||
| 382 | /// | **%Peripheral event hat state** | @ref JOYSTICK_STATE_HAT | @ref PeripheralEvent::SetHatState "SetHatState" | @ref PeripheralEvent::HatState "HatState" | ||
| 383 | /// | **%Peripheral event axis state** | @ref JOYSTICK_STATE_AXIS (`float`) | @ref PeripheralEvent::SetAxisState "SetAxisState" | @ref PeripheralEvent::AxisState "AxisState" | ||
| 384 | /// | **%Peripheral event motor state** | @ref JOYSTICK_STATE_MOTOR (`float`) | @ref PeripheralEvent::SetMotorState "SetMotorState" | @ref PeripheralEvent::MotorState "MotorState" | ||
| 385 | /// | ||
| 386 | /// Further are several class constructors with values included. | ||
| 387 | |||
| 388 | /// @addtogroup cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent | ||
| 389 | ///@{ | ||
| 390 | |||
| 391 | /// @brief Constructor. | ||
| 392 | PeripheralEvent() = default; | ||
| 393 | |||
| 394 | /// @brief Constructor. | ||
| 395 | /// | ||
| 396 | /// @param[in] peripheralIndex %Peripheral index | ||
| 397 | /// @param[in] buttonIndex Button index | ||
| 398 | /// @param[in] state Joystick state button | ||
| 399 | PeripheralEvent(unsigned int peripheralIndex, | ||
| 400 | unsigned int buttonIndex, | ||
| 401 | JOYSTICK_STATE_BUTTON state) | ||
| 402 | : m_type(PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON), | ||
| 403 | m_peripheralIndex(peripheralIndex), | ||
| 404 | m_driverIndex(buttonIndex), | ||
| 405 | m_buttonState(state) | ||
| 406 | { | ||
| 407 | } | ||
| 408 | |||
| 409 | /// @brief Constructor. | ||
| 410 | /// | ||
| 411 | /// @param[in] peripheralIndex %Peripheral index | ||
| 412 | /// @param[in] hatIndex Hat index | ||
| 413 | /// @param[in] state Joystick state hat | ||
| 414 | PeripheralEvent(unsigned int peripheralIndex, unsigned int hatIndex, JOYSTICK_STATE_HAT state) | ||
| 415 | : m_type(PERIPHERAL_EVENT_TYPE_DRIVER_HAT), | ||
| 416 | m_peripheralIndex(peripheralIndex), | ||
| 417 | m_driverIndex(hatIndex), | ||
| 418 | m_hatState(state) | ||
| 419 | { | ||
| 420 | } | ||
| 421 | |||
| 422 | /// @brief Constructor. | ||
| 423 | /// | ||
| 424 | /// @param[in] peripheralIndex %Peripheral index | ||
| 425 | /// @param[in] axisIndex Axis index | ||
| 426 | /// @param[in] state Joystick state axis | ||
| 427 | PeripheralEvent(unsigned int peripheralIndex, unsigned int axisIndex, JOYSTICK_STATE_AXIS state) | ||
| 428 | : m_type(PERIPHERAL_EVENT_TYPE_DRIVER_AXIS), | ||
| 429 | m_peripheralIndex(peripheralIndex), | ||
| 430 | m_driverIndex(axisIndex), | ||
| 431 | m_axisState(state) | ||
| 432 | { | ||
| 433 | } | ||
| 434 | |||
| 435 | /// @brief Get type of event. | ||
| 436 | /// | ||
| 437 | /// @return Type defined with @ref PERIPHERAL_EVENT_TYPE | ||
| 438 | PERIPHERAL_EVENT_TYPE Type(void) const { return m_type; } | ||
| 439 | |||
| 440 | /// @brief Get peripheral index. | ||
| 441 | /// | ||
| 442 | /// @return %Peripheral index number | ||
| 443 | unsigned int PeripheralIndex(void) const { return m_peripheralIndex; } | ||
| 444 | |||
| 445 | /// @brief Get driver index. | ||
| 446 | /// | ||
| 447 | /// @return Driver index number | ||
| 448 | unsigned int DriverIndex(void) const { return m_driverIndex; } | ||
| 449 | |||
| 450 | /// @brief Get button state. | ||
| 451 | /// | ||
| 452 | /// @return Button state as @ref JOYSTICK_STATE_BUTTON | ||
| 453 | JOYSTICK_STATE_BUTTON ButtonState(void) const { return m_buttonState; } | ||
| 454 | |||
| 455 | /// @brief Get hat state. | ||
| 456 | /// | ||
| 457 | /// @return Hat state | ||
| 458 | JOYSTICK_STATE_HAT HatState(void) const { return m_hatState; } | ||
| 459 | |||
| 460 | /// @brief Get axis state. | ||
| 461 | /// | ||
| 462 | /// @return Axis state | ||
| 463 | JOYSTICK_STATE_AXIS AxisState(void) const { return m_axisState; } | ||
| 464 | |||
| 465 | /// @brief Get motor state. | ||
| 466 | /// | ||
| 467 | /// @return Motor state | ||
| 468 | JOYSTICK_STATE_MOTOR MotorState(void) const { return m_motorState; } | ||
| 469 | |||
| 470 | /// @brief Set type of event. | ||
| 471 | /// | ||
| 472 | /// @param[in] type Type defined with @ref PERIPHERAL_EVENT_TYPE | ||
| 473 | void SetType(PERIPHERAL_EVENT_TYPE type) { m_type = type; } | ||
| 474 | |||
| 475 | /// @brief Set peripheral index. | ||
| 476 | /// | ||
| 477 | /// @param[in] index %Peripheral index number | ||
| 478 | void SetPeripheralIndex(unsigned int index) { m_peripheralIndex = index; } | ||
| 479 | |||
| 480 | /// @brief Set driver index. | ||
| 481 | /// | ||
| 482 | /// @param[in] index Driver index number | ||
| 483 | void SetDriverIndex(unsigned int index) { m_driverIndex = index; } | ||
| 484 | |||
| 485 | /// @brief Set button state. | ||
| 486 | /// | ||
| 487 | /// @param[in] state Button state as @ref JOYSTICK_STATE_BUTTON | ||
| 488 | void SetButtonState(JOYSTICK_STATE_BUTTON state) { m_buttonState = state; } | ||
| 489 | |||
| 490 | /// @brief Set hat state. | ||
| 491 | /// | ||
| 492 | /// @param[in] state Hat state as @ref JOYSTICK_STATE_HAT (float) | ||
| 493 | void SetHatState(JOYSTICK_STATE_HAT state) { m_hatState = state; } | ||
| 494 | |||
| 495 | /// @brief Set axis state. | ||
| 496 | /// | ||
| 497 | /// @param[in] state Axis state as @ref JOYSTICK_STATE_AXIS (float) | ||
| 498 | void SetAxisState(JOYSTICK_STATE_AXIS state) { m_axisState = state; } | ||
| 499 | |||
| 500 | /// @brief Set motor state. | ||
| 501 | /// | ||
| 502 | /// @param[in] state Motor state as @ref JOYSTICK_STATE_MOTOR (float) | ||
| 503 | void SetMotorState(JOYSTICK_STATE_MOTOR state) { m_motorState = state; } | ||
| 504 | |||
| 505 | ///@} | ||
| 506 | |||
| 507 | explicit PeripheralEvent(const PERIPHERAL_EVENT& event) | ||
| 508 | : m_type(event.type), | ||
| 509 | m_peripheralIndex(event.peripheral_index), | ||
| 510 | m_driverIndex(event.driver_index), | ||
| 511 | m_buttonState(event.driver_button_state), | ||
| 512 | m_hatState(event.driver_hat_state), | ||
| 513 | m_axisState(event.driver_axis_state), | ||
| 514 | m_motorState(event.motor_state) | ||
| 515 | { | ||
| 516 | } | ||
| 517 | |||
| 518 | void ToStruct(PERIPHERAL_EVENT& event) const | ||
| 519 | { | ||
| 520 | event.type = m_type; | ||
| 521 | event.peripheral_index = m_peripheralIndex; | ||
| 522 | event.driver_index = m_driverIndex; | ||
| 523 | event.driver_button_state = m_buttonState; | ||
| 524 | event.driver_hat_state = m_hatState; | ||
| 525 | event.driver_axis_state = m_axisState; | ||
| 526 | event.motor_state = m_motorState; | ||
| 527 | } | ||
| 528 | |||
| 529 | static void FreeStruct(PERIPHERAL_EVENT& event) { (void)event; } | ||
| 530 | |||
| 531 | private: | ||
| 532 | PERIPHERAL_EVENT_TYPE m_type = PERIPHERAL_EVENT_TYPE_NONE; | ||
| 533 | unsigned int m_peripheralIndex = 0; | ||
| 534 | unsigned int m_driverIndex = 0; | ||
| 535 | JOYSTICK_STATE_BUTTON m_buttonState = JOYSTICK_STATE_BUTTON_UNPRESSED; | ||
| 536 | JOYSTICK_STATE_HAT m_hatState = JOYSTICK_STATE_HAT_UNPRESSED; | ||
| 537 | JOYSTICK_STATE_AXIS m_axisState = 0.0f; | ||
| 538 | JOYSTICK_STATE_MOTOR m_motorState = 0.0f; | ||
| 539 | }; | ||
| 540 | ///@} | ||
| 541 | //------------------------------------------------------------------------------ | ||
| 542 | |||
| 543 | typedef PeripheralVector<PeripheralEvent, PERIPHERAL_EVENT> PeripheralEvents; | ||
| 544 | |||
| 545 | //============================================================================== | ||
| 546 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_Joystick class Joystick | ||
| 547 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick | ||
| 548 | /// @brief **Wrapper class providing additional joystick information**\n | ||
| 549 | /// This is a child class to expand another class with necessary joystick data. | ||
| 550 | /// | ||
| 551 | /// For data not provided by @ref cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral. | ||
| 552 | /// | ||
| 553 | /// Used on: | ||
| 554 | /// - @ref kodi::addon::CInstancePeripheral::GetJoystickInfo() | ||
| 555 | /// - @ref kodi::addon::CInstancePeripheral::GetFeatures(). | ||
| 556 | /// - @ref kodi::addon::CInstancePeripheral::MapFeatures(). | ||
| 557 | /// - @ref kodi::addon::CInstancePeripheral::GetIgnoredPrimitives(). | ||
| 558 | /// - @ref kodi::addon::CInstancePeripheral::SetIgnoredPrimitives(). | ||
| 559 | /// - @ref kodi::addon::CInstancePeripheral::SaveButtonMap(). | ||
| 560 | /// - @ref kodi::addon::CInstancePeripheral::RevertButtonMap(). | ||
| 561 | /// - @ref kodi::addon::CInstancePeripheral::ResetButtonMap(). | ||
| 562 | /// | ||
| 563 | /// ---------------------------------------------------------------------------- | ||
| 564 | /// | ||
| 565 | /// @copydetails cpp_kodi_addon_peripheral_Defs_Joystick_Joystick_Help | ||
| 566 | /// | ||
| 567 | ///@{ | ||
| 568 | class Joystick : public Peripheral | ||
| 569 | { | ||
| 570 | public: | ||
| 571 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_Joystick_Help Value Help | ||
| 572 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick_Joystick | ||
| 573 | /// ---------------------------------------------------------------------------- | ||
| 574 | /// | ||
| 575 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_peripheral_Defs_Joystick_Joystick :</b> | ||
| 576 | /// | Name | Type | Class | Set call | Get call | ||
| 577 | /// |------|------|-------|----------|---------- | ||
| 578 | /// | **%Joystick provider** | `const std::string&` | @ref Joystick | @ref Joystick::SetProvider "SetProvider" | @ref Joystick::Provider "Provider" | ||
| 579 | /// | **%Joystick requested port** | `int` | @ref Joystick | @ref Joystick::SetRequestedPort "SetRequestedPort" | @ref Joystick::RequestedPort "RequestedPort" | ||
| 580 | /// | **%Joystick button count** | `unsigned int` | @ref Joystick | @ref Joystick::SetButtonCount "SetButtonCount" | @ref Joystick::ButtonCount "ButtonCount" | ||
| 581 | /// | **%Joystick hat count** | `unsigned int` | @ref Joystick | @ref Joystick::SetHatCount "SetHatCount" | @ref Joystick::HatCount "HatCount" | ||
| 582 | /// | **%Joystick axis count** | `unsigned int` | @ref Joystick | @ref Joystick::SetAxisCount "SetAxisCount" | @ref Joystick::AxisCount "AxisCount" | ||
| 583 | /// | **%Joystick motor count** | `unsigned int` | @ref Joystick | @ref Joystick::SetMotorCount "SetMotorCount" | @ref Joystick::MotorCount "MotorCount" | ||
| 584 | /// | **%Joystick support power off** | `bool` | @ref Joystick | @ref Joystick::SetSupportsPowerOff "SetSupportsPowerOff" | @ref Joystick::SupportsPowerOff "SupportsPowerOff" | ||
| 585 | /// | **%Peripheral type** | @ref PERIPHERAL_TYPE | @ref Peripheral | @ref Peripheral::SetType "SetType" | @ref Peripheral::Type "Type" | ||
| 586 | /// | **%Peripheral name** | `const std::string&` | @ref Peripheral | @ref Peripheral::SetName "SetName" | @ref Peripheral::Name "Name" | ||
| 587 | /// | **%Peripheral vendor id** | `uint16_t` | @ref Peripheral | @ref Peripheral::SetVendorID "SetVendorID" | @ref Peripheral::VendorID "VendorID" | ||
| 588 | /// | **%Peripheral product id** | `uint16_t` | @ref Peripheral | @ref Peripheral::SetProductID "SetProductID" | @ref Peripheral::ProductID "ProductID" | ||
| 589 | /// | **%Peripheral index** | `unsigned int` | @ref Peripheral | @ref Peripheral::SetIndex "SetIndex" | @ref Peripheral::Index "Index" | ||
| 590 | /// | ||
| 591 | /// Further are following included: | ||
| 592 | /// - @ref Joystick::Joystick "Joystick(const std::string& provider = \"\", const std::string& strName = \"\")" | ||
| 593 | /// - @ref Joystick::operator= "Joystick& operator=(const Joystick& rhs)" | ||
| 594 | /// - @ref Peripheral::IsVidPidKnown "IsVidPidKnown()": To check VID and PID are known. | ||
| 595 | /// | ||
| 596 | |||
| 597 | /// @addtogroup cpp_kodi_addon_peripheral_Defs_Joystick_Joystick | ||
| 598 | ///@{ | ||
| 599 | |||
| 600 | /// @brief Constructor. | ||
| 601 | /// | ||
| 602 | /// @param[in] provider [optional] Provide name | ||
| 603 | /// @param[in] strName [optional] Name of related joystick | ||
| 604 | Joystick(const std::string& provider = "", const std::string& strName = "") | ||
| 605 | : Peripheral(PERIPHERAL_TYPE_JOYSTICK, strName), | ||
| 606 | m_provider(provider), | ||
| 607 | m_requestedPort(NO_PORT_REQUESTED) | ||
| 608 | { | ||
| 609 | } | ||
| 610 | |||
| 611 | /// @brief Class copy constructor. | ||
| 612 | /// | ||
| 613 | /// @param[in] other Other class to copy on construct here | ||
| 614 | Joystick(const Joystick& other) { *this = other; } | ||
| 615 | |||
| 616 | /// @brief Destructor. | ||
| 617 | /// | ||
| 618 | ~Joystick(void) override = default; | ||
| 619 | |||
| 620 | /// @brief Copy data from another @ref Joystick class to here. | ||
| 621 | /// | ||
| 622 | /// @param[in] other Other class to copy here | ||
| 623 | Joystick& operator=(const Joystick& rhs) | ||
| 624 | { | ||
| 625 | if (this != &rhs) | ||
| 626 | { | ||
| 627 | Peripheral::operator=(rhs); | ||
| 628 | |||
| 629 | m_provider = rhs.m_provider; | ||
| 630 | m_requestedPort = rhs.m_requestedPort; | ||
| 631 | m_buttonCount = rhs.m_buttonCount; | ||
| 632 | m_hatCount = rhs.m_hatCount; | ||
| 633 | m_axisCount = rhs.m_axisCount; | ||
| 634 | m_motorCount = rhs.m_motorCount; | ||
| 635 | m_supportsPowerOff = rhs.m_supportsPowerOff; | ||
| 636 | } | ||
| 637 | return *this; | ||
| 638 | } | ||
| 639 | |||
| 640 | /// @brief Get provider name. | ||
| 641 | /// | ||
| 642 | /// @return Name of provider | ||
| 643 | const std::string& Provider(void) const { return m_provider; } | ||
| 644 | |||
| 645 | /// @brief Get requested port number. | ||
| 646 | /// | ||
| 647 | /// @return Port | ||
| 648 | int RequestedPort(void) const { return m_requestedPort; } | ||
| 649 | |||
| 650 | /// @brief Get button count. | ||
| 651 | /// | ||
| 652 | /// @return Button count | ||
| 653 | unsigned int ButtonCount(void) const { return m_buttonCount; } | ||
| 654 | |||
| 655 | /// @brief Get hat count. | ||
| 656 | /// | ||
| 657 | /// @return Hat count | ||
| 658 | unsigned int HatCount(void) const { return m_hatCount; } | ||
| 659 | |||
| 660 | /// @brief Get axis count. | ||
| 661 | /// | ||
| 662 | /// @return Axis count | ||
| 663 | unsigned int AxisCount(void) const { return m_axisCount; } | ||
| 664 | |||
| 665 | /// @brief Get motor count. | ||
| 666 | /// | ||
| 667 | /// @return Motor count | ||
| 668 | unsigned int MotorCount(void) const { return m_motorCount; } | ||
| 669 | |||
| 670 | /// @brief Get supports power off. | ||
| 671 | /// | ||
| 672 | /// @return True if power off is supported, false otherwise | ||
| 673 | bool SupportsPowerOff(void) const { return m_supportsPowerOff; } | ||
| 674 | |||
| 675 | /// @brief Set provider name. | ||
| 676 | /// | ||
| 677 | /// @param[in] provider Name of provider | ||
| 678 | void SetProvider(const std::string& provider) { m_provider = provider; } | ||
| 679 | |||
| 680 | /// @brief Get requested port number. | ||
| 681 | /// | ||
| 682 | /// @param[in] requestedPort Port | ||
| 683 | void SetRequestedPort(int requestedPort) { m_requestedPort = requestedPort; } | ||
| 684 | |||
| 685 | /// @brief Get button count. | ||
| 686 | /// | ||
| 687 | /// @param[in] buttonCount Button count | ||
| 688 | void SetButtonCount(unsigned int buttonCount) { m_buttonCount = buttonCount; } | ||
| 689 | |||
| 690 | /// @brief Get hat count. | ||
| 691 | /// | ||
| 692 | /// @param[in] hatCount Hat count | ||
| 693 | void SetHatCount(unsigned int hatCount) { m_hatCount = hatCount; } | ||
| 694 | |||
| 695 | /// @brief Get axis count. | ||
| 696 | /// | ||
| 697 | /// @param[in] axisCount Axis count | ||
| 698 | void SetAxisCount(unsigned int axisCount) { m_axisCount = axisCount; } | ||
| 699 | |||
| 700 | /// @brief Get motor count. | ||
| 701 | /// | ||
| 702 | /// @param[in] motorCount Motor count | ||
| 703 | void SetMotorCount(unsigned int motorCount) { m_motorCount = motorCount; } | ||
| 704 | |||
| 705 | /// @brief Get supports power off. | ||
| 706 | /// | ||
| 707 | /// @param[in] supportsPowerOff True if power off is supported, false otherwise | ||
| 708 | void SetSupportsPowerOff(bool supportsPowerOff) { m_supportsPowerOff = supportsPowerOff; } | ||
| 709 | |||
| 710 | ///@} | ||
| 711 | |||
| 712 | explicit Joystick(const JOYSTICK_INFO& info) | ||
| 713 | : Peripheral(info.peripheral), | ||
| 714 | m_provider(info.provider ? info.provider : ""), | ||
| 715 | m_requestedPort(info.requested_port), | ||
| 716 | m_buttonCount(info.button_count), | ||
| 717 | m_hatCount(info.hat_count), | ||
| 718 | m_axisCount(info.axis_count), | ||
| 719 | m_motorCount(info.motor_count), | ||
| 720 | m_supportsPowerOff(info.supports_poweroff) | ||
| 721 | { | ||
| 722 | } | ||
| 723 | |||
| 724 | void ToStruct(JOYSTICK_INFO& info) const | ||
| 725 | { | ||
| 726 | Peripheral::ToStruct(info.peripheral); | ||
| 727 | |||
| 728 | info.provider = new char[m_provider.size() + 1]; | ||
| 729 | info.requested_port = m_requestedPort; | ||
| 730 | info.button_count = m_buttonCount; | ||
| 731 | info.hat_count = m_hatCount; | ||
| 732 | info.axis_count = m_axisCount; | ||
| 733 | info.motor_count = m_motorCount; | ||
| 734 | info.supports_poweroff = m_supportsPowerOff; | ||
| 735 | |||
| 736 | std::strcpy(info.provider, m_provider.c_str()); | ||
| 737 | } | ||
| 738 | |||
| 739 | static void FreeStruct(JOYSTICK_INFO& info) | ||
| 740 | { | ||
| 741 | Peripheral::FreeStruct(info.peripheral); | ||
| 742 | |||
| 743 | PERIPHERAL_SAFE_DELETE_ARRAY(info.provider); | ||
| 744 | } | ||
| 745 | |||
| 746 | private: | ||
| 747 | std::string m_provider; | ||
| 748 | int m_requestedPort; | ||
| 749 | unsigned int m_buttonCount = 0; | ||
| 750 | unsigned int m_hatCount = 0; | ||
| 751 | unsigned int m_axisCount = 0; | ||
| 752 | unsigned int m_motorCount = 0; | ||
| 753 | bool m_supportsPowerOff = false; | ||
| 754 | }; | ||
| 755 | ///@} | ||
| 756 | //------------------------------------------------------------------------------ | ||
| 757 | |||
| 758 | typedef PeripheralVector<Joystick, JOYSTICK_INFO> Joysticks; | ||
| 759 | |||
| 760 | class JoystickFeature; | ||
| 761 | |||
| 762 | //============================================================================== | ||
| 763 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_DriverPrimitive class DriverPrimitive | ||
| 764 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick | ||
| 765 | /// @brief **Base class for joystick driver primitives** | ||
| 766 | /// | ||
| 767 | /// A driver primitive can be: | ||
| 768 | /// | ||
| 769 | /// 1. a button | ||
| 770 | /// 2. a hat direction | ||
| 771 | /// 3. a semiaxis (either the positive or negative half of an axis) | ||
| 772 | /// 4. a motor | ||
| 773 | /// 5. a keyboard key | ||
| 774 | /// 6. a mouse button | ||
| 775 | /// 7. a relative pointer direction | ||
| 776 | /// | ||
| 777 | /// The type determines the fields in use: | ||
| 778 | /// | ||
| 779 | /// Button: | ||
| 780 | /// - driver index | ||
| 781 | /// | ||
| 782 | /// Hat direction: | ||
| 783 | /// - driver index | ||
| 784 | /// - hat direction | ||
| 785 | /// | ||
| 786 | /// Semiaxis: | ||
| 787 | /// - driver index | ||
| 788 | /// - center | ||
| 789 | /// - semiaxis direction | ||
| 790 | /// - range | ||
| 791 | /// | ||
| 792 | /// Motor: | ||
| 793 | /// - driver index | ||
| 794 | /// | ||
| 795 | /// Key: | ||
| 796 | /// - key code | ||
| 797 | /// | ||
| 798 | /// Mouse button: | ||
| 799 | /// - driver index | ||
| 800 | /// | ||
| 801 | /// Relative pointer direction: | ||
| 802 | /// - relative pointer direction | ||
| 803 | /// | ||
| 804 | ///@{ | ||
| 805 | struct DriverPrimitive | ||
| 806 | { | ||
| 807 | protected: | ||
| 808 | /*! | ||
| 809 | * \brief Construct a driver primitive of the specified type | ||
| 810 | */ | ||
| 811 | DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE type, unsigned int driverIndex) | ||
| 812 | : m_type(type), m_driverIndex(driverIndex) | ||
| 813 | { | ||
| 814 | } | ||
| 815 | |||
| 816 | public: | ||
| 817 | /// @addtogroup cpp_kodi_addon_peripheral_Defs_Joystick_DriverPrimitive | ||
| 818 | ///@{ | ||
| 819 | |||
| 820 | /// @brief Construct an invalid driver primitive. | ||
| 821 | DriverPrimitive(void) = default; | ||
| 822 | |||
| 823 | /// @brief Construct a driver primitive representing a joystick button. | ||
| 824 | /// | ||
| 825 | /// @param[in] buttonIndex Index | ||
| 826 | /// @return Created class | ||
| 827 | static DriverPrimitive CreateButton(unsigned int buttonIndex) | ||
| 828 | { | ||
| 829 | return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON, buttonIndex); | ||
| 830 | } | ||
| 831 | |||
| 832 | /// @brief Construct a driver primitive representing one of the four direction | ||
| 833 | /// arrows on a dpad. | ||
| 834 | /// | ||
| 835 | /// @param[in] hatIndex Hat index | ||
| 836 | /// @param[in] direction With @ref JOYSTICK_DRIVER_HAT_DIRECTION defined direction | ||
| 837 | DriverPrimitive(unsigned int hatIndex, JOYSTICK_DRIVER_HAT_DIRECTION direction) | ||
| 838 | : m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION), | ||
| 839 | m_driverIndex(hatIndex), | ||
| 840 | m_hatDirection(direction) | ||
| 841 | { | ||
| 842 | } | ||
| 843 | |||
| 844 | /// @brief Construct a driver primitive representing the positive or negative | ||
| 845 | /// half of an axis. | ||
| 846 | /// | ||
| 847 | /// @param[in] axisIndex Axis index | ||
| 848 | /// @param[in] center Center | ||
| 849 | /// @param[in] direction With @ref JOYSTICK_DRIVER_HAT_DIRECTION defined direction | ||
| 850 | /// @param[in] range Range | ||
| 851 | DriverPrimitive(unsigned int axisIndex, | ||
| 852 | int center, | ||
| 853 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction, | ||
| 854 | unsigned int range) | ||
| 855 | : m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS), | ||
| 856 | m_driverIndex(axisIndex), | ||
| 857 | m_center(center), | ||
| 858 | m_semiAxisDirection(direction), | ||
| 859 | m_range(range) | ||
| 860 | { | ||
| 861 | } | ||
| 862 | |||
| 863 | /// @brief Construct a driver primitive representing a motor. | ||
| 864 | /// | ||
| 865 | /// @param[in] motorIndex Motor index number | ||
| 866 | /// @return Constructed driver primitive representing a motor | ||
| 867 | static DriverPrimitive CreateMotor(unsigned int motorIndex) | ||
| 868 | { | ||
| 869 | return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR, motorIndex); | ||
| 870 | } | ||
| 871 | |||
| 872 | /// @brief Construct a driver primitive representing a key on a keyboard. | ||
| 873 | /// | ||
| 874 | /// @param[in] keycode Keycode to use | ||
| 875 | DriverPrimitive(std::string keycode) | ||
| 876 | : m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY), m_keycode(std::move(keycode)) | ||
| 877 | { | ||
| 878 | } | ||
| 879 | |||
| 880 | /// @brief Construct a driver primitive representing a mouse button. | ||
| 881 | /// | ||
| 882 | /// @param[in] buttonIndex Index | ||
| 883 | /// @return Constructed driver primitive representing a mouse button | ||
| 884 | static DriverPrimitive CreateMouseButton(JOYSTICK_DRIVER_MOUSE_INDEX buttonIndex) | ||
| 885 | { | ||
| 886 | return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON, | ||
| 887 | static_cast<unsigned int>(buttonIndex)); | ||
| 888 | } | ||
| 889 | |||
| 890 | /// @brief Construct a driver primitive representing one of the four | ||
| 891 | /// direction in which a relative pointer can move | ||
| 892 | /// | ||
| 893 | /// @param[in] direction With @ref JOYSTICK_DRIVER_RELPOINTER_DIRECTION defined direction | ||
| 894 | DriverPrimitive(JOYSTICK_DRIVER_RELPOINTER_DIRECTION direction) | ||
| 895 | : m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION), m_relPointerDirection(direction) | ||
| 896 | { | ||
| 897 | } | ||
| 898 | |||
| 899 | /// @brief Get type of primitive. | ||
| 900 | /// | ||
| 901 | /// @return The with @ref JOYSTICK_DRIVER_PRIMITIVE_TYPE defined type | ||
| 902 | JOYSTICK_DRIVER_PRIMITIVE_TYPE Type(void) const { return m_type; } | ||
| 903 | |||
| 904 | /// @brief Get driver index. | ||
| 905 | /// | ||
| 906 | /// @return Index number | ||
| 907 | unsigned int DriverIndex(void) const { return m_driverIndex; } | ||
| 908 | |||
| 909 | /// @brief Get hat direction | ||
| 910 | /// | ||
| 911 | /// @return The with @ref JOYSTICK_DRIVER_HAT_DIRECTION defined direction | ||
| 912 | JOYSTICK_DRIVER_HAT_DIRECTION HatDirection(void) const { return m_hatDirection; } | ||
| 913 | |||
| 914 | /// @brief Get center | ||
| 915 | /// | ||
| 916 | /// @return Center | ||
| 917 | int Center(void) const { return m_center; } | ||
| 918 | |||
| 919 | /// @brief Get semi axis direction | ||
| 920 | /// | ||
| 921 | /// @return With @ref JOYSTICK_DRIVER_SEMIAXIS_DIRECTION defined direction | ||
| 922 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION SemiAxisDirection(void) const { return m_semiAxisDirection; } | ||
| 923 | |||
| 924 | /// @brief Get range. | ||
| 925 | /// | ||
| 926 | /// @return Range | ||
| 927 | unsigned int Range(void) const { return m_range; } | ||
| 928 | |||
| 929 | /// @brief Get key code as string. | ||
| 930 | /// | ||
| 931 | /// @return Key code | ||
| 932 | const std::string& Keycode(void) const { return m_keycode; } | ||
| 933 | |||
| 934 | /// @brief Get mouse index | ||
| 935 | /// | ||
| 936 | /// @return With @ref JOYSTICK_DRIVER_MOUSE_INDEX defined mouse index | ||
| 937 | JOYSTICK_DRIVER_MOUSE_INDEX MouseIndex(void) const | ||
| 938 | { | ||
| 939 | return static_cast<JOYSTICK_DRIVER_MOUSE_INDEX>(m_driverIndex); | ||
| 940 | } | ||
| 941 | |||
| 942 | /// @brief Get relative pointer direction. | ||
| 943 | /// | ||
| 944 | /// @return With @ref JOYSTICK_DRIVER_RELPOINTER_DIRECTION defined direction | ||
| 945 | JOYSTICK_DRIVER_RELPOINTER_DIRECTION RelPointerDirection(void) const | ||
| 946 | { | ||
| 947 | return m_relPointerDirection; | ||
| 948 | } | ||
| 949 | |||
| 950 | /// @brief Compare this with another class of this type. | ||
| 951 | /// | ||
| 952 | /// @param[in] other Other class to compare | ||
| 953 | /// @return True if they are equal, false otherwise | ||
| 954 | bool operator==(const DriverPrimitive& other) const | ||
| 955 | { | ||
| 956 | if (m_type == other.m_type) | ||
| 957 | { | ||
| 958 | switch (m_type) | ||
| 959 | { | ||
| 960 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: | ||
| 961 | { | ||
| 962 | return m_driverIndex == other.m_driverIndex; | ||
| 963 | } | ||
| 964 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION: | ||
| 965 | { | ||
| 966 | return m_driverIndex == other.m_driverIndex && m_hatDirection == other.m_hatDirection; | ||
| 967 | } | ||
| 968 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: | ||
| 969 | { | ||
| 970 | return m_driverIndex == other.m_driverIndex && m_center == other.m_center && | ||
| 971 | m_semiAxisDirection == other.m_semiAxisDirection && m_range == other.m_range; | ||
| 972 | } | ||
| 973 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY: | ||
| 974 | { | ||
| 975 | return m_keycode == other.m_keycode; | ||
| 976 | } | ||
| 977 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: | ||
| 978 | { | ||
| 979 | return m_driverIndex == other.m_driverIndex; | ||
| 980 | } | ||
| 981 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON: | ||
| 982 | { | ||
| 983 | return m_driverIndex == other.m_driverIndex; | ||
| 984 | } | ||
| 985 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION: | ||
| 986 | { | ||
| 987 | return m_relPointerDirection == other.m_relPointerDirection; | ||
| 988 | } | ||
| 989 | default: | ||
| 990 | break; | ||
| 991 | } | ||
| 992 | } | ||
| 993 | return false; | ||
| 994 | } | ||
| 995 | |||
| 996 | ///@} | ||
| 997 | |||
| 998 | explicit DriverPrimitive(const JOYSTICK_DRIVER_PRIMITIVE& primitive) : m_type(primitive.type) | ||
| 999 | { | ||
| 1000 | switch (m_type) | ||
| 1001 | { | ||
| 1002 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: | ||
| 1003 | { | ||
| 1004 | m_driverIndex = primitive.button.index; | ||
| 1005 | break; | ||
| 1006 | } | ||
| 1007 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION: | ||
| 1008 | { | ||
| 1009 | m_driverIndex = primitive.hat.index; | ||
| 1010 | m_hatDirection = primitive.hat.direction; | ||
| 1011 | break; | ||
| 1012 | } | ||
| 1013 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: | ||
| 1014 | { | ||
| 1015 | m_driverIndex = primitive.semiaxis.index; | ||
| 1016 | m_center = primitive.semiaxis.center; | ||
| 1017 | m_semiAxisDirection = primitive.semiaxis.direction; | ||
| 1018 | m_range = primitive.semiaxis.range; | ||
| 1019 | break; | ||
| 1020 | } | ||
| 1021 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: | ||
| 1022 | { | ||
| 1023 | m_driverIndex = primitive.motor.index; | ||
| 1024 | break; | ||
| 1025 | } | ||
| 1026 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY: | ||
| 1027 | { | ||
| 1028 | m_keycode = primitive.key.keycode; | ||
| 1029 | break; | ||
| 1030 | } | ||
| 1031 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON: | ||
| 1032 | { | ||
| 1033 | m_driverIndex = primitive.mouse.button; | ||
| 1034 | break; | ||
| 1035 | } | ||
| 1036 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION: | ||
| 1037 | { | ||
| 1038 | m_relPointerDirection = primitive.relpointer.direction; | ||
| 1039 | break; | ||
| 1040 | } | ||
| 1041 | default: | ||
| 1042 | break; | ||
| 1043 | } | ||
| 1044 | } | ||
| 1045 | |||
| 1046 | void ToStruct(JOYSTICK_DRIVER_PRIMITIVE& driver_primitive) const | ||
| 1047 | { | ||
| 1048 | driver_primitive.type = m_type; | ||
| 1049 | switch (m_type) | ||
| 1050 | { | ||
| 1051 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: | ||
| 1052 | { | ||
| 1053 | driver_primitive.button.index = m_driverIndex; | ||
| 1054 | break; | ||
| 1055 | } | ||
| 1056 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION: | ||
| 1057 | { | ||
| 1058 | driver_primitive.hat.index = m_driverIndex; | ||
| 1059 | driver_primitive.hat.direction = m_hatDirection; | ||
| 1060 | break; | ||
| 1061 | } | ||
| 1062 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: | ||
| 1063 | { | ||
| 1064 | driver_primitive.semiaxis.index = m_driverIndex; | ||
| 1065 | driver_primitive.semiaxis.center = m_center; | ||
| 1066 | driver_primitive.semiaxis.direction = m_semiAxisDirection; | ||
| 1067 | driver_primitive.semiaxis.range = m_range; | ||
| 1068 | break; | ||
| 1069 | } | ||
| 1070 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: | ||
| 1071 | { | ||
| 1072 | driver_primitive.motor.index = m_driverIndex; | ||
| 1073 | break; | ||
| 1074 | } | ||
| 1075 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY: | ||
| 1076 | { | ||
| 1077 | const size_t size = sizeof(driver_primitive.key.keycode); | ||
| 1078 | std::strncpy(driver_primitive.key.keycode, m_keycode.c_str(), size - 1); | ||
| 1079 | driver_primitive.key.keycode[size - 1] = '\0'; | ||
| 1080 | break; | ||
| 1081 | } | ||
| 1082 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON: | ||
| 1083 | { | ||
| 1084 | driver_primitive.mouse.button = static_cast<JOYSTICK_DRIVER_MOUSE_INDEX>(m_driverIndex); | ||
| 1085 | break; | ||
| 1086 | } | ||
| 1087 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION: | ||
| 1088 | { | ||
| 1089 | driver_primitive.relpointer.direction = m_relPointerDirection; | ||
| 1090 | break; | ||
| 1091 | } | ||
| 1092 | default: | ||
| 1093 | break; | ||
| 1094 | } | ||
| 1095 | } | ||
| 1096 | |||
| 1097 | static void FreeStruct(JOYSTICK_DRIVER_PRIMITIVE& primitive) { (void)primitive; } | ||
| 1098 | |||
| 1099 | private: | ||
| 1100 | JOYSTICK_DRIVER_PRIMITIVE_TYPE m_type = JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN; | ||
| 1101 | unsigned int m_driverIndex = 0; | ||
| 1102 | JOYSTICK_DRIVER_HAT_DIRECTION m_hatDirection = JOYSTICK_DRIVER_HAT_UNKNOWN; | ||
| 1103 | int m_center = 0; | ||
| 1104 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION m_semiAxisDirection = JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN; | ||
| 1105 | unsigned int m_range = 1; | ||
| 1106 | std::string m_keycode; | ||
| 1107 | JOYSTICK_DRIVER_RELPOINTER_DIRECTION m_relPointerDirection = JOYSTICK_DRIVER_RELPOINTER_UNKNOWN; | ||
| 1108 | }; | ||
| 1109 | ///@} | ||
| 1110 | //------------------------------------------------------------------------------ | ||
| 1111 | |||
| 1112 | typedef PeripheralVector<DriverPrimitive, JOYSTICK_DRIVER_PRIMITIVE> DriverPrimitives; | ||
| 1113 | |||
| 1114 | //============================================================================== | ||
| 1115 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JoystickFeature class JoystickFeature | ||
| 1116 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick | ||
| 1117 | /// @brief **Base class for joystick feature primitives** | ||
| 1118 | /// | ||
| 1119 | /// Class for joystick features. A feature can be: | ||
| 1120 | /// | ||
| 1121 | /// 1. scalar *[1]* | ||
| 1122 | /// 2. analog stick | ||
| 1123 | /// 3. accelerometer | ||
| 1124 | /// 4. motor | ||
| 1125 | /// 5. relative pointer *[2]* | ||
| 1126 | /// 6. absolute pointer | ||
| 1127 | /// 7. wheel | ||
| 1128 | /// 8. throttle | ||
| 1129 | /// 9. keyboard key | ||
| 1130 | /// | ||
| 1131 | /// *[1]* All three driver primitives (buttons, hats and axes) have a state that | ||
| 1132 | /// can be represented using a single scalar value. For this reason, | ||
| 1133 | /// features that map to a single primitive are called "scalar features". | ||
| 1134 | /// | ||
| 1135 | /// *[2]* Relative pointers are similar to analog sticks, but they use | ||
| 1136 | /// relative distances instead of positions. | ||
| 1137 | /// | ||
| 1138 | ///@{ | ||
| 1139 | class JoystickFeature | ||
| 1140 | { | ||
| 1141 | public: | ||
| 1142 | /// @addtogroup cpp_kodi_addon_peripheral_Defs_Joystick_JoystickFeature | ||
| 1143 | ///@{ | ||
| 1144 | |||
| 1145 | /// @brief Class constructor. | ||
| 1146 | /// | ||
| 1147 | /// @param[in] name [optional] Name of the feature | ||
| 1148 | /// @param[in] type [optional] Type of the feature, @ref JOYSTICK_FEATURE_TYPE_UNKNOWN | ||
| 1149 | /// as default | ||
| 1150 | JoystickFeature(const std::string& name = "", | ||
| 1151 | JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN) | ||
| 1152 | : m_name(name), m_type(type), m_primitives{} | ||
| 1153 | { | ||
| 1154 | } | ||
| 1155 | |||
| 1156 | /// @brief Class copy constructor. | ||
| 1157 | /// | ||
| 1158 | /// @param[in] other Other class to copy on construct here | ||
| 1159 | JoystickFeature(const JoystickFeature& other) { *this = other; } | ||
| 1160 | |||
| 1161 | /// @brief Copy data from another @ref JoystickFeature class to here. | ||
| 1162 | /// | ||
| 1163 | /// @param[in] other Other class to copy here | ||
| 1164 | JoystickFeature& operator=(const JoystickFeature& rhs) | ||
| 1165 | { | ||
| 1166 | if (this != &rhs) | ||
| 1167 | { | ||
| 1168 | m_name = rhs.m_name; | ||
| 1169 | m_type = rhs.m_type; | ||
| 1170 | m_primitives = rhs.m_primitives; | ||
| 1171 | } | ||
| 1172 | return *this; | ||
| 1173 | } | ||
| 1174 | |||
| 1175 | /// @brief Compare this with another class of this type. | ||
| 1176 | /// | ||
| 1177 | /// @param[in] other Other class to compare | ||
| 1178 | /// @return True if they are equal, false otherwise | ||
| 1179 | bool operator==(const JoystickFeature& other) const | ||
| 1180 | { | ||
| 1181 | return m_name == other.m_name && m_type == other.m_type && m_primitives == other.m_primitives; | ||
| 1182 | } | ||
| 1183 | |||
| 1184 | /// @brief Get name of feature. | ||
| 1185 | /// | ||
| 1186 | /// @return Name of feature | ||
| 1187 | const std::string& Name(void) const { return m_name; } | ||
| 1188 | |||
| 1189 | /// @brief Get name of feature. | ||
| 1190 | /// | ||
| 1191 | /// @return Type of feature defined with @ref JOYSTICK_FEATURE_TYPE | ||
| 1192 | JOYSTICK_FEATURE_TYPE Type(void) const { return m_type; } | ||
| 1193 | |||
| 1194 | /// @brief Check this feature is valid. | ||
| 1195 | /// | ||
| 1196 | /// @return True if valid (type != JOYSTICK_FEATURE_TYPE_UNKNOWN), false otherwise | ||
| 1197 | bool IsValid() const { return m_type != JOYSTICK_FEATURE_TYPE_UNKNOWN; } | ||
| 1198 | |||
| 1199 | /// @brief Set name of feature. | ||
| 1200 | /// | ||
| 1201 | /// @param[in] name Name of feature | ||
| 1202 | void SetName(const std::string& name) { m_name = name; } | ||
| 1203 | |||
| 1204 | /// @brief Set type of feature. | ||
| 1205 | /// | ||
| 1206 | /// @param[in] type Type of feature | ||
| 1207 | void SetType(JOYSTICK_FEATURE_TYPE type) { m_type = type; } | ||
| 1208 | |||
| 1209 | /// @brief Set type as invalid. | ||
| 1210 | void SetInvalid(void) { m_type = JOYSTICK_FEATURE_TYPE_UNKNOWN; } | ||
| 1211 | |||
| 1212 | /// @brief Get primitive of feature by wanted type. | ||
| 1213 | /// | ||
| 1214 | /// @param[in] which Type of feature, defined with @ref JOYSTICK_FEATURE_PRIMITIVE | ||
| 1215 | /// @return Primitive of asked type | ||
| 1216 | const DriverPrimitive& Primitive(JOYSTICK_FEATURE_PRIMITIVE which) const | ||
| 1217 | { | ||
| 1218 | return m_primitives[which]; | ||
| 1219 | } | ||
| 1220 | |||
| 1221 | /// @brief Set primitive for feature by wanted type. | ||
| 1222 | /// | ||
| 1223 | /// @param[in] which Type of feature, defined with @ref JOYSTICK_FEATURE_PRIMITIVE | ||
| 1224 | /// @param[in] primitive The with @ref DriverPrimitive defined primitive to set | ||
| 1225 | void SetPrimitive(JOYSTICK_FEATURE_PRIMITIVE which, const DriverPrimitive& primitive) | ||
| 1226 | { | ||
| 1227 | m_primitives[which] = primitive; | ||
| 1228 | } | ||
| 1229 | |||
| 1230 | /// @brief Get all primitives on this class. | ||
| 1231 | /// | ||
| 1232 | /// @return Array list of primitives | ||
| 1233 | std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX>& Primitives() { return m_primitives; } | ||
| 1234 | |||
| 1235 | /// @brief Get all primitives on this class (as constant). | ||
| 1236 | /// | ||
| 1237 | /// @return Constant a´rray list of primitives | ||
| 1238 | const std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX>& Primitives() const | ||
| 1239 | { | ||
| 1240 | return m_primitives; | ||
| 1241 | } | ||
| 1242 | |||
| 1243 | ///@} | ||
| 1244 | |||
| 1245 | explicit JoystickFeature(const JOYSTICK_FEATURE& feature) | ||
| 1246 | : m_name(feature.name ? feature.name : ""), m_type(feature.type) | ||
| 1247 | { | ||
| 1248 | for (unsigned int i = 0; i < JOYSTICK_PRIMITIVE_MAX; i++) | ||
| 1249 | m_primitives[i] = DriverPrimitive(feature.primitives[i]); | ||
| 1250 | } | ||
| 1251 | |||
| 1252 | void ToStruct(JOYSTICK_FEATURE& feature) const | ||
| 1253 | { | ||
| 1254 | feature.name = new char[m_name.length() + 1]; | ||
| 1255 | feature.type = m_type; | ||
| 1256 | for (unsigned int i = 0; i < JOYSTICK_PRIMITIVE_MAX; i++) | ||
| 1257 | m_primitives[i].ToStruct(feature.primitives[i]); | ||
| 1258 | |||
| 1259 | std::strcpy(feature.name, m_name.c_str()); | ||
| 1260 | } | ||
| 1261 | |||
| 1262 | static void FreeStruct(JOYSTICK_FEATURE& feature) { PERIPHERAL_SAFE_DELETE_ARRAY(feature.name); } | ||
| 1263 | |||
| 1264 | private: | ||
| 1265 | std::string m_name; | ||
| 1266 | JOYSTICK_FEATURE_TYPE m_type; | ||
| 1267 | std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX> m_primitives; | ||
| 1268 | }; | ||
| 1269 | ///@} | ||
| 1270 | //------------------------------------------------------------------------------ | ||
| 1271 | |||
| 1272 | typedef PeripheralVector<JoystickFeature, JOYSTICK_FEATURE> JoystickFeatures; | ||
| 1273 | |||
| 1274 | } /* namespace addon */ | ||
| 1275 | } /* namespace kodi */ | ||
| 1276 | |||
| 1277 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt index 946849e..3443b1e 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt | |||
| @@ -9,5 +9,5 @@ set(HEADERS ChannelGroups.h | |||
| 9 | Timers.h) | 9 | Timers.h) |
| 10 | 10 | ||
| 11 | if(NOT ENABLE_STATIC_LIBS) | 11 | if(NOT ENABLE_STATIC_LIBS) |
| 12 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_addon-instance_pvr) | 12 | core_add_library(addons_kodi-dev-kit_include_kodi_addon-instance_pvr) |
| 13 | endif() | 13 | endif() |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h index 17995bb..17995bb 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Channels.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Channels.h index 9c2f5d2..9c2f5d2 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Channels.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Channels.h | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EDL.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/EDL.h index 34c7c41..34c7c41 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EDL.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/EDL.h | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EPG.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/EPG.h index e1fc04f..e1fc04f 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EPG.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/EPG.h | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/General.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/General.h index c7977c2..c7977c2 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/General.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/General.h | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h index 053a4d5..053a4d5 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Recordings.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Recordings.h index 24ecf11..24ecf11 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Recordings.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Recordings.h | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Stream.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h index 5613947..5613947 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Stream.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Timers.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Timers.h index 6e05e55..6e05e55 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Timers.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Timers.h | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/CMakeLists.txt index d7b2269..091e0fe 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/CMakeLists.txt +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/CMakeLists.txt | |||
| @@ -4,6 +4,10 @@ set(HEADERS addon_base.h | |||
| 4 | general.h | 4 | general.h |
| 5 | network.h) | 5 | network.h) |
| 6 | 6 | ||
| 7 | if(CORE_SYSTEM_NAME STREQUAL android) | ||
| 8 | list(APPEND SOURCES platform/android/system.h) | ||
| 9 | endif() | ||
| 10 | |||
| 7 | if(NOT ENABLE_STATIC_LIBS) | 11 | if(NOT ENABLE_STATIC_LIBS) |
| 8 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_c-api) | 12 | core_add_library(addons_kodi-dev-kit_include_kodi_c-api) |
| 9 | endif() | 13 | endif() |
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt new file mode 100644 index 0000000..4edd034 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | set(HEADERS audio_decoder.h | ||
| 2 | audio_encoder.h | ||
| 3 | game.h | ||
| 4 | image_decoder.h | ||
| 5 | peripheral.h | ||
| 6 | pvr.h | ||
| 7 | screensaver.h | ||
| 8 | vfs.h | ||
| 9 | visualization.h) | ||
| 10 | |||
| 11 | if(NOT ENABLE_STATIC_LIBS) | ||
| 12 | core_add_library(addons_kodi-dev-kit_include_kodi_c-api_addon-instance) | ||
| 13 | endif() | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_decoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_decoder.h new file mode 100644 index 0000000..8b75ddb --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_decoder.h | |||
| @@ -0,0 +1,92 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_ADDONINSTANCE_AUDIO_DECODER_H | ||
| 12 | #define C_API_ADDONINSTANCE_AUDIO_DECODER_H | ||
| 13 | |||
| 14 | #include "../addon_base.h" | ||
| 15 | #include "../audio_engine.h" | ||
| 16 | |||
| 17 | #define AUDIO_DECODER_LYRICS_SIZE 65535 | ||
| 18 | |||
| 19 | #ifdef __cplusplus | ||
| 20 | extern "C" | ||
| 21 | { | ||
| 22 | #endif /* __cplusplus */ | ||
| 23 | |||
| 24 | // WARNING About size use malloc/new! | ||
| 25 | struct AUDIO_DECODER_INFO_TAG | ||
| 26 | { | ||
| 27 | char title[ADDON_STANDARD_STRING_LENGTH_SMALL]; | ||
| 28 | char artist[ADDON_STANDARD_STRING_LENGTH_SMALL]; | ||
| 29 | char album[ADDON_STANDARD_STRING_LENGTH_SMALL]; | ||
| 30 | char album_artist[ADDON_STANDARD_STRING_LENGTH_SMALL]; | ||
| 31 | char media_type[ADDON_STANDARD_STRING_LENGTH_SMALL]; | ||
| 32 | char genre[ADDON_STANDARD_STRING_LENGTH_SMALL]; | ||
| 33 | int duration; | ||
| 34 | int track; | ||
| 35 | int disc; | ||
| 36 | char disc_subtitle[ADDON_STANDARD_STRING_LENGTH_SMALL]; | ||
| 37 | int disc_total; | ||
| 38 | char release_date[ADDON_STANDARD_STRING_LENGTH_SMALL]; | ||
| 39 | char lyrics[AUDIO_DECODER_LYRICS_SIZE]; | ||
| 40 | int samplerate; | ||
| 41 | int channels; | ||
| 42 | int bitrate; | ||
| 43 | char comment[ADDON_STANDARD_STRING_LENGTH]; | ||
| 44 | }; | ||
| 45 | |||
| 46 | typedef struct AddonProps_AudioDecoder | ||
| 47 | { | ||
| 48 | int dummy; | ||
| 49 | } AddonProps_AudioDecoder; | ||
| 50 | |||
| 51 | typedef struct AddonToKodiFuncTable_AudioDecoder | ||
| 52 | { | ||
| 53 | KODI_HANDLE kodiInstance; | ||
| 54 | } AddonToKodiFuncTable_AudioDecoder; | ||
| 55 | |||
| 56 | struct AddonInstance_AudioDecoder; | ||
| 57 | typedef struct KodiToAddonFuncTable_AudioDecoder | ||
| 58 | { | ||
| 59 | KODI_HANDLE addonInstance; | ||
| 60 | bool(__cdecl* init)(const struct AddonInstance_AudioDecoder* instance, | ||
| 61 | const char* file, | ||
| 62 | unsigned int filecache, | ||
| 63 | int* channels, | ||
| 64 | int* samplerate, | ||
| 65 | int* bitspersample, | ||
| 66 | int64_t* totaltime, | ||
| 67 | int* bitrate, | ||
| 68 | enum AudioEngineDataFormat* format, | ||
| 69 | const enum AudioEngineChannel** info); | ||
| 70 | int(__cdecl* read_pcm)(const struct AddonInstance_AudioDecoder* instance, | ||
| 71 | uint8_t* buffer, | ||
| 72 | int size, | ||
| 73 | int* actualsize); | ||
| 74 | int64_t(__cdecl* seek)(const struct AddonInstance_AudioDecoder* instance, int64_t time); | ||
| 75 | bool(__cdecl* read_tag)(const struct AddonInstance_AudioDecoder* instance, | ||
| 76 | const char* file, | ||
| 77 | struct AUDIO_DECODER_INFO_TAG* tag); | ||
| 78 | int(__cdecl* track_count)(const struct AddonInstance_AudioDecoder* instance, const char* file); | ||
| 79 | } KodiToAddonFuncTable_AudioDecoder; | ||
| 80 | |||
| 81 | typedef struct AddonInstance_AudioDecoder | ||
| 82 | { | ||
| 83 | struct AddonProps_AudioDecoder* props; | ||
| 84 | struct AddonToKodiFuncTable_AudioDecoder* toKodi; | ||
| 85 | struct KodiToAddonFuncTable_AudioDecoder* toAddon; | ||
| 86 | } AddonInstance_AudioDecoder; | ||
| 87 | |||
| 88 | #ifdef __cplusplus | ||
| 89 | } /* extern "C" */ | ||
| 90 | #endif /* __cplusplus */ | ||
| 91 | |||
| 92 | #endif /* !C_API_ADDONINSTANCE_AUDIO_DECODER_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_encoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_encoder.h new file mode 100644 index 0000000..6f24d1c --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_encoder.h | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_ADDONINSTANCE_AUDIO_ENCODER_H | ||
| 12 | #define C_API_ADDONINSTANCE_AUDIO_ENCODER_H | ||
| 13 | |||
| 14 | #include "../addon_base.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonProps_AudioEncoder | ||
| 22 | { | ||
| 23 | int dummy; | ||
| 24 | } AddonProps_AudioEncoder; | ||
| 25 | |||
| 26 | typedef struct AddonToKodiFuncTable_AudioEncoder | ||
| 27 | { | ||
| 28 | KODI_HANDLE kodiInstance; | ||
| 29 | int (*write)(KODI_HANDLE kodiInstance, const uint8_t* data, int len); | ||
| 30 | int64_t (*seek)(KODI_HANDLE kodiInstance, int64_t pos, int whence); | ||
| 31 | } AddonToKodiFuncTable_AudioEncoder; | ||
| 32 | |||
| 33 | struct AddonInstance_AudioEncoder; | ||
| 34 | typedef struct KodiToAddonFuncTable_AudioEncoder | ||
| 35 | { | ||
| 36 | KODI_HANDLE addonInstance; | ||
| 37 | bool(__cdecl* start)(const struct AddonInstance_AudioEncoder* instance, | ||
| 38 | int in_channels, | ||
| 39 | int in_rate, | ||
| 40 | int in_bits, | ||
| 41 | const char* title, | ||
| 42 | const char* artist, | ||
| 43 | const char* albumartist, | ||
| 44 | const char* album, | ||
| 45 | const char* year, | ||
| 46 | const char* track, | ||
| 47 | const char* genre, | ||
| 48 | const char* comment, | ||
| 49 | int track_length); | ||
| 50 | int(__cdecl* encode)(const struct AddonInstance_AudioEncoder* instance, | ||
| 51 | int num_bytes_read, | ||
| 52 | const uint8_t* pbt_stream); | ||
| 53 | bool(__cdecl* finish)(const struct AddonInstance_AudioEncoder* instance); | ||
| 54 | } KodiToAddonFuncTable_AudioEncoder; | ||
| 55 | |||
| 56 | typedef struct AddonInstance_AudioEncoder | ||
| 57 | { | ||
| 58 | struct AddonProps_AudioEncoder* props; | ||
| 59 | struct AddonToKodiFuncTable_AudioEncoder* toKodi; | ||
| 60 | struct KodiToAddonFuncTable_AudioEncoder* toAddon; | ||
| 61 | } AddonInstance_AudioEncoder; | ||
| 62 | |||
| 63 | #ifdef __cplusplus | ||
| 64 | } /* extern "C" */ | ||
| 65 | #endif /* __cplusplus */ | ||
| 66 | |||
| 67 | #endif /* !C_API_ADDONINSTANCE_AUDIO_ENCODER_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h new file mode 100644 index 0000000..c97fa5d --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h | |||
| @@ -0,0 +1,1212 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_ADDONINSTANCE_GAME_H | ||
| 12 | #define C_API_ADDONINSTANCE_GAME_H | ||
| 13 | |||
| 14 | #include "../addon_base.h" | ||
| 15 | |||
| 16 | #include <stddef.h> /* size_t */ | ||
| 17 | |||
| 18 | //============================================================================== | ||
| 19 | /// @ingroup cpp_kodi_addon_game_Defs | ||
| 20 | /// @brief **Port ID used when topology is unknown** | ||
| 21 | #define DEFAULT_PORT_ID "1" | ||
| 22 | //------------------------------------------------------------------------------ | ||
| 23 | |||
| 24 | #ifdef __cplusplus | ||
| 25 | extern "C" | ||
| 26 | { | ||
| 27 | #endif /* __cplusplus */ | ||
| 28 | |||
| 29 | //============================================================================ | ||
| 30 | /// @ingroup cpp_kodi_addon_game_Defs | ||
| 31 | /// @brief **Game add-on error codes** | ||
| 32 | /// | ||
| 33 | /// Used as return values on most Game related functions. | ||
| 34 | /// | ||
| 35 | typedef enum GAME_ERROR | ||
| 36 | { | ||
| 37 | /// @brief no error occurred | ||
| 38 | GAME_ERROR_NO_ERROR, | ||
| 39 | |||
| 40 | /// @brief an unknown error occurred | ||
| 41 | GAME_ERROR_UNKNOWN, | ||
| 42 | |||
| 43 | /// @brief the method that the frontend called is not implemented | ||
| 44 | GAME_ERROR_NOT_IMPLEMENTED, | ||
| 45 | |||
| 46 | /// @brief the command was rejected by the game client | ||
| 47 | GAME_ERROR_REJECTED, | ||
| 48 | |||
| 49 | /// @brief the parameters of the method that was called are invalid for this operation | ||
| 50 | GAME_ERROR_INVALID_PARAMETERS, | ||
| 51 | |||
| 52 | /// @brief the command failed | ||
| 53 | GAME_ERROR_FAILED, | ||
| 54 | |||
| 55 | /// @brief no game is loaded | ||
| 56 | GAME_ERROR_NOT_LOADED, | ||
| 57 | |||
| 58 | /// @brief game requires restricted resources | ||
| 59 | GAME_ERROR_RESTRICTED, | ||
| 60 | } GAME_ERROR; | ||
| 61 | //---------------------------------------------------------------------------- | ||
| 62 | |||
| 63 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 64 | /// @defgroup cpp_kodi_addon_game_Defs_AudioStream 1. Audio stream | ||
| 65 | /// @ingroup cpp_kodi_addon_game_Defs | ||
| 66 | /// @brief **The for Audio stream used data system** | ||
| 67 | /// | ||
| 68 | /// Used to give Addon currently used audio stream configuration on Kodi and | ||
| 69 | /// arrays to give related data to Kodi on callbacks. | ||
| 70 | /// | ||
| 71 | ///@{ | ||
| 72 | |||
| 73 | //============================================================================ | ||
| 74 | /// @brief **Stream Format** | ||
| 75 | /// | ||
| 76 | /// From Kodi requested specified audio sample format. | ||
| 77 | /// | ||
| 78 | typedef enum GAME_PCM_FORMAT | ||
| 79 | { | ||
| 80 | GAME_PCM_FORMAT_UNKNOWN, | ||
| 81 | |||
| 82 | /// @brief S16NE sample format | ||
| 83 | GAME_PCM_FORMAT_S16NE, | ||
| 84 | } GAME_PCM_FORMAT; | ||
| 85 | //---------------------------------------------------------------------------- | ||
| 86 | |||
| 87 | //============================================================================ | ||
| 88 | /// @brief **Audio channel** | ||
| 89 | /// | ||
| 90 | /// Channel identification flags. | ||
| 91 | /// | ||
| 92 | typedef enum GAME_AUDIO_CHANNEL | ||
| 93 | { | ||
| 94 | /// @brief Channel list terminator | ||
| 95 | GAME_CH_NULL, | ||
| 96 | |||
| 97 | /// @brief Channel front left | ||
| 98 | GAME_CH_FL, | ||
| 99 | |||
| 100 | /// @brief Channel front right | ||
| 101 | GAME_CH_FR, | ||
| 102 | |||
| 103 | /// @brief Channel front center | ||
| 104 | GAME_CH_FC, | ||
| 105 | |||
| 106 | /// @brief Channel Low Frequency Effects / Subwoofer | ||
| 107 | GAME_CH_LFE, | ||
| 108 | |||
| 109 | /// @brief Channel back left | ||
| 110 | GAME_CH_BL, | ||
| 111 | |||
| 112 | /// @brief Channel back right | ||
| 113 | GAME_CH_BR, | ||
| 114 | |||
| 115 | /// @brief Channel front left over center | ||
| 116 | GAME_CH_FLOC, | ||
| 117 | |||
| 118 | /// @brief Channel front right over center | ||
| 119 | GAME_CH_FROC, | ||
| 120 | |||
| 121 | /// @brief Channel back center | ||
| 122 | GAME_CH_BC, | ||
| 123 | |||
| 124 | /// @brief Channel surround/side left | ||
| 125 | GAME_CH_SL, | ||
| 126 | |||
| 127 | /// @brief Channel surround/side right | ||
| 128 | GAME_CH_SR, | ||
| 129 | |||
| 130 | /// @brief Channel top front left | ||
| 131 | GAME_CH_TFL, | ||
| 132 | |||
| 133 | /// @brief Channel top front right | ||
| 134 | GAME_CH_TFR, | ||
| 135 | |||
| 136 | /// @brief Channel top front center | ||
| 137 | GAME_CH_TFC, | ||
| 138 | |||
| 139 | /// @brief Channel top center | ||
| 140 | GAME_CH_TC, | ||
| 141 | |||
| 142 | /// @brief Channel top back left | ||
| 143 | GAME_CH_TBL, | ||
| 144 | |||
| 145 | /// @brief Channel top back right | ||
| 146 | GAME_CH_TBR, | ||
| 147 | |||
| 148 | /// @brief Channel top back center | ||
| 149 | GAME_CH_TBC, | ||
| 150 | |||
| 151 | /// @brief Channel bacl left over center | ||
| 152 | GAME_CH_BLOC, | ||
| 153 | |||
| 154 | /// @brief Channel back right over center | ||
| 155 | GAME_CH_BROC, | ||
| 156 | } GAME_AUDIO_CHANNEL; | ||
| 157 | //---------------------------------------------------------------------------- | ||
| 158 | |||
| 159 | //============================================================================ | ||
| 160 | /// @brief **Game audio stream properties** | ||
| 161 | /// | ||
| 162 | /// Used by Kodi to pass the currently required audio stream settings to the addon | ||
| 163 | /// | ||
| 164 | typedef struct game_stream_audio_properties | ||
| 165 | { | ||
| 166 | GAME_PCM_FORMAT format; | ||
| 167 | const GAME_AUDIO_CHANNEL* channel_map; | ||
| 168 | } ATTRIBUTE_PACKED game_stream_audio_properties; | ||
| 169 | //---------------------------------------------------------------------------- | ||
| 170 | |||
| 171 | //============================================================================ | ||
| 172 | /// @brief **Audio stream packet** | ||
| 173 | /// | ||
| 174 | /// This packet contains audio stream data passed to Kodi. | ||
| 175 | /// | ||
| 176 | typedef struct game_stream_audio_packet | ||
| 177 | { | ||
| 178 | /// @brief Pointer for audio stream data given to Kodi | ||
| 179 | const uint8_t* data; | ||
| 180 | |||
| 181 | /// @brief Size of data array | ||
| 182 | size_t size; | ||
| 183 | } ATTRIBUTE_PACKED game_stream_audio_packet; | ||
| 184 | //---------------------------------------------------------------------------- | ||
| 185 | |||
| 186 | ///@} | ||
| 187 | |||
| 188 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 189 | /// @defgroup cpp_kodi_addon_game_Defs_VideoStream 2. Video stream | ||
| 190 | /// @ingroup cpp_kodi_addon_game_Defs | ||
| 191 | /// @brief **The for Video stream used data system** | ||
| 192 | /// | ||
| 193 | /// Used to give Addon currently used video stream configuration on Kodi and | ||
| 194 | /// arrays to give related data to Kodi on callbacks. | ||
| 195 | /// | ||
| 196 | ///@{ | ||
| 197 | |||
| 198 | //============================================================================ | ||
| 199 | /// @brief **Pixel format** | ||
| 200 | /// | ||
| 201 | /// From Kodi requested specified video RGB color model format. | ||
| 202 | /// | ||
| 203 | typedef enum GAME_PIXEL_FORMAT | ||
| 204 | { | ||
| 205 | GAME_PIXEL_FORMAT_UNKNOWN, | ||
| 206 | |||
| 207 | /// @brief 0RGB8888 Format | ||
| 208 | GAME_PIXEL_FORMAT_0RGB8888, | ||
| 209 | |||
| 210 | /// @brief RGB565 Format | ||
| 211 | GAME_PIXEL_FORMAT_RGB565, | ||
| 212 | |||
| 213 | /// @brief 0RGB1555 Format | ||
| 214 | GAME_PIXEL_FORMAT_0RGB1555, | ||
| 215 | } GAME_PIXEL_FORMAT; | ||
| 216 | //---------------------------------------------------------------------------- | ||
| 217 | |||
| 218 | //============================================================================ | ||
| 219 | /// @brief **Video rotation position** | ||
| 220 | /// | ||
| 221 | /// To define position how video becomes shown. | ||
| 222 | /// | ||
| 223 | typedef enum GAME_VIDEO_ROTATION | ||
| 224 | { | ||
| 225 | /// @brief 0° and Without rotation | ||
| 226 | GAME_VIDEO_ROTATION_0, | ||
| 227 | |||
| 228 | /// @brief rotate 90° counterclockwise | ||
| 229 | GAME_VIDEO_ROTATION_90_CCW, | ||
| 230 | |||
| 231 | /// @brief rotate 180° counterclockwise | ||
| 232 | GAME_VIDEO_ROTATION_180_CCW, | ||
| 233 | |||
| 234 | /// @brief rotate 270° counterclockwise | ||
| 235 | GAME_VIDEO_ROTATION_270_CCW, | ||
| 236 | } GAME_VIDEO_ROTATION; | ||
| 237 | //---------------------------------------------------------------------------- | ||
| 238 | |||
| 239 | //============================================================================ | ||
| 240 | /// @brief **Game video stream properties** | ||
| 241 | /// | ||
| 242 | /// Used by Kodi to pass the currently required video stream settings to the addon | ||
| 243 | /// | ||
| 244 | typedef struct game_stream_video_properties | ||
| 245 | { | ||
| 246 | /// @brief The to used pixel format | ||
| 247 | GAME_PIXEL_FORMAT format; | ||
| 248 | |||
| 249 | /// @brief The nominal used width | ||
| 250 | unsigned int nominal_width; | ||
| 251 | |||
| 252 | /// @brief The nominal used height | ||
| 253 | unsigned int nominal_height; | ||
| 254 | |||
| 255 | /// @brief The maximal used width | ||
| 256 | unsigned int max_width; | ||
| 257 | |||
| 258 | /// @brief The maximal used height | ||
| 259 | unsigned int max_height; | ||
| 260 | |||
| 261 | /// @brief On video stream used aspect ration | ||
| 262 | /// | ||
| 263 | /// @note If aspect_ratio is <= 0.0, an aspect ratio of nominal_width / nominal_height is assumed | ||
| 264 | float aspect_ratio; | ||
| 265 | } ATTRIBUTE_PACKED game_stream_video_properties; | ||
| 266 | //---------------------------------------------------------------------------- | ||
| 267 | |||
| 268 | //============================================================================ | ||
| 269 | /// @brief **Video stream packet** | ||
| 270 | /// | ||
| 271 | /// This packet contains video stream data passed to Kodi. | ||
| 272 | /// | ||
| 273 | typedef struct game_stream_video_packet | ||
| 274 | { | ||
| 275 | /// @brief Video height | ||
| 276 | unsigned int width; | ||
| 277 | |||
| 278 | /// @brief Video width | ||
| 279 | unsigned int height; | ||
| 280 | |||
| 281 | /// @brief Width @ref GAME_VIDEO_ROTATION defined rotation angle. | ||
| 282 | GAME_VIDEO_ROTATION rotation; | ||
| 283 | |||
| 284 | /// @brief Pointer for video stream data given to Kodi | ||
| 285 | const uint8_t* data; | ||
| 286 | |||
| 287 | /// @brief Size of data array | ||
| 288 | size_t size; | ||
| 289 | } ATTRIBUTE_PACKED game_stream_video_packet; | ||
| 290 | //---------------------------------------------------------------------------- | ||
| 291 | |||
| 292 | ///@} | ||
| 293 | |||
| 294 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 295 | /// @defgroup cpp_kodi_addon_game_Defs_HardwareFramebuffer 3. Hardware framebuffer stream | ||
| 296 | /// @ingroup cpp_kodi_addon_game_Defs | ||
| 297 | /// @brief **Hardware framebuffer stream data** | ||
| 298 | /// | ||
| 299 | ///@{ | ||
| 300 | |||
| 301 | //============================================================================ | ||
| 302 | /// @brief **Hardware framebuffer type** | ||
| 303 | /// | ||
| 304 | typedef enum GAME_HW_CONTEXT_TYPE | ||
| 305 | { | ||
| 306 | /// @brief None context | ||
| 307 | GAME_HW_CONTEXT_NONE, | ||
| 308 | |||
| 309 | /// @brief OpenGL 2.x. Driver can choose to use latest compatibility context | ||
| 310 | GAME_HW_CONTEXT_OPENGL, | ||
| 311 | |||
| 312 | /// @brief OpenGL ES 2.0 | ||
| 313 | GAME_HW_CONTEXT_OPENGLES2, | ||
| 314 | |||
| 315 | /// @brief Modern desktop core GL context. Use major/minor fields to set GL version | ||
| 316 | GAME_HW_CONTEXT_OPENGL_CORE, | ||
| 317 | |||
| 318 | /// @brief OpenGL ES 3.0 | ||
| 319 | GAME_HW_CONTEXT_OPENGLES3, | ||
| 320 | |||
| 321 | /// @brief OpenGL ES 3.1+. Set major/minor fields. | ||
| 322 | GAME_HW_CONTEXT_OPENGLES_VERSION, | ||
| 323 | |||
| 324 | /// @brief Vulkan | ||
| 325 | GAME_HW_CONTEXT_VULKAN | ||
| 326 | } GAME_HW_CONTEXT_TYPE; | ||
| 327 | //---------------------------------------------------------------------------- | ||
| 328 | |||
| 329 | //============================================================================ | ||
| 330 | /// @brief **Hardware framebuffer properties** | ||
| 331 | /// | ||
| 332 | typedef struct game_stream_hw_framebuffer_properties | ||
| 333 | { | ||
| 334 | /// @brief The API to use. | ||
| 335 | /// | ||
| 336 | GAME_HW_CONTEXT_TYPE context_type; | ||
| 337 | |||
| 338 | /// @brief Set if render buffers should have depth component attached. | ||
| 339 | /// | ||
| 340 | /// @todo: Obsolete | ||
| 341 | /// | ||
| 342 | bool depth; | ||
| 343 | |||
| 344 | /// @brief Set if stencil buffers should be attached. | ||
| 345 | /// | ||
| 346 | /// If depth and stencil are true, a packed 24/8 buffer will be added. | ||
| 347 | /// Only attaching stencil is invalid and will be ignored. | ||
| 348 | /// | ||
| 349 | /// @todo: Obsolete. | ||
| 350 | /// | ||
| 351 | bool stencil; | ||
| 352 | |||
| 353 | /// @brief Use conventional bottom-left origin convention. | ||
| 354 | /// | ||
| 355 | /// If false, standard top-left origin semantics are used. | ||
| 356 | /// | ||
| 357 | /// @todo: Move to GL specific interface | ||
| 358 | /// | ||
| 359 | bool bottom_left_origin; | ||
| 360 | |||
| 361 | /// @brief Major version number for core GL context or GLES 3.1+. | ||
| 362 | unsigned int version_major; | ||
| 363 | |||
| 364 | /// @brief Minor version number for core GL context or GLES 3.1+. | ||
| 365 | unsigned int version_minor; | ||
| 366 | |||
| 367 | /// @brief If this is true, the frontend will go very far to avoid resetting context | ||
| 368 | /// in scenarios like toggling fullscreen, etc. | ||
| 369 | /// | ||
| 370 | /// @todo: Obsolete? Maybe frontend should just always assume this... | ||
| 371 | /// | ||
| 372 | /// The reset callback might still be called in extreme situations such as if | ||
| 373 | /// the context is lost beyond recovery. | ||
| 374 | /// | ||
| 375 | /// For optimal stability, set this to false, and allow context to be reset at | ||
| 376 | /// any time. | ||
| 377 | /// | ||
| 378 | bool cache_context; | ||
| 379 | |||
| 380 | /// @brief Creates a debug context. | ||
| 381 | bool debug_context; | ||
| 382 | } ATTRIBUTE_PACKED game_stream_hw_framebuffer_properties; | ||
| 383 | //---------------------------------------------------------------------------- | ||
| 384 | |||
| 385 | //============================================================================ | ||
| 386 | /// @brief **Hardware framebuffer buffer** | ||
| 387 | /// | ||
| 388 | typedef struct game_stream_hw_framebuffer_buffer | ||
| 389 | { | ||
| 390 | /// @brief | ||
| 391 | uintptr_t framebuffer; | ||
| 392 | } ATTRIBUTE_PACKED game_stream_hw_framebuffer_buffer; | ||
| 393 | //---------------------------------------------------------------------------- | ||
| 394 | |||
| 395 | //============================================================================ | ||
| 396 | /// @brief **Hardware framebuffer packet** | ||
| 397 | /// | ||
| 398 | typedef struct game_stream_hw_framebuffer_packet | ||
| 399 | { | ||
| 400 | /// @brief | ||
| 401 | uintptr_t framebuffer; | ||
| 402 | } ATTRIBUTE_PACKED game_stream_hw_framebuffer_packet; | ||
| 403 | //---------------------------------------------------------------------------- | ||
| 404 | |||
| 405 | //============================================================================ | ||
| 406 | /// @brief **Hardware framebuffer process function address** | ||
| 407 | /// | ||
| 408 | typedef void (*game_proc_address_t)(void); | ||
| 409 | //---------------------------------------------------------------------------- | ||
| 410 | |||
| 411 | ///@} | ||
| 412 | |||
| 413 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 414 | /// @defgroup cpp_kodi_addon_game_Defs_SoftwareFramebuffer 4. Software framebuffer stream | ||
| 415 | /// @ingroup cpp_kodi_addon_game_Defs | ||
| 416 | /// @brief **Software framebuffer stream data** | ||
| 417 | /// | ||
| 418 | ///@{ | ||
| 419 | |||
| 420 | //============================================================================ | ||
| 421 | /// @brief **Game video stream properties** | ||
| 422 | /// | ||
| 423 | /// Used by Kodi to pass the currently required video stream settings to the addon | ||
| 424 | /// | ||
| 425 | typedef game_stream_video_properties game_stream_sw_framebuffer_properties; | ||
| 426 | //---------------------------------------------------------------------------- | ||
| 427 | |||
| 428 | //============================================================================ | ||
| 429 | /// @brief **Hardware framebuffer type** | ||
| 430 | /// | ||
| 431 | typedef struct game_stream_sw_framebuffer_buffer | ||
| 432 | { | ||
| 433 | GAME_PIXEL_FORMAT format; | ||
| 434 | uint8_t* data; | ||
| 435 | size_t size; | ||
| 436 | } ATTRIBUTE_PACKED game_stream_sw_framebuffer_buffer; | ||
| 437 | //---------------------------------------------------------------------------- | ||
| 438 | |||
| 439 | //============================================================================ | ||
| 440 | /// @brief **Video stream packet** | ||
| 441 | /// | ||
| 442 | /// This packet contains video stream data passed to Kodi. | ||
| 443 | /// | ||
| 444 | typedef game_stream_video_packet game_stream_sw_framebuffer_packet; | ||
| 445 | //---------------------------------------------------------------------------- | ||
| 446 | |||
| 447 | ///@} | ||
| 448 | |||
| 449 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 450 | /// @defgroup cpp_kodi_addon_game_Defs_StreamTypes 5. Stream types | ||
| 451 | /// @ingroup cpp_kodi_addon_game_Defs | ||
| 452 | /// @brief **Stream types data** | ||
| 453 | /// | ||
| 454 | ///@{ | ||
| 455 | |||
| 456 | //============================================================================ | ||
| 457 | /// @brief **Game stream types** | ||
| 458 | /// | ||
| 459 | typedef enum GAME_STREAM_TYPE | ||
| 460 | { | ||
| 461 | /// @brief Unknown | ||
| 462 | GAME_STREAM_UNKNOWN, | ||
| 463 | |||
| 464 | /// @brief Audio stream | ||
| 465 | GAME_STREAM_AUDIO, | ||
| 466 | |||
| 467 | /// @brief Video stream | ||
| 468 | GAME_STREAM_VIDEO, | ||
| 469 | |||
| 470 | /// @brief Hardware framebuffer | ||
| 471 | GAME_STREAM_HW_FRAMEBUFFER, | ||
| 472 | |||
| 473 | /// @brief Software framebuffer | ||
| 474 | GAME_STREAM_SW_FRAMEBUFFER, | ||
| 475 | } GAME_STREAM_TYPE; | ||
| 476 | //---------------------------------------------------------------------------- | ||
| 477 | |||
| 478 | //============================================================================ | ||
| 479 | /// @brief **Immutable stream metadata** | ||
| 480 | /// | ||
| 481 | /// This metadata is provided when the stream is opened. If any stream | ||
| 482 | /// properties change, a new stream must be opened. | ||
| 483 | /// | ||
| 484 | typedef struct game_stream_properties | ||
| 485 | { | ||
| 486 | /// @brief | ||
| 487 | GAME_STREAM_TYPE type; | ||
| 488 | union | ||
| 489 | { | ||
| 490 | /// @brief | ||
| 491 | game_stream_audio_properties audio; | ||
| 492 | |||
| 493 | /// @brief | ||
| 494 | game_stream_video_properties video; | ||
| 495 | |||
| 496 | /// @brief | ||
| 497 | game_stream_hw_framebuffer_properties hw_framebuffer; | ||
| 498 | |||
| 499 | /// @brief | ||
| 500 | game_stream_sw_framebuffer_properties sw_framebuffer; | ||
| 501 | }; | ||
| 502 | } ATTRIBUTE_PACKED game_stream_properties; | ||
| 503 | //---------------------------------------------------------------------------- | ||
| 504 | |||
| 505 | //============================================================================ | ||
| 506 | /// @brief **Stream buffers for hardware rendering and zero-copy support** | ||
| 507 | /// | ||
| 508 | typedef struct game_stream_buffer | ||
| 509 | { | ||
| 510 | /// @brief | ||
| 511 | GAME_STREAM_TYPE type; | ||
| 512 | union | ||
| 513 | { | ||
| 514 | /// @brief | ||
| 515 | game_stream_hw_framebuffer_buffer hw_framebuffer; | ||
| 516 | |||
| 517 | /// @brief | ||
| 518 | game_stream_sw_framebuffer_buffer sw_framebuffer; | ||
| 519 | }; | ||
| 520 | } ATTRIBUTE_PACKED game_stream_buffer; | ||
| 521 | //---------------------------------------------------------------------------- | ||
| 522 | |||
| 523 | //============================================================================ | ||
| 524 | /// @brief **Stream packet and ephemeral metadata** | ||
| 525 | /// | ||
| 526 | /// This packet contains stream data and accompanying metadata. The metadata | ||
| 527 | /// is ephemeral, meaning it only applies to the current packet and can change | ||
| 528 | /// from packet to packet in the same stream. | ||
| 529 | /// | ||
| 530 | typedef struct game_stream_packet | ||
| 531 | { | ||
| 532 | /// @brief | ||
| 533 | GAME_STREAM_TYPE type; | ||
| 534 | union | ||
| 535 | { | ||
| 536 | /// @brief | ||
| 537 | game_stream_audio_packet audio; | ||
| 538 | |||
| 539 | /// @brief | ||
| 540 | game_stream_video_packet video; | ||
| 541 | |||
| 542 | /// @brief | ||
| 543 | game_stream_hw_framebuffer_packet hw_framebuffer; | ||
| 544 | |||
| 545 | /// @brief | ||
| 546 | game_stream_sw_framebuffer_packet sw_framebuffer; | ||
| 547 | }; | ||
| 548 | } ATTRIBUTE_PACKED game_stream_packet; | ||
| 549 | //---------------------------------------------------------------------------- | ||
| 550 | |||
| 551 | ///@} | ||
| 552 | |||
| 553 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 554 | /// @defgroup cpp_kodi_addon_game_Defs_GameTypes 6. Game types | ||
| 555 | /// @ingroup cpp_kodi_addon_game_Defs | ||
| 556 | /// @brief **Game types data** | ||
| 557 | /// | ||
| 558 | ///@{ | ||
| 559 | |||
| 560 | //============================================================================ | ||
| 561 | /// @brief **Game reguin definition** | ||
| 562 | /// | ||
| 563 | /// Returned from game_get_region() | ||
| 564 | typedef enum GAME_REGION | ||
| 565 | { | ||
| 566 | /// @brief Game region unknown | ||
| 567 | GAME_REGION_UNKNOWN, | ||
| 568 | |||
| 569 | /// @brief Game region NTSC | ||
| 570 | GAME_REGION_NTSC, | ||
| 571 | |||
| 572 | /// @brief Game region PAL | ||
| 573 | GAME_REGION_PAL, | ||
| 574 | } GAME_REGION; | ||
| 575 | //---------------------------------------------------------------------------- | ||
| 576 | |||
| 577 | //============================================================================ | ||
| 578 | /// @brief **Special game types passed into game_load_game_special().** | ||
| 579 | /// | ||
| 580 | /// @remark Only used when multiple ROMs are required. | ||
| 581 | /// | ||
| 582 | typedef enum SPECIAL_GAME_TYPE | ||
| 583 | { | ||
| 584 | /// @brief Game Type BSX | ||
| 585 | SPECIAL_GAME_TYPE_BSX, | ||
| 586 | |||
| 587 | /// @brief Game Type BSX slotted | ||
| 588 | SPECIAL_GAME_TYPE_BSX_SLOTTED, | ||
| 589 | |||
| 590 | /// @brief Game Type sufami turbo | ||
| 591 | SPECIAL_GAME_TYPE_SUFAMI_TURBO, | ||
| 592 | |||
| 593 | /// @brief Game Type super game boy | ||
| 594 | SPECIAL_GAME_TYPE_SUPER_GAME_BOY, | ||
| 595 | } SPECIAL_GAME_TYPE; | ||
| 596 | //---------------------------------------------------------------------------- | ||
| 597 | |||
| 598 | //============================================================================ | ||
| 599 | /// @brief **Game Memory** | ||
| 600 | /// | ||
| 601 | typedef enum GAME_MEMORY | ||
| 602 | { | ||
| 603 | /// @brief Passed to game_get_memory_data/size(). If the memory type doesn't apply | ||
| 604 | /// to the implementation NULL/0 can be returned. | ||
| 605 | GAME_MEMORY_MASK = 0xff, | ||
| 606 | |||
| 607 | /// @brief Regular save ram. | ||
| 608 | /// | ||
| 609 | /// This ram is usually found on a game cartridge, backed | ||
| 610 | /// up by a battery. If save game data is too complex for a single memory | ||
| 611 | /// buffer, the SYSTEM_DIRECTORY environment callback can be used. | ||
| 612 | GAME_MEMORY_SAVE_RAM = 0, | ||
| 613 | |||
| 614 | /// @brief Some games have a built-in clock to keep track of time. | ||
| 615 | /// | ||
| 616 | /// This memory is usually just a couple of bytes to keep track of time. | ||
| 617 | GAME_MEMORY_RTC = 1, | ||
| 618 | |||
| 619 | /// @brief System ram lets a frontend peek into a game systems main RAM | ||
| 620 | GAME_MEMORY_SYSTEM_RAM = 2, | ||
| 621 | |||
| 622 | /// @brief Video ram lets a frontend peek into a game systems video RAM (VRAM) | ||
| 623 | GAME_MEMORY_VIDEO_RAM = 3, | ||
| 624 | |||
| 625 | /// @brief Special memory type | ||
| 626 | GAME_MEMORY_SNES_BSX_RAM = ((1 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 627 | |||
| 628 | /// @brief Special memory type | ||
| 629 | GAME_MEMORY_SNES_BSX_PRAM = ((2 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 630 | |||
| 631 | /// @brief Special memory type | ||
| 632 | GAME_MEMORY_SNES_SUFAMI_TURBO_A_RAM = ((3 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 633 | |||
| 634 | /// @brief Special memory type | ||
| 635 | GAME_MEMORY_SNES_SUFAMI_TURBO_B_RAM = ((4 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 636 | |||
| 637 | /// @brief Special memory type | ||
| 638 | GAME_MEMORY_SNES_GAME_BOY_RAM = ((5 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 639 | |||
| 640 | /// @brief Special memory type | ||
| 641 | GAME_MEMORY_SNES_GAME_BOY_RTC = ((6 << 8) | GAME_MEMORY_RTC), | ||
| 642 | } GAME_MEMORY; | ||
| 643 | //---------------------------------------------------------------------------- | ||
| 644 | |||
| 645 | //============================================================================ | ||
| 646 | /// @brief **ID values for SIMD CPU features** | ||
| 647 | typedef enum GAME_SIMD | ||
| 648 | { | ||
| 649 | /// @brief SIMD CPU SSE | ||
| 650 | GAME_SIMD_SSE = (1 << 0), | ||
| 651 | |||
| 652 | /// @brief SIMD CPU SSE2 | ||
| 653 | GAME_SIMD_SSE2 = (1 << 1), | ||
| 654 | |||
| 655 | /// @brief SIMD CPU VMX | ||
| 656 | GAME_SIMD_VMX = (1 << 2), | ||
| 657 | |||
| 658 | /// @brief SIMD CPU VMX128 | ||
| 659 | GAME_SIMD_VMX128 = (1 << 3), | ||
| 660 | |||
| 661 | /// @brief SIMD CPU AVX | ||
| 662 | GAME_SIMD_AVX = (1 << 4), | ||
| 663 | |||
| 664 | /// @brief SIMD CPU NEON | ||
| 665 | GAME_SIMD_NEON = (1 << 5), | ||
| 666 | |||
| 667 | /// @brief SIMD CPU SSE3 | ||
| 668 | GAME_SIMD_SSE3 = (1 << 6), | ||
| 669 | |||
| 670 | /// @brief SIMD CPU SSSE3 | ||
| 671 | GAME_SIMD_SSSE3 = (1 << 7), | ||
| 672 | |||
| 673 | /// @brief SIMD CPU MMX | ||
| 674 | GAME_SIMD_MMX = (1 << 8), | ||
| 675 | |||
| 676 | /// @brief SIMD CPU MMXEXT | ||
| 677 | GAME_SIMD_MMXEXT = (1 << 9), | ||
| 678 | |||
| 679 | /// @brief SIMD CPU SSE4 | ||
| 680 | GAME_SIMD_SSE4 = (1 << 10), | ||
| 681 | |||
| 682 | /// @brief SIMD CPU SSE42 | ||
| 683 | GAME_SIMD_SSE42 = (1 << 11), | ||
| 684 | |||
| 685 | /// @brief SIMD CPU AVX2 | ||
| 686 | GAME_SIMD_AVX2 = (1 << 12), | ||
| 687 | |||
| 688 | /// @brief SIMD CPU VFPU | ||
| 689 | GAME_SIMD_VFPU = (1 << 13), | ||
| 690 | } GAME_SIMD; | ||
| 691 | //---------------------------------------------------------------------------- | ||
| 692 | |||
| 693 | ///@} | ||
| 694 | |||
| 695 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 696 | /// @defgroup cpp_kodi_addon_game_Defs_InputTypes 7. Input types | ||
| 697 | /// @ingroup cpp_kodi_addon_game_Defs | ||
| 698 | /// @brief **Input types** | ||
| 699 | /// | ||
| 700 | ///@{ | ||
| 701 | |||
| 702 | //============================================================================ | ||
| 703 | /// @brief | ||
| 704 | typedef enum GAME_INPUT_EVENT_SOURCE | ||
| 705 | { | ||
| 706 | /// @brief | ||
| 707 | GAME_INPUT_EVENT_DIGITAL_BUTTON, | ||
| 708 | |||
| 709 | /// @brief | ||
| 710 | GAME_INPUT_EVENT_ANALOG_BUTTON, | ||
| 711 | |||
| 712 | /// @brief | ||
| 713 | GAME_INPUT_EVENT_AXIS, | ||
| 714 | |||
| 715 | /// @brief | ||
| 716 | GAME_INPUT_EVENT_ANALOG_STICK, | ||
| 717 | |||
| 718 | /// @brief | ||
| 719 | GAME_INPUT_EVENT_ACCELEROMETER, | ||
| 720 | |||
| 721 | /// @brief | ||
| 722 | GAME_INPUT_EVENT_KEY, | ||
| 723 | |||
| 724 | /// @brief | ||
| 725 | GAME_INPUT_EVENT_RELATIVE_POINTER, | ||
| 726 | |||
| 727 | /// @brief | ||
| 728 | GAME_INPUT_EVENT_ABSOLUTE_POINTER, | ||
| 729 | |||
| 730 | /// @brief | ||
| 731 | GAME_INPUT_EVENT_MOTOR, | ||
| 732 | } GAME_INPUT_EVENT_SOURCE; | ||
| 733 | //---------------------------------------------------------------------------- | ||
| 734 | |||
| 735 | //============================================================================ | ||
| 736 | /// @brief | ||
| 737 | typedef enum GAME_KEY_MOD | ||
| 738 | { | ||
| 739 | /// @brief | ||
| 740 | GAME_KEY_MOD_NONE = 0x0000, | ||
| 741 | |||
| 742 | /// @brief | ||
| 743 | GAME_KEY_MOD_SHIFT = 0x0001, | ||
| 744 | |||
| 745 | /// @brief | ||
| 746 | GAME_KEY_MOD_CTRL = 0x0002, | ||
| 747 | |||
| 748 | /// @brief | ||
| 749 | GAME_KEY_MOD_ALT = 0x0004, | ||
| 750 | |||
| 751 | /// @brief | ||
| 752 | GAME_KEY_MOD_META = 0x0008, | ||
| 753 | |||
| 754 | /// @brief | ||
| 755 | GAME_KEY_MOD_SUPER = 0x0010, | ||
| 756 | |||
| 757 | /// @brief | ||
| 758 | GAME_KEY_MOD_NUMLOCK = 0x0100, | ||
| 759 | |||
| 760 | /// @brief | ||
| 761 | GAME_KEY_MOD_CAPSLOCK = 0x0200, | ||
| 762 | |||
| 763 | /// @brief | ||
| 764 | GAME_KEY_MOD_SCROLLOCK = 0x0400, | ||
| 765 | } GAME_KEY_MOD; | ||
| 766 | //---------------------------------------------------------------------------- | ||
| 767 | |||
| 768 | //============================================================================ | ||
| 769 | /// @brief Type of port on the virtual game console | ||
| 770 | typedef enum GAME_PORT_TYPE | ||
| 771 | { | ||
| 772 | /// @brief Game port unknown | ||
| 773 | GAME_PORT_UNKNOWN, | ||
| 774 | |||
| 775 | /// @brief Game port Keyboard | ||
| 776 | GAME_PORT_KEYBOARD, | ||
| 777 | |||
| 778 | /// @brief Game port mouse | ||
| 779 | GAME_PORT_MOUSE, | ||
| 780 | |||
| 781 | /// @brief Game port controller | ||
| 782 | GAME_PORT_CONTROLLER, | ||
| 783 | } GAME_PORT_TYPE; | ||
| 784 | //---------------------------------------------------------------------------- | ||
| 785 | |||
| 786 | /*! @cond PRIVATE */ | ||
| 787 | /*! | ||
| 788 | * @brief "C" Game add-on controller layout. | ||
| 789 | * | ||
| 790 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 791 | * | ||
| 792 | * See @ref AddonGameControllerLayout for description of values. | ||
| 793 | */ | ||
| 794 | typedef struct game_controller_layout | ||
| 795 | { | ||
| 796 | char* controller_id; | ||
| 797 | bool provides_input; // False for multitaps | ||
| 798 | char** digital_buttons; | ||
| 799 | unsigned int digital_button_count; | ||
| 800 | char** analog_buttons; | ||
| 801 | unsigned int analog_button_count; | ||
| 802 | char** analog_sticks; | ||
| 803 | unsigned int analog_stick_count; | ||
| 804 | char** accelerometers; | ||
| 805 | unsigned int accelerometer_count; | ||
| 806 | char** keys; | ||
| 807 | unsigned int key_count; | ||
| 808 | char** rel_pointers; | ||
| 809 | unsigned int rel_pointer_count; | ||
| 810 | char** abs_pointers; | ||
| 811 | unsigned int abs_pointer_count; | ||
| 812 | char** motors; | ||
| 813 | unsigned int motor_count; | ||
| 814 | } ATTRIBUTE_PACKED game_controller_layout; | ||
| 815 | /*! @endcond */ | ||
| 816 | |||
| 817 | struct game_input_port; | ||
| 818 | |||
| 819 | //============================================================================ | ||
| 820 | /// @brief Device that can provide input | ||
| 821 | typedef struct game_input_device | ||
| 822 | { | ||
| 823 | /// @brief ID used in the Kodi controller API | ||
| 824 | const char* controller_id; | ||
| 825 | |||
| 826 | /// @brief | ||
| 827 | const char* port_address; | ||
| 828 | |||
| 829 | /// @brief | ||
| 830 | struct game_input_port* available_ports; | ||
| 831 | |||
| 832 | /// @brief | ||
| 833 | unsigned int port_count; | ||
| 834 | } ATTRIBUTE_PACKED game_input_device; | ||
| 835 | //---------------------------------------------------------------------------- | ||
| 836 | |||
| 837 | //============================================================================ | ||
| 838 | /// @brief Port that can provide input | ||
| 839 | /// | ||
| 840 | /// Ports can accept multiple devices and devices can have multiple ports, so | ||
| 841 | /// the topology of possible configurations is a tree structure of alternating | ||
| 842 | /// port and device nodes. | ||
| 843 | /// | ||
| 844 | typedef struct game_input_port | ||
| 845 | { | ||
| 846 | /// @brief | ||
| 847 | GAME_PORT_TYPE type; | ||
| 848 | |||
| 849 | /// @brief Required for GAME_PORT_CONTROLLER type | ||
| 850 | const char* port_id; | ||
| 851 | |||
| 852 | /// @brief | ||
| 853 | game_input_device* accepted_devices; | ||
| 854 | |||
| 855 | /// @brief | ||
| 856 | unsigned int device_count; | ||
| 857 | } ATTRIBUTE_PACKED game_input_port; | ||
| 858 | //---------------------------------------------------------------------------- | ||
| 859 | |||
| 860 | //============================================================================ | ||
| 861 | /// @brief The input topology is the possible ways to connect input devices | ||
| 862 | /// | ||
| 863 | /// This represents the logical topology, which is the possible connections that | ||
| 864 | /// the game client's logic can handle. It is strictly a subset of the physical | ||
| 865 | /// topology. Loops are not allowed. | ||
| 866 | /// | ||
| 867 | typedef struct game_input_topology | ||
| 868 | { | ||
| 869 | /// @brief The list of ports on the virtual game console | ||
| 870 | game_input_port* ports; | ||
| 871 | |||
| 872 | /// @brief The number of ports | ||
| 873 | unsigned int port_count; | ||
| 874 | |||
| 875 | /// @brief A limit on the number of input-providing devices, or -1 for no limit | ||
| 876 | int player_limit; | ||
| 877 | } ATTRIBUTE_PACKED game_input_topology; | ||
| 878 | //---------------------------------------------------------------------------- | ||
| 879 | |||
| 880 | //============================================================================ | ||
| 881 | /// @brief | ||
| 882 | typedef struct game_digital_button_event | ||
| 883 | { | ||
| 884 | /// @brief | ||
| 885 | bool pressed; | ||
| 886 | } ATTRIBUTE_PACKED game_digital_button_event; | ||
| 887 | //---------------------------------------------------------------------------- | ||
| 888 | |||
| 889 | //============================================================================ | ||
| 890 | /// @brief | ||
| 891 | typedef struct game_analog_button_event | ||
| 892 | { | ||
| 893 | /// @brief | ||
| 894 | float magnitude; | ||
| 895 | } ATTRIBUTE_PACKED game_analog_button_event; | ||
| 896 | //---------------------------------------------------------------------------- | ||
| 897 | |||
| 898 | //============================================================================ | ||
| 899 | /// @brief | ||
| 900 | typedef struct game_axis_event | ||
| 901 | { | ||
| 902 | /// @brief | ||
| 903 | float position; | ||
| 904 | } ATTRIBUTE_PACKED game_axis_event; | ||
| 905 | //---------------------------------------------------------------------------- | ||
| 906 | |||
| 907 | //============================================================================ | ||
| 908 | /// @brief | ||
| 909 | typedef struct game_analog_stick_event | ||
| 910 | { | ||
| 911 | /// @brief | ||
| 912 | float x; | ||
| 913 | |||
| 914 | /// @brief | ||
| 915 | float y; | ||
| 916 | } ATTRIBUTE_PACKED game_analog_stick_event; | ||
| 917 | //---------------------------------------------------------------------------- | ||
| 918 | |||
| 919 | //============================================================================ | ||
| 920 | /// @brief | ||
| 921 | typedef struct game_accelerometer_event | ||
| 922 | { | ||
| 923 | /// @brief | ||
| 924 | float x; | ||
| 925 | |||
| 926 | /// @brief | ||
| 927 | float y; | ||
| 928 | |||
| 929 | /// @brief | ||
| 930 | float z; | ||
| 931 | } ATTRIBUTE_PACKED game_accelerometer_event; | ||
| 932 | //---------------------------------------------------------------------------- | ||
| 933 | |||
| 934 | //============================================================================ | ||
| 935 | /// @brief | ||
| 936 | typedef struct game_key_event | ||
| 937 | { | ||
| 938 | /// @brief | ||
| 939 | bool pressed; | ||
| 940 | |||
| 941 | /// @brief If the keypress generates a printing character | ||
| 942 | /// | ||
| 943 | /// The unicode value contains the character generated. If the key is a | ||
| 944 | /// non-printing character, e.g. a function or arrow key, the unicode value | ||
| 945 | /// is zero. | ||
| 946 | uint32_t unicode; | ||
| 947 | |||
| 948 | /// @brief | ||
| 949 | GAME_KEY_MOD modifiers; | ||
| 950 | } ATTRIBUTE_PACKED game_key_event; | ||
| 951 | //---------------------------------------------------------------------------- | ||
| 952 | |||
| 953 | //============================================================================ | ||
| 954 | /// @brief | ||
| 955 | typedef struct game_rel_pointer_event | ||
| 956 | { | ||
| 957 | /// @brief | ||
| 958 | int x; | ||
| 959 | |||
| 960 | /// @brief | ||
| 961 | int y; | ||
| 962 | } ATTRIBUTE_PACKED game_rel_pointer_event; | ||
| 963 | //---------------------------------------------------------------------------- | ||
| 964 | |||
| 965 | //============================================================================ | ||
| 966 | /// @brief | ||
| 967 | typedef struct game_abs_pointer_event | ||
| 968 | { | ||
| 969 | /// @brief | ||
| 970 | bool pressed; | ||
| 971 | |||
| 972 | /// @brief | ||
| 973 | float x; | ||
| 974 | |||
| 975 | /// @brief | ||
| 976 | float y; | ||
| 977 | } ATTRIBUTE_PACKED game_abs_pointer_event; | ||
| 978 | //---------------------------------------------------------------------------- | ||
| 979 | |||
| 980 | //============================================================================ | ||
| 981 | /// @brief | ||
| 982 | typedef struct game_motor_event | ||
| 983 | { | ||
| 984 | /// @brief | ||
| 985 | float magnitude; | ||
| 986 | } ATTRIBUTE_PACKED game_motor_event; | ||
| 987 | //---------------------------------------------------------------------------- | ||
| 988 | |||
| 989 | //============================================================================ | ||
| 990 | /// @brief | ||
| 991 | typedef struct game_input_event | ||
| 992 | { | ||
| 993 | /// @brief | ||
| 994 | GAME_INPUT_EVENT_SOURCE type; | ||
| 995 | |||
| 996 | /// @brief | ||
| 997 | const char* controller_id; | ||
| 998 | |||
| 999 | /// @brief | ||
| 1000 | GAME_PORT_TYPE port_type; | ||
| 1001 | |||
| 1002 | /// @brief | ||
| 1003 | const char* port_address; | ||
| 1004 | |||
| 1005 | /// @brief | ||
| 1006 | const char* feature_name; | ||
| 1007 | union | ||
| 1008 | { | ||
| 1009 | /// @brief | ||
| 1010 | struct game_digital_button_event digital_button; | ||
| 1011 | |||
| 1012 | /// @brief | ||
| 1013 | struct game_analog_button_event analog_button; | ||
| 1014 | |||
| 1015 | /// @brief | ||
| 1016 | struct game_axis_event axis; | ||
| 1017 | |||
| 1018 | /// @brief | ||
| 1019 | struct game_analog_stick_event analog_stick; | ||
| 1020 | |||
| 1021 | /// @brief | ||
| 1022 | struct game_accelerometer_event accelerometer; | ||
| 1023 | |||
| 1024 | /// @brief | ||
| 1025 | struct game_key_event key; | ||
| 1026 | |||
| 1027 | /// @brief | ||
| 1028 | struct game_rel_pointer_event rel_pointer; | ||
| 1029 | |||
| 1030 | /// @brief | ||
| 1031 | struct game_abs_pointer_event abs_pointer; | ||
| 1032 | |||
| 1033 | /// @brief | ||
| 1034 | struct game_motor_event motor; | ||
| 1035 | }; | ||
| 1036 | } ATTRIBUTE_PACKED game_input_event; | ||
| 1037 | //---------------------------------------------------------------------------- | ||
| 1038 | |||
| 1039 | ///@} | ||
| 1040 | |||
| 1041 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 1042 | /// @defgroup cpp_kodi_addon_game_Defs_EnvironmentTypes 8. Environment types | ||
| 1043 | /// @ingroup cpp_kodi_addon_game_Defs | ||
| 1044 | /// @brief **Environment types** | ||
| 1045 | /// | ||
| 1046 | ///@{ | ||
| 1047 | |||
| 1048 | //============================================================================ | ||
| 1049 | /// @brief Game system timing | ||
| 1050 | /// | ||
| 1051 | struct game_system_timing | ||
| 1052 | { | ||
| 1053 | /// @brief FPS of video content. | ||
| 1054 | double fps; | ||
| 1055 | |||
| 1056 | /// @brief Sampling rate of audio. | ||
| 1057 | double sample_rate; | ||
| 1058 | }; | ||
| 1059 | //---------------------------------------------------------------------------- | ||
| 1060 | |||
| 1061 | ///@} | ||
| 1062 | |||
| 1063 | |||
| 1064 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 1065 | |||
| 1066 | /*! | ||
| 1067 | * @brief Game properties | ||
| 1068 | * | ||
| 1069 | * Not to be used outside this header. | ||
| 1070 | */ | ||
| 1071 | typedef struct AddonProps_Game | ||
| 1072 | { | ||
| 1073 | /*! | ||
| 1074 | * The path of the game client being loaded. | ||
| 1075 | */ | ||
| 1076 | const char* game_client_dll_path; | ||
| 1077 | |||
| 1078 | /*! | ||
| 1079 | * Paths to proxy DLLs used to load the game client. | ||
| 1080 | */ | ||
| 1081 | const char** proxy_dll_paths; | ||
| 1082 | |||
| 1083 | /*! | ||
| 1084 | * Number of proxy DLL paths provided. | ||
| 1085 | */ | ||
| 1086 | unsigned int proxy_dll_count; | ||
| 1087 | |||
| 1088 | /*! | ||
| 1089 | * The "system" directories of the frontend. These directories can be used to | ||
| 1090 | * store system-specific ROMs such as BIOSes, configuration data, etc. | ||
| 1091 | */ | ||
| 1092 | const char** resource_directories; | ||
| 1093 | |||
| 1094 | /*! | ||
| 1095 | * Number of resource directories provided | ||
| 1096 | */ | ||
| 1097 | unsigned int resource_directory_count; | ||
| 1098 | |||
| 1099 | /*! | ||
| 1100 | * The writable directory of the frontend. This directory can be used to store | ||
| 1101 | * SRAM, memory cards, high scores, etc, if the game client cannot use the | ||
| 1102 | * regular memory interface, GetMemoryData(). | ||
| 1103 | */ | ||
| 1104 | const char* profile_directory; | ||
| 1105 | |||
| 1106 | /*! | ||
| 1107 | * The value of the <supports_vfs> property from addon.xml | ||
| 1108 | */ | ||
| 1109 | bool supports_vfs; | ||
| 1110 | |||
| 1111 | /*! | ||
| 1112 | * The extensions in the <extensions> property from addon.xml | ||
| 1113 | */ | ||
| 1114 | const char** extensions; | ||
| 1115 | |||
| 1116 | /*! | ||
| 1117 | * Number of extensions provided | ||
| 1118 | */ | ||
| 1119 | unsigned int extension_count; | ||
| 1120 | } AddonProps_Game; | ||
| 1121 | |||
| 1122 | typedef void* KODI_GAME_STREAM_HANDLE; | ||
| 1123 | |||
| 1124 | /*! Structure to transfer the methods from kodi_game_dll.h to Kodi */ | ||
| 1125 | |||
| 1126 | struct AddonInstance_Game; | ||
| 1127 | |||
| 1128 | /*! | ||
| 1129 | * @brief Game callbacks | ||
| 1130 | * | ||
| 1131 | * Not to be used outside this header. | ||
| 1132 | */ | ||
| 1133 | typedef struct AddonToKodiFuncTable_Game | ||
| 1134 | { | ||
| 1135 | KODI_HANDLE kodiInstance; | ||
| 1136 | |||
| 1137 | void (*CloseGame)(KODI_HANDLE kodiInstance); | ||
| 1138 | KODI_GAME_STREAM_HANDLE (*OpenStream)(KODI_HANDLE, const struct game_stream_properties*); | ||
| 1139 | bool (*GetStreamBuffer)(KODI_HANDLE, | ||
| 1140 | KODI_GAME_STREAM_HANDLE, | ||
| 1141 | unsigned int, | ||
| 1142 | unsigned int, | ||
| 1143 | struct game_stream_buffer*); | ||
| 1144 | void (*AddStreamData)(KODI_HANDLE, KODI_GAME_STREAM_HANDLE, const struct game_stream_packet*); | ||
| 1145 | void (*ReleaseStreamBuffer)(KODI_HANDLE, KODI_GAME_STREAM_HANDLE, struct game_stream_buffer*); | ||
| 1146 | void (*CloseStream)(KODI_HANDLE, KODI_GAME_STREAM_HANDLE); | ||
| 1147 | game_proc_address_t (*HwGetProcAddress)(KODI_HANDLE kodiInstance, const char* symbol); | ||
| 1148 | bool (*InputEvent)(KODI_HANDLE kodiInstance, const struct game_input_event* event); | ||
| 1149 | } AddonToKodiFuncTable_Game; | ||
| 1150 | |||
| 1151 | /*! | ||
| 1152 | * @brief Game function hooks | ||
| 1153 | * | ||
| 1154 | * Not to be used outside this header. | ||
| 1155 | */ | ||
| 1156 | typedef struct KodiToAddonFuncTable_Game | ||
| 1157 | { | ||
| 1158 | KODI_HANDLE addonInstance; | ||
| 1159 | |||
| 1160 | GAME_ERROR(__cdecl* LoadGame)(const struct AddonInstance_Game*, const char*); | ||
| 1161 | GAME_ERROR(__cdecl* LoadGameSpecial) | ||
| 1162 | (const struct AddonInstance_Game*, enum SPECIAL_GAME_TYPE, const char**, size_t); | ||
| 1163 | GAME_ERROR(__cdecl* LoadStandalone)(const struct AddonInstance_Game*); | ||
| 1164 | GAME_ERROR(__cdecl* UnloadGame)(const struct AddonInstance_Game*); | ||
| 1165 | GAME_ERROR(__cdecl* GetGameTiming) | ||
| 1166 | (const struct AddonInstance_Game*, struct game_system_timing*); | ||
| 1167 | GAME_REGION(__cdecl* GetRegion)(const struct AddonInstance_Game*); | ||
| 1168 | bool(__cdecl* RequiresGameLoop)(const struct AddonInstance_Game*); | ||
| 1169 | GAME_ERROR(__cdecl* RunFrame)(const struct AddonInstance_Game*); | ||
| 1170 | GAME_ERROR(__cdecl* Reset)(const struct AddonInstance_Game*); | ||
| 1171 | GAME_ERROR(__cdecl* HwContextReset)(const struct AddonInstance_Game*); | ||
| 1172 | GAME_ERROR(__cdecl* HwContextDestroy)(const struct AddonInstance_Game*); | ||
| 1173 | bool(__cdecl* HasFeature)(const struct AddonInstance_Game*, const char*, const char*); | ||
| 1174 | game_input_topology*(__cdecl* GetTopology)(const struct AddonInstance_Game*); | ||
| 1175 | void(__cdecl* FreeTopology)(const struct AddonInstance_Game*, struct game_input_topology*); | ||
| 1176 | void(__cdecl* SetControllerLayouts)(const struct AddonInstance_Game*, | ||
| 1177 | const struct game_controller_layout*, | ||
| 1178 | unsigned int); | ||
| 1179 | bool(__cdecl* EnableKeyboard)(const struct AddonInstance_Game*, bool, const char*); | ||
| 1180 | bool(__cdecl* EnableMouse)(const struct AddonInstance_Game*, bool, const char*); | ||
| 1181 | bool(__cdecl* ConnectController)(const struct AddonInstance_Game*, | ||
| 1182 | bool, | ||
| 1183 | const char*, | ||
| 1184 | const char*); | ||
| 1185 | bool(__cdecl* InputEvent)(const struct AddonInstance_Game*, const struct game_input_event*); | ||
| 1186 | size_t(__cdecl* SerializeSize)(const struct AddonInstance_Game*); | ||
| 1187 | GAME_ERROR(__cdecl* Serialize)(const struct AddonInstance_Game*, uint8_t*, size_t); | ||
| 1188 | GAME_ERROR(__cdecl* Deserialize)(const struct AddonInstance_Game*, const uint8_t*, size_t); | ||
| 1189 | GAME_ERROR(__cdecl* CheatReset)(const struct AddonInstance_Game*); | ||
| 1190 | GAME_ERROR(__cdecl* GetMemory) | ||
| 1191 | (const struct AddonInstance_Game*, enum GAME_MEMORY, uint8_t**, size_t*); | ||
| 1192 | GAME_ERROR(__cdecl* SetCheat) | ||
| 1193 | (const struct AddonInstance_Game*, unsigned int, bool, const char*); | ||
| 1194 | } KodiToAddonFuncTable_Game; | ||
| 1195 | |||
| 1196 | /*! | ||
| 1197 | * @brief Game instance | ||
| 1198 | * | ||
| 1199 | * Not to be used outside this header. | ||
| 1200 | */ | ||
| 1201 | typedef struct AddonInstance_Game | ||
| 1202 | { | ||
| 1203 | struct AddonProps_Game* props; | ||
| 1204 | struct AddonToKodiFuncTable_Game* toKodi; | ||
| 1205 | struct KodiToAddonFuncTable_Game* toAddon; | ||
| 1206 | } AddonInstance_Game; | ||
| 1207 | |||
| 1208 | #ifdef __cplusplus | ||
| 1209 | } | ||
| 1210 | #endif /* __cplusplus */ | ||
| 1211 | |||
| 1212 | #endif /* !C_API_ADDONINSTANCE_GAME_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h index 595a5dc..6455b38 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h | |||
| @@ -8,6 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_ADDONINSTANCE_IMAGE_DECODER_H | ||
| 12 | #define C_API_ADDONINSTANCE_IMAGE_DECODER_H | ||
| 13 | |||
| 11 | #include "../addon_base.h" | 14 | #include "../addon_base.h" |
| 12 | 15 | ||
| 13 | #ifdef __cplusplus | 16 | #ifdef __cplusplus |
| @@ -76,3 +79,5 @@ extern "C" | |||
| 76 | #ifdef __cplusplus | 79 | #ifdef __cplusplus |
| 77 | } /* extern "C" */ | 80 | } /* extern "C" */ |
| 78 | #endif /* __cplusplus */ | 81 | #endif /* __cplusplus */ |
| 82 | |||
| 83 | #endif /* !C_API_ADDONINSTANCE_IMAGE_DECODER_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h new file mode 100644 index 0000000..393f34a --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h | |||
| @@ -0,0 +1,709 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_ADDONINSTANCE_PERIPHERAL_H | ||
| 12 | #define C_API_ADDONINSTANCE_PERIPHERAL_H | ||
| 13 | |||
| 14 | #include "../addon_base.h" | ||
| 15 | |||
| 16 | /* indicates a joystick has no preference for port number */ | ||
| 17 | #define NO_PORT_REQUESTED (-1) | ||
| 18 | |||
| 19 | /* joystick's driver button/hat/axis index is unknown */ | ||
| 20 | #define DRIVER_INDEX_UNKNOWN (-1) | ||
| 21 | |||
| 22 | #ifdef __cplusplus | ||
| 23 | extern "C" | ||
| 24 | { | ||
| 25 | #endif /* __cplusplus */ | ||
| 26 | |||
| 27 | //============================================================================ | ||
| 28 | /// @defgroup cpp_kodi_addon_peripheral_Defs_General_PERIPHERAL_ERROR enum PERIPHERAL_ERROR | ||
| 29 | /// @ingroup cpp_kodi_addon_peripheral_Defs_General | ||
| 30 | /// @brief **Peripheral add-on error codes**\n | ||
| 31 | /// Used as return values on most peripheral related functions. | ||
| 32 | /// | ||
| 33 | /// In this way, a peripheral instance signals errors in its processing and, | ||
| 34 | /// under certain conditions, allows Kodi to make corrections. | ||
| 35 | /// | ||
| 36 | ///@{ | ||
| 37 | typedef enum PERIPHERAL_ERROR | ||
| 38 | { | ||
| 39 | /// @brief __0__ : No error occurred | ||
| 40 | PERIPHERAL_NO_ERROR = 0, | ||
| 41 | |||
| 42 | /// @brief __-1__ : An unknown error occurred | ||
| 43 | PERIPHERAL_ERROR_UNKNOWN = -1, | ||
| 44 | |||
| 45 | /// @brief __-2__ : The command failed | ||
| 46 | PERIPHERAL_ERROR_FAILED = -2, | ||
| 47 | |||
| 48 | /// @brief __-3__ : The parameters of the method are invalid for this operation | ||
| 49 | PERIPHERAL_ERROR_INVALID_PARAMETERS = -3, | ||
| 50 | |||
| 51 | /// @brief __-4__ : The method that the frontend called is not implemented | ||
| 52 | PERIPHERAL_ERROR_NOT_IMPLEMENTED = -4, | ||
| 53 | |||
| 54 | /// @brief __-5__ : No peripherals are connected | ||
| 55 | PERIPHERAL_ERROR_NOT_CONNECTED = -5, | ||
| 56 | |||
| 57 | /// @brief __-6__ : Peripherals are connected, but command was interrupted | ||
| 58 | PERIPHERAL_ERROR_CONNECTION_FAILED = -6, | ||
| 59 | } PERIPHERAL_ERROR; | ||
| 60 | ///@} | ||
| 61 | //---------------------------------------------------------------------------- | ||
| 62 | |||
| 63 | // @name Peripheral types | ||
| 64 | //{ | ||
| 65 | |||
| 66 | //============================================================================ | ||
| 67 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Peripheral_PERIPHERAL_TYPE enum PERIPHERAL_TYPE | ||
| 68 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Peripheral | ||
| 69 | /// @brief **Peripheral types**\n | ||
| 70 | /// Types used to identify wanted peripheral. | ||
| 71 | ///@{ | ||
| 72 | typedef enum PERIPHERAL_TYPE | ||
| 73 | { | ||
| 74 | /// @brief Type declared as unknown. | ||
| 75 | PERIPHERAL_TYPE_UNKNOWN, | ||
| 76 | |||
| 77 | /// @brief Type declared as joystick. | ||
| 78 | PERIPHERAL_TYPE_JOYSTICK, | ||
| 79 | |||
| 80 | /// @brief Type declared as keyboard. | ||
| 81 | PERIPHERAL_TYPE_KEYBOARD, | ||
| 82 | } PERIPHERAL_TYPE; | ||
| 83 | ///@} | ||
| 84 | //---------------------------------------------------------------------------- | ||
| 85 | |||
| 86 | /*! | ||
| 87 | * @brief Information shared between peripherals | ||
| 88 | */ | ||
| 89 | typedef struct PERIPHERAL_INFO | ||
| 90 | { | ||
| 91 | PERIPHERAL_TYPE type; /*!< type of peripheral */ | ||
| 92 | char* name; /*!< name of peripheral */ | ||
| 93 | uint16_t vendor_id; /*!< vendor ID of peripheral, 0x0000 if unknown */ | ||
| 94 | uint16_t product_id; /*!< product ID of peripheral, 0x0000 if unknown */ | ||
| 95 | unsigned int index; /*!< the order in which the add-on identified this peripheral */ | ||
| 96 | } ATTRIBUTE_PACKED PERIPHERAL_INFO; | ||
| 97 | |||
| 98 | /*! | ||
| 99 | * @brief Peripheral add-on capabilities. | ||
| 100 | */ | ||
| 101 | typedef struct PERIPHERAL_CAPABILITIES | ||
| 102 | { | ||
| 103 | bool provides_joysticks; /*!< true if the add-on provides joysticks */ | ||
| 104 | bool provides_joystick_rumble; | ||
| 105 | bool provides_joystick_power_off; | ||
| 106 | bool provides_buttonmaps; /*!< true if the add-on provides button maps */ | ||
| 107 | } ATTRIBUTE_PACKED PERIPHERAL_CAPABILITIES; | ||
| 108 | |||
| 109 | //} | ||
| 110 | |||
| 111 | // @name Event types | ||
| 112 | //{ | ||
| 113 | |||
| 114 | //============================================================================ | ||
| 115 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Event_PERIPHERAL_EVENT_TYPE enum PERIPHERAL_EVENT_TYPE | ||
| 116 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Event | ||
| 117 | /// @brief **Event types**\n | ||
| 118 | /// Types of events that can be sent and received. | ||
| 119 | ///@{ | ||
| 120 | typedef enum PERIPHERAL_EVENT_TYPE | ||
| 121 | { | ||
| 122 | /// @brief unknown event | ||
| 123 | PERIPHERAL_EVENT_TYPE_NONE, | ||
| 124 | |||
| 125 | /// @brief state changed for joystick driver button | ||
| 126 | PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON, | ||
| 127 | |||
| 128 | /// @brief state changed for joystick driver hat | ||
| 129 | PERIPHERAL_EVENT_TYPE_DRIVER_HAT, | ||
| 130 | |||
| 131 | /// @brief state changed for joystick driver axis | ||
| 132 | PERIPHERAL_EVENT_TYPE_DRIVER_AXIS, | ||
| 133 | |||
| 134 | /// @brief set the state for joystick rumble motor | ||
| 135 | PERIPHERAL_EVENT_TYPE_SET_MOTOR, | ||
| 136 | } PERIPHERAL_EVENT_TYPE; | ||
| 137 | ///@} | ||
| 138 | //---------------------------------------------------------------------------- | ||
| 139 | |||
| 140 | //============================================================================ | ||
| 141 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Event_JOYSTICK_STATE_BUTTON enum JOYSTICK_STATE_BUTTON | ||
| 142 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Event | ||
| 143 | /// @brief **State button**\n | ||
| 144 | /// States a button can have | ||
| 145 | ///@{ | ||
| 146 | typedef enum JOYSTICK_STATE_BUTTON | ||
| 147 | { | ||
| 148 | /// @brief button is released | ||
| 149 | JOYSTICK_STATE_BUTTON_UNPRESSED = 0x0, | ||
| 150 | |||
| 151 | /// @brief button is pressed | ||
| 152 | JOYSTICK_STATE_BUTTON_PRESSED = 0x1, | ||
| 153 | } JOYSTICK_STATE_BUTTON; | ||
| 154 | ///@} | ||
| 155 | //---------------------------------------------------------------------------- | ||
| 156 | |||
| 157 | //============================================================================ | ||
| 158 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Event_JOYSTICK_STATE_HAT enum JOYSTICK_STATE_HAT | ||
| 159 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Event | ||
| 160 | /// @brief **State hat**\n | ||
| 161 | /// States a D-pad (also called a hat) can have | ||
| 162 | ///@{ | ||
| 163 | typedef enum JOYSTICK_STATE_HAT | ||
| 164 | { | ||
| 165 | /// @brief no directions are pressed | ||
| 166 | JOYSTICK_STATE_HAT_UNPRESSED = 0x0, | ||
| 167 | |||
| 168 | /// @brief only left is pressed | ||
| 169 | JOYSTICK_STATE_HAT_LEFT = 0x1, | ||
| 170 | |||
| 171 | /// @brief only right is pressed | ||
| 172 | JOYSTICK_STATE_HAT_RIGHT = 0x2, | ||
| 173 | |||
| 174 | /// @brief only up is pressed | ||
| 175 | JOYSTICK_STATE_HAT_UP = 0x4, | ||
| 176 | |||
| 177 | /// @brief only down is pressed | ||
| 178 | JOYSTICK_STATE_HAT_DOWN = 0x8, | ||
| 179 | |||
| 180 | /// @brief left and up is pressed | ||
| 181 | JOYSTICK_STATE_HAT_LEFT_UP = JOYSTICK_STATE_HAT_LEFT | JOYSTICK_STATE_HAT_UP, | ||
| 182 | |||
| 183 | /// @brief left and down is pressed | ||
| 184 | JOYSTICK_STATE_HAT_LEFT_DOWN = JOYSTICK_STATE_HAT_LEFT | JOYSTICK_STATE_HAT_DOWN, | ||
| 185 | |||
| 186 | /// @brief right and up is pressed | ||
| 187 | JOYSTICK_STATE_HAT_RIGHT_UP = JOYSTICK_STATE_HAT_RIGHT | JOYSTICK_STATE_HAT_UP, | ||
| 188 | |||
| 189 | /// @brief right and down is pressed | ||
| 190 | JOYSTICK_STATE_HAT_RIGHT_DOWN = JOYSTICK_STATE_HAT_RIGHT | JOYSTICK_STATE_HAT_DOWN, | ||
| 191 | } JOYSTICK_STATE_HAT; | ||
| 192 | ///@} | ||
| 193 | //---------------------------------------------------------------------------- | ||
| 194 | |||
| 195 | //============================================================================ | ||
| 196 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Event | ||
| 197 | /// @brief Axis value in the closed interval [-1.0, 1.0] | ||
| 198 | /// | ||
| 199 | /// The axis state uses the XInput coordinate system: | ||
| 200 | /// - Negative values signify down or to the left | ||
| 201 | /// - Positive values signify up or to the right | ||
| 202 | /// | ||
| 203 | typedef float JOYSTICK_STATE_AXIS; | ||
| 204 | //---------------------------------------------------------------------------- | ||
| 205 | |||
| 206 | //============================================================================ | ||
| 207 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Event | ||
| 208 | /// @brief Motor value in the closed interval [0.0, 1.0] | ||
| 209 | typedef float JOYSTICK_STATE_MOTOR; | ||
| 210 | //---------------------------------------------------------------------------- | ||
| 211 | |||
| 212 | /*! | ||
| 213 | * @brief Event information | ||
| 214 | */ | ||
| 215 | typedef struct PERIPHERAL_EVENT | ||
| 216 | { | ||
| 217 | /*! @brief Index of the peripheral handling/receiving the event */ | ||
| 218 | unsigned int peripheral_index; | ||
| 219 | |||
| 220 | /*! @brief Type of the event used to determine which enum field to access below */ | ||
| 221 | PERIPHERAL_EVENT_TYPE type; | ||
| 222 | |||
| 223 | /*! @brief The index of the event source */ | ||
| 224 | unsigned int driver_index; | ||
| 225 | |||
| 226 | JOYSTICK_STATE_BUTTON driver_button_state; | ||
| 227 | JOYSTICK_STATE_HAT driver_hat_state; | ||
| 228 | JOYSTICK_STATE_AXIS driver_axis_state; | ||
| 229 | JOYSTICK_STATE_MOTOR motor_state; | ||
| 230 | } ATTRIBUTE_PACKED PERIPHERAL_EVENT; | ||
| 231 | |||
| 232 | //} | ||
| 233 | |||
| 234 | // @name Joystick types | ||
| 235 | //{ | ||
| 236 | |||
| 237 | /*! | ||
| 238 | * @brief Info specific to joystick peripherals | ||
| 239 | */ | ||
| 240 | typedef struct JOYSTICK_INFO | ||
| 241 | { | ||
| 242 | PERIPHERAL_INFO peripheral; /*!< @brief peripheral info for this joystick */ | ||
| 243 | char* provider; /*!< @brief name of the driver or interface providing the joystick */ | ||
| 244 | int requested_port; /*!< @brief requested port number (such as for 360 controllers), or NO_PORT_REQUESTED */ | ||
| 245 | unsigned int button_count; /*!< @brief number of buttons reported by the driver */ | ||
| 246 | unsigned int hat_count; /*!< @brief number of hats reported by the driver */ | ||
| 247 | unsigned int axis_count; /*!< @brief number of axes reported by the driver */ | ||
| 248 | unsigned int motor_count; /*!< @brief number of motors reported by the driver */ | ||
| 249 | bool supports_poweroff; /*!< @brief whether the joystick supports being powered off */ | ||
| 250 | } ATTRIBUTE_PACKED JOYSTICK_INFO; | ||
| 251 | |||
| 252 | //============================================================================ | ||
| 253 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_PRIMITIVE_TYPE enum JOYSTICK_DRIVER_PRIMITIVE_TYPE | ||
| 254 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick | ||
| 255 | /// @brief **Driver primitive type**\n | ||
| 256 | /// Driver input primitives | ||
| 257 | /// | ||
| 258 | /// Mapping lower-level driver values to higher-level controller features is | ||
| 259 | /// non-injective; two triggers can share a single axis. | ||
| 260 | /// | ||
| 261 | /// To handle this, driver values are subdivided into "primitives" that map | ||
| 262 | /// injectively to higher-level features. | ||
| 263 | /// | ||
| 264 | ///@{ | ||
| 265 | typedef enum JOYSTICK_DRIVER_PRIMITIVE_TYPE | ||
| 266 | { | ||
| 267 | /// @brief Driver input primitive type unknown | ||
| 268 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN, | ||
| 269 | |||
| 270 | /// @brief Driver input primitive type button | ||
| 271 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON, | ||
| 272 | |||
| 273 | /// @brief Driver input primitive type hat direction | ||
| 274 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION, | ||
| 275 | |||
| 276 | /// @brief Driver input primitive type semiaxis | ||
| 277 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS, | ||
| 278 | |||
| 279 | /// @brief Driver input primitive type motor | ||
| 280 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR, | ||
| 281 | |||
| 282 | /// @brief Driver input primitive type key | ||
| 283 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY, | ||
| 284 | |||
| 285 | /// @brief Driver input primitive type mouse button | ||
| 286 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON, | ||
| 287 | |||
| 288 | /// @brief Driver input primitive type relative pointer direction | ||
| 289 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION, | ||
| 290 | } JOYSTICK_DRIVER_PRIMITIVE_TYPE; | ||
| 291 | ///@} | ||
| 292 | //---------------------------------------------------------------------------- | ||
| 293 | |||
| 294 | /*! | ||
| 295 | * @brief Button primitive | ||
| 296 | */ | ||
| 297 | typedef struct JOYSTICK_DRIVER_BUTTON | ||
| 298 | { | ||
| 299 | int index; | ||
| 300 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_BUTTON; | ||
| 301 | |||
| 302 | //============================================================================ | ||
| 303 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_HAT_DIRECTION enum JOYSTICK_DRIVER_HAT_DIRECTION | ||
| 304 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick | ||
| 305 | /// @brief **Driver direction**\n | ||
| 306 | /// Hat direction. | ||
| 307 | ///@{ | ||
| 308 | typedef enum JOYSTICK_DRIVER_HAT_DIRECTION | ||
| 309 | { | ||
| 310 | /// @brief Driver hat unknown | ||
| 311 | JOYSTICK_DRIVER_HAT_UNKNOWN, | ||
| 312 | |||
| 313 | /// @brief Driver hat left | ||
| 314 | JOYSTICK_DRIVER_HAT_LEFT, | ||
| 315 | |||
| 316 | /// @brief Driver hat right | ||
| 317 | JOYSTICK_DRIVER_HAT_RIGHT, | ||
| 318 | |||
| 319 | /// @brief Driver hat up | ||
| 320 | JOYSTICK_DRIVER_HAT_UP, | ||
| 321 | |||
| 322 | /// @brief Driver hat down | ||
| 323 | JOYSTICK_DRIVER_HAT_DOWN, | ||
| 324 | } JOYSTICK_DRIVER_HAT_DIRECTION; | ||
| 325 | ///@} | ||
| 326 | //---------------------------------------------------------------------------- | ||
| 327 | |||
| 328 | /*! | ||
| 329 | * @brief Hat direction primitive | ||
| 330 | */ | ||
| 331 | typedef struct JOYSTICK_DRIVER_HAT | ||
| 332 | { | ||
| 333 | int index; | ||
| 334 | JOYSTICK_DRIVER_HAT_DIRECTION direction; | ||
| 335 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_HAT; | ||
| 336 | |||
| 337 | //============================================================================ | ||
| 338 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_SEMIAXIS_DIRECTION enum JOYSTICK_DRIVER_SEMIAXIS_DIRECTION | ||
| 339 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick | ||
| 340 | /// @brief **Driver direction**\n | ||
| 341 | /// Semiaxis direction. | ||
| 342 | ///@{ | ||
| 343 | typedef enum JOYSTICK_DRIVER_SEMIAXIS_DIRECTION | ||
| 344 | { | ||
| 345 | /// @brief negative half of the axis | ||
| 346 | JOYSTICK_DRIVER_SEMIAXIS_NEGATIVE = -1, | ||
| 347 | |||
| 348 | /// @brief unknown direction | ||
| 349 | JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN = 0, | ||
| 350 | |||
| 351 | /// @brief positive half of the axis | ||
| 352 | JOYSTICK_DRIVER_SEMIAXIS_POSITIVE = 1, | ||
| 353 | } JOYSTICK_DRIVER_SEMIAXIS_DIRECTION; | ||
| 354 | ///@} | ||
| 355 | //---------------------------------------------------------------------------- | ||
| 356 | |||
| 357 | /*! | ||
| 358 | * @brief Semiaxis primitive | ||
| 359 | */ | ||
| 360 | typedef struct JOYSTICK_DRIVER_SEMIAXIS | ||
| 361 | { | ||
| 362 | int index; | ||
| 363 | int center; | ||
| 364 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction; | ||
| 365 | unsigned int range; | ||
| 366 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_SEMIAXIS; | ||
| 367 | |||
| 368 | /*! | ||
| 369 | * @brief Motor primitive | ||
| 370 | */ | ||
| 371 | typedef struct JOYSTICK_DRIVER_MOTOR | ||
| 372 | { | ||
| 373 | int index; | ||
| 374 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOTOR; | ||
| 375 | |||
| 376 | /*! | ||
| 377 | * @brief Keyboard key primitive | ||
| 378 | */ | ||
| 379 | typedef struct JOYSTICK_DRIVER_KEY | ||
| 380 | { | ||
| 381 | char keycode[16]; | ||
| 382 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_KEY; | ||
| 383 | |||
| 384 | //============================================================================ | ||
| 385 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_MOUSE_INDEX enum JOYSTICK_DRIVER_MOUSE_INDEX | ||
| 386 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick | ||
| 387 | /// @brief **Buttons**\n | ||
| 388 | /// Mouse buttons. | ||
| 389 | ///@{ | ||
| 390 | typedef enum JOYSTICK_DRIVER_MOUSE_INDEX | ||
| 391 | { | ||
| 392 | /// @brief Mouse index unknown | ||
| 393 | JOYSTICK_DRIVER_MOUSE_INDEX_UNKNOWN, | ||
| 394 | |||
| 395 | /// @brief Mouse index left | ||
| 396 | JOYSTICK_DRIVER_MOUSE_INDEX_LEFT, | ||
| 397 | |||
| 398 | /// @brief Mouse index right | ||
| 399 | JOYSTICK_DRIVER_MOUSE_INDEX_RIGHT, | ||
| 400 | |||
| 401 | /// @brief Mouse index middle | ||
| 402 | JOYSTICK_DRIVER_MOUSE_INDEX_MIDDLE, | ||
| 403 | |||
| 404 | /// @brief Mouse index button 4 | ||
| 405 | JOYSTICK_DRIVER_MOUSE_INDEX_BUTTON4, | ||
| 406 | |||
| 407 | /// @brief Mouse index button 5 | ||
| 408 | JOYSTICK_DRIVER_MOUSE_INDEX_BUTTON5, | ||
| 409 | |||
| 410 | /// @brief Mouse index wheel up | ||
| 411 | JOYSTICK_DRIVER_MOUSE_INDEX_WHEEL_UP, | ||
| 412 | |||
| 413 | /// @brief Mouse index wheel down | ||
| 414 | JOYSTICK_DRIVER_MOUSE_INDEX_WHEEL_DOWN, | ||
| 415 | |||
| 416 | /// @brief Mouse index horizontal wheel left | ||
| 417 | JOYSTICK_DRIVER_MOUSE_INDEX_HORIZ_WHEEL_LEFT, | ||
| 418 | |||
| 419 | /// @brief Mouse index horizontal wheel right | ||
| 420 | JOYSTICK_DRIVER_MOUSE_INDEX_HORIZ_WHEEL_RIGHT, | ||
| 421 | } JOYSTICK_DRIVER_MOUSE_INDEX; | ||
| 422 | ///@} | ||
| 423 | //---------------------------------------------------------------------------- | ||
| 424 | |||
| 425 | /*! | ||
| 426 | * @brief Mouse button primitive | ||
| 427 | */ | ||
| 428 | typedef struct JOYSTICK_DRIVER_MOUSE_BUTTON | ||
| 429 | { | ||
| 430 | JOYSTICK_DRIVER_MOUSE_INDEX button; | ||
| 431 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOUSE_BUTTON; | ||
| 432 | |||
| 433 | //============================================================================ | ||
| 434 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_RELPOINTER_DIRECTION enum JOYSTICK_DRIVER_RELPOINTER_DIRECTION | ||
| 435 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick | ||
| 436 | /// @brief **Pointer direction**\n | ||
| 437 | /// Relative pointer direction | ||
| 438 | ///@{ | ||
| 439 | typedef enum JOYSTICK_DRIVER_RELPOINTER_DIRECTION | ||
| 440 | { | ||
| 441 | /// @brief Relative pointer direction unknown | ||
| 442 | JOYSTICK_DRIVER_RELPOINTER_UNKNOWN, | ||
| 443 | |||
| 444 | /// @brief Relative pointer direction left | ||
| 445 | JOYSTICK_DRIVER_RELPOINTER_LEFT, | ||
| 446 | |||
| 447 | /// @brief Relative pointer direction right | ||
| 448 | JOYSTICK_DRIVER_RELPOINTER_RIGHT, | ||
| 449 | |||
| 450 | /// @brief Relative pointer direction up | ||
| 451 | JOYSTICK_DRIVER_RELPOINTER_UP, | ||
| 452 | |||
| 453 | /// @brief Relative pointer direction down | ||
| 454 | JOYSTICK_DRIVER_RELPOINTER_DOWN, | ||
| 455 | } JOYSTICK_DRIVER_RELPOINTER_DIRECTION; | ||
| 456 | ///@} | ||
| 457 | //---------------------------------------------------------------------------- | ||
| 458 | |||
| 459 | /*! | ||
| 460 | * @brief Relative pointer direction primitive | ||
| 461 | */ | ||
| 462 | typedef struct JOYSTICK_DRIVER_RELPOINTER | ||
| 463 | { | ||
| 464 | JOYSTICK_DRIVER_RELPOINTER_DIRECTION direction; | ||
| 465 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_RELPOINTER; | ||
| 466 | |||
| 467 | /*! | ||
| 468 | * @brief Driver primitive struct | ||
| 469 | */ | ||
| 470 | typedef struct JOYSTICK_DRIVER_PRIMITIVE | ||
| 471 | { | ||
| 472 | JOYSTICK_DRIVER_PRIMITIVE_TYPE type; | ||
| 473 | union | ||
| 474 | { | ||
| 475 | struct JOYSTICK_DRIVER_BUTTON button; | ||
| 476 | struct JOYSTICK_DRIVER_HAT hat; | ||
| 477 | struct JOYSTICK_DRIVER_SEMIAXIS semiaxis; | ||
| 478 | struct JOYSTICK_DRIVER_MOTOR motor; | ||
| 479 | struct JOYSTICK_DRIVER_KEY key; | ||
| 480 | struct JOYSTICK_DRIVER_MOUSE_BUTTON mouse; | ||
| 481 | struct JOYSTICK_DRIVER_RELPOINTER relpointer; | ||
| 482 | }; | ||
| 483 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_PRIMITIVE; | ||
| 484 | |||
| 485 | //============================================================================ | ||
| 486 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_FEATURE_TYPE enum JOYSTICK_FEATURE_TYPE | ||
| 487 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick | ||
| 488 | /// @brief **Feature type**\n | ||
| 489 | /// Controller feature. | ||
| 490 | /// | ||
| 491 | /// Controller features are an abstraction over driver values. Each feature | ||
| 492 | /// maps to one or more driver primitives. | ||
| 493 | /// | ||
| 494 | ///@{ | ||
| 495 | typedef enum JOYSTICK_FEATURE_TYPE | ||
| 496 | { | ||
| 497 | /// @brief Unknown type | ||
| 498 | JOYSTICK_FEATURE_TYPE_UNKNOWN, | ||
| 499 | |||
| 500 | /// @brief Type scalar | ||
| 501 | JOYSTICK_FEATURE_TYPE_SCALAR, | ||
| 502 | |||
| 503 | /// @brief Type analog stick | ||
| 504 | JOYSTICK_FEATURE_TYPE_ANALOG_STICK, | ||
| 505 | |||
| 506 | /// @brief Type accelerometer | ||
| 507 | JOYSTICK_FEATURE_TYPE_ACCELEROMETER, | ||
| 508 | |||
| 509 | /// @brief Type motor | ||
| 510 | JOYSTICK_FEATURE_TYPE_MOTOR, | ||
| 511 | |||
| 512 | /// @brief Type relative pointer | ||
| 513 | JOYSTICK_FEATURE_TYPE_RELPOINTER, | ||
| 514 | |||
| 515 | /// @brief Type absolut pointer | ||
| 516 | JOYSTICK_FEATURE_TYPE_ABSPOINTER, | ||
| 517 | |||
| 518 | /// @brief Type wheel | ||
| 519 | JOYSTICK_FEATURE_TYPE_WHEEL, | ||
| 520 | |||
| 521 | /// @brief Type throttle | ||
| 522 | JOYSTICK_FEATURE_TYPE_THROTTLE, | ||
| 523 | |||
| 524 | /// @brief Type key | ||
| 525 | JOYSTICK_FEATURE_TYPE_KEY, | ||
| 526 | } JOYSTICK_FEATURE_TYPE; | ||
| 527 | ///@} | ||
| 528 | //---------------------------------------------------------------------------- | ||
| 529 | |||
| 530 | //============================================================================ | ||
| 531 | /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_FEATURE_PRIMITIVE enum JOYSTICK_FEATURE_PRIMITIVE | ||
| 532 | /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick | ||
| 533 | /// @brief **Feature primitives**\n | ||
| 534 | /// Indices used to access a feature's driver primitives. | ||
| 535 | /// | ||
| 536 | ///@{ | ||
| 537 | typedef enum JOYSTICK_FEATURE_PRIMITIVE | ||
| 538 | { | ||
| 539 | /// @brief Scalar feature (a button, hat direction or semiaxis) | ||
| 540 | JOYSTICK_SCALAR_PRIMITIVE = 0, | ||
| 541 | |||
| 542 | /// @brief Analog stick up | ||
| 543 | JOYSTICK_ANALOG_STICK_UP = 0, | ||
| 544 | /// @brief Analog stick down | ||
| 545 | JOYSTICK_ANALOG_STICK_DOWN = 1, | ||
| 546 | /// @brief Analog stick right | ||
| 547 | JOYSTICK_ANALOG_STICK_RIGHT = 2, | ||
| 548 | /// @brief Analog stick left | ||
| 549 | JOYSTICK_ANALOG_STICK_LEFT = 3, | ||
| 550 | |||
| 551 | /// @brief Accelerometer X | ||
| 552 | JOYSTICK_ACCELEROMETER_POSITIVE_X = 0, | ||
| 553 | /// @brief Accelerometer Y | ||
| 554 | JOYSTICK_ACCELEROMETER_POSITIVE_Y = 1, | ||
| 555 | /// @brief Accelerometer Z | ||
| 556 | JOYSTICK_ACCELEROMETER_POSITIVE_Z = 2, | ||
| 557 | |||
| 558 | /// @brief Motor | ||
| 559 | JOYSTICK_MOTOR_PRIMITIVE = 0, | ||
| 560 | |||
| 561 | /// @brief Wheel left | ||
| 562 | JOYSTICK_WHEEL_LEFT = 0, | ||
| 563 | /// @brief Wheel right | ||
| 564 | JOYSTICK_WHEEL_RIGHT = 1, | ||
| 565 | |||
| 566 | /// @brief Throttle up | ||
| 567 | JOYSTICK_THROTTLE_UP = 0, | ||
| 568 | /// @brief Throttle down | ||
| 569 | JOYSTICK_THROTTLE_DOWN = 1, | ||
| 570 | |||
| 571 | /// @brief Key | ||
| 572 | JOYSTICK_KEY_PRIMITIVE = 0, | ||
| 573 | |||
| 574 | /// @brief Mouse button | ||
| 575 | JOYSTICK_MOUSE_BUTTON = 0, | ||
| 576 | |||
| 577 | /// @brief Relative pointer direction up | ||
| 578 | JOYSTICK_RELPOINTER_UP = 0, | ||
| 579 | /// @brief Relative pointer direction down | ||
| 580 | JOYSTICK_RELPOINTER_DOWN = 1, | ||
| 581 | /// @brief Relative pointer direction right | ||
| 582 | JOYSTICK_RELPOINTER_RIGHT = 2, | ||
| 583 | /// @brief Relative pointer direction left | ||
| 584 | JOYSTICK_RELPOINTER_LEFT = 3, | ||
| 585 | |||
| 586 | /// @brief Maximum number of primitives | ||
| 587 | JOYSTICK_PRIMITIVE_MAX = 4, | ||
| 588 | } JOYSTICK_FEATURE_PRIMITIVE; | ||
| 589 | ///@} | ||
| 590 | //---------------------------------------------------------------------------- | ||
| 591 | |||
| 592 | /*! | ||
| 593 | * @brief Mapping between higher-level controller feature and its driver primitives | ||
| 594 | */ | ||
| 595 | typedef struct JOYSTICK_FEATURE | ||
| 596 | { | ||
| 597 | char* name; | ||
| 598 | JOYSTICK_FEATURE_TYPE type; | ||
| 599 | struct JOYSTICK_DRIVER_PRIMITIVE primitives[JOYSTICK_PRIMITIVE_MAX]; | ||
| 600 | } ATTRIBUTE_PACKED JOYSTICK_FEATURE; | ||
| 601 | //} | ||
| 602 | |||
| 603 | typedef struct AddonProps_Peripheral | ||
| 604 | { | ||
| 605 | const char* user_path; /*!< @brief path to the user profile */ | ||
| 606 | const char* addon_path; /*!< @brief path to this add-on */ | ||
| 607 | } ATTRIBUTE_PACKED AddonProps_Peripheral; | ||
| 608 | |||
| 609 | struct AddonInstance_Peripheral; | ||
| 610 | |||
| 611 | typedef struct AddonToKodiFuncTable_Peripheral | ||
| 612 | { | ||
| 613 | KODI_HANDLE kodiInstance; | ||
| 614 | void (*trigger_scan)(void* kodiInstance); | ||
| 615 | void (*refresh_button_maps)(void* kodiInstance, | ||
| 616 | const char* device_name, | ||
| 617 | const char* controller_id); | ||
| 618 | unsigned int (*feature_count)(void* kodiInstance, | ||
| 619 | const char* controller_id, | ||
| 620 | JOYSTICK_FEATURE_TYPE type); | ||
| 621 | JOYSTICK_FEATURE_TYPE(*feature_type) | ||
| 622 | (void* kodiInstance, const char* controller_id, const char* feature_name); | ||
| 623 | } AddonToKodiFuncTable_Peripheral; | ||
| 624 | |||
| 625 | //! @todo Mouse, light gun, multitouch | ||
| 626 | |||
| 627 | typedef struct KodiToAddonFuncTable_Peripheral | ||
| 628 | { | ||
| 629 | KODI_HANDLE addonInstance; | ||
| 630 | |||
| 631 | void(__cdecl* get_capabilities)(const struct AddonInstance_Peripheral* addonInstance, | ||
| 632 | struct PERIPHERAL_CAPABILITIES* capabilities); | ||
| 633 | PERIPHERAL_ERROR(__cdecl* perform_device_scan) | ||
| 634 | (const struct AddonInstance_Peripheral* addonInstance, | ||
| 635 | unsigned int* peripheral_count, | ||
| 636 | struct PERIPHERAL_INFO** scan_results); | ||
| 637 | void(__cdecl* free_scan_results)(const struct AddonInstance_Peripheral* addonInstance, | ||
| 638 | unsigned int peripheral_count, | ||
| 639 | struct PERIPHERAL_INFO* scan_results); | ||
| 640 | PERIPHERAL_ERROR(__cdecl* get_events) | ||
| 641 | (const struct AddonInstance_Peripheral* addonInstance, | ||
| 642 | unsigned int* event_count, | ||
| 643 | struct PERIPHERAL_EVENT** events); | ||
| 644 | void(__cdecl* free_events)(const struct AddonInstance_Peripheral* addonInstance, | ||
| 645 | unsigned int event_count, | ||
| 646 | struct PERIPHERAL_EVENT* events); | ||
| 647 | bool(__cdecl* send_event)(const struct AddonInstance_Peripheral* addonInstance, | ||
| 648 | const struct PERIPHERAL_EVENT* event); | ||
| 649 | |||
| 650 | /// @name Joystick operations | ||
| 651 | ///{ | ||
| 652 | PERIPHERAL_ERROR(__cdecl* get_joystick_info) | ||
| 653 | (const struct AddonInstance_Peripheral* addonInstance, | ||
| 654 | unsigned int index, | ||
| 655 | struct JOYSTICK_INFO* info); | ||
| 656 | void(__cdecl* free_joystick_info)(const struct AddonInstance_Peripheral* addonInstance, | ||
| 657 | struct JOYSTICK_INFO* info); | ||
| 658 | PERIPHERAL_ERROR(__cdecl* get_features) | ||
| 659 | (const struct AddonInstance_Peripheral* addonInstance, | ||
| 660 | const struct JOYSTICK_INFO* joystick, | ||
| 661 | const char* controller_id, | ||
| 662 | unsigned int* feature_count, | ||
| 663 | struct JOYSTICK_FEATURE** features); | ||
| 664 | void(__cdecl* free_features)(const struct AddonInstance_Peripheral* addonInstance, | ||
| 665 | unsigned int feature_count, | ||
| 666 | struct JOYSTICK_FEATURE* features); | ||
| 667 | PERIPHERAL_ERROR(__cdecl* map_features) | ||
| 668 | (const struct AddonInstance_Peripheral* addonInstance, | ||
| 669 | const struct JOYSTICK_INFO* joystick, | ||
| 670 | const char* controller_id, | ||
| 671 | unsigned int feature_count, | ||
| 672 | const struct JOYSTICK_FEATURE* features); | ||
| 673 | PERIPHERAL_ERROR(__cdecl* get_ignored_primitives) | ||
| 674 | (const struct AddonInstance_Peripheral* addonInstance, | ||
| 675 | const struct JOYSTICK_INFO* joystick, | ||
| 676 | unsigned int* feature_count, | ||
| 677 | struct JOYSTICK_DRIVER_PRIMITIVE** primitives); | ||
| 678 | void(__cdecl* free_primitives)(const struct AddonInstance_Peripheral* addonInstance, | ||
| 679 | unsigned int, | ||
| 680 | struct JOYSTICK_DRIVER_PRIMITIVE* primitives); | ||
| 681 | PERIPHERAL_ERROR(__cdecl* set_ignored_primitives) | ||
| 682 | (const struct AddonInstance_Peripheral* addonInstance, | ||
| 683 | const struct JOYSTICK_INFO* joystick, | ||
| 684 | unsigned int primitive_count, | ||
| 685 | const struct JOYSTICK_DRIVER_PRIMITIVE* primitives); | ||
| 686 | void(__cdecl* save_button_map)(const struct AddonInstance_Peripheral* addonInstance, | ||
| 687 | const struct JOYSTICK_INFO* joystick); | ||
| 688 | void(__cdecl* revert_button_map)(const struct AddonInstance_Peripheral* addonInstance, | ||
| 689 | const struct JOYSTICK_INFO* joystick); | ||
| 690 | void(__cdecl* reset_button_map)(const struct AddonInstance_Peripheral* addonInstance, | ||
| 691 | const struct JOYSTICK_INFO* joystick, | ||
| 692 | const char* controller_id); | ||
| 693 | void(__cdecl* power_off_joystick)(const struct AddonInstance_Peripheral* addonInstance, | ||
| 694 | unsigned int index); | ||
| 695 | ///} | ||
| 696 | } KodiToAddonFuncTable_Peripheral; | ||
| 697 | |||
| 698 | typedef struct AddonInstance_Peripheral | ||
| 699 | { | ||
| 700 | struct AddonProps_Peripheral* props; | ||
| 701 | struct AddonToKodiFuncTable_Peripheral* toKodi; | ||
| 702 | struct KodiToAddonFuncTable_Peripheral* toAddon; | ||
| 703 | } AddonInstance_Peripheral; | ||
| 704 | |||
| 705 | #ifdef __cplusplus | ||
| 706 | } /* extern "C" */ | ||
| 707 | #endif /* __cplusplus */ | ||
| 708 | |||
| 709 | #endif /* !C_API_ADDONINSTANCE_PERIPHERAL_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr.h index 2d255ad..a50ea2b 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr.h | |||
| @@ -8,6 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_ADDONINSTANCE_PVR_H | ||
| 12 | #define C_API_ADDONINSTANCE_PVR_H | ||
| 13 | |||
| 11 | #include "../../AddonBase.h" | 14 | #include "../../AddonBase.h" |
| 12 | #include "pvr/pvr_channel_groups.h" | 15 | #include "pvr/pvr_channel_groups.h" |
| 13 | #include "pvr/pvr_channels.h" | 16 | #include "pvr/pvr_channels.h" |
| @@ -325,3 +328,5 @@ extern "C" | |||
| 325 | #ifdef __cplusplus | 328 | #ifdef __cplusplus |
| 326 | } | 329 | } |
| 327 | #endif /* __cplusplus */ | 330 | #endif /* __cplusplus */ |
| 331 | |||
| 332 | #endif /* !C_API_ADDONINSTANCE_PVR_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/CMakeLists.txt index 6617084..0e37ea4 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/CMakeLists.txt +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/CMakeLists.txt | |||
| @@ -10,5 +10,5 @@ set(HEADERS pvr_channel_groups.h | |||
| 10 | pvr_timers.h) | 10 | pvr_timers.h) |
| 11 | 11 | ||
| 12 | if(NOT ENABLE_STATIC_LIBS) | 12 | if(NOT ENABLE_STATIC_LIBS) |
| 13 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_c-api_addon-instance_pvr) | 13 | core_add_library(addons_kodi-dev-kit_include_kodi_c-api_addon-instance_pvr) |
| 14 | endif() | 14 | endif() |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h index 36f9ed6..a24d27f 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h | |||
| @@ -8,6 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_ADDONINSTANCE_PVR_CHANNEL_GROUPS_H | ||
| 12 | #define C_API_ADDONINSTANCE_PVR_CHANNEL_GROUPS_H | ||
| 13 | |||
| 11 | #include "pvr_defines.h" | 14 | #include "pvr_defines.h" |
| 12 | 15 | ||
| 13 | #include <stdbool.h> | 16 | #include <stdbool.h> |
| @@ -52,3 +55,5 @@ extern "C" | |||
| 52 | #ifdef __cplusplus | 55 | #ifdef __cplusplus |
| 53 | } | 56 | } |
| 54 | #endif /* __cplusplus */ | 57 | #endif /* __cplusplus */ |
| 58 | |||
| 59 | #endif /* !C_API_ADDONINSTANCE_PVR_CHANNEL_GROUPS_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h index a2ce591..00daffa 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h | |||
| @@ -8,6 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_ADDONINSTANCE_PVR_CHANNELS_H | ||
| 12 | #define C_API_ADDONINSTANCE_PVR_CHANNELS_H | ||
| 13 | |||
| 11 | #include "pvr_defines.h" | 14 | #include "pvr_defines.h" |
| 12 | 15 | ||
| 13 | #include <stdbool.h> | 16 | #include <stdbool.h> |
| @@ -102,3 +105,5 @@ extern "C" | |||
| 102 | #ifdef __cplusplus | 105 | #ifdef __cplusplus |
| 103 | } | 106 | } |
| 104 | #endif /* __cplusplus */ | 107 | #endif /* __cplusplus */ |
| 108 | |||
| 109 | #endif /* !C_API_ADDONINSTANCE_PVR_CHANNELS_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h index af1daae..449000f 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h | |||
| @@ -8,6 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_ADDONINSTANCE_PVR_DEFINES_H | ||
| 12 | #define C_API_ADDONINSTANCE_PVR_DEFINES_H | ||
| 13 | |||
| 11 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | 14 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ |
| 12 | // "C" Standard PVR definitions | 15 | // "C" Standard PVR definitions |
| 13 | // | 16 | // |
| @@ -59,3 +62,5 @@ extern "C" | |||
| 59 | #ifdef __cplusplus | 62 | #ifdef __cplusplus |
| 60 | } | 63 | } |
| 61 | #endif /* __cplusplus */ | 64 | #endif /* __cplusplus */ |
| 65 | |||
| 66 | #endif /* !C_API_ADDONINSTANCE_PVR_DEFINES_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h index 8378eaf..e7cdf06 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h | |||
| @@ -8,6 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_ADDONINSTANCE_PVR_EDL_H | ||
| 12 | #define C_API_ADDONINSTANCE_PVR_EDL_H | ||
| 13 | |||
| 11 | #include "pvr_defines.h" | 14 | #include "pvr_defines.h" |
| 12 | 15 | ||
| 13 | #include <stdint.h> | 16 | #include <stdint.h> |
| @@ -60,3 +63,5 @@ extern "C" | |||
| 60 | #ifdef __cplusplus | 63 | #ifdef __cplusplus |
| 61 | } | 64 | } |
| 62 | #endif /* __cplusplus */ | 65 | #endif /* __cplusplus */ |
| 66 | |||
| 67 | #endif /* !C_API_ADDONINSTANCE_PVR_EDL_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h index 57c603f..d7512dc 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h | |||
| @@ -8,6 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_ADDONINSTANCE_PVR_EPG_H | ||
| 12 | #define C_API_ADDONINSTANCE_PVR_EPG_H | ||
| 13 | |||
| 11 | #include "pvr_defines.h" | 14 | #include "pvr_defines.h" |
| 12 | 15 | ||
| 13 | #include <time.h> | 16 | #include <time.h> |
| @@ -651,3 +654,5 @@ extern "C" | |||
| 651 | #ifdef __cplusplus | 654 | #ifdef __cplusplus |
| 652 | } | 655 | } |
| 653 | #endif /* __cplusplus */ | 656 | #endif /* __cplusplus */ |
| 657 | |||
| 658 | #endif /* !C_API_ADDONINSTANCE_PVR_EPG_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h index 52787b0..e2136f6 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h | |||
| @@ -8,6 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_ADDONINSTANCE_PVR_GENERAL_H | ||
| 12 | #define C_API_ADDONINSTANCE_PVR_GENERAL_H | ||
| 13 | |||
| 11 | #include "pvr_defines.h" | 14 | #include "pvr_defines.h" |
| 12 | 15 | ||
| 13 | #ifdef BUILD_KODI_ADDON | 16 | #ifdef BUILD_KODI_ADDON |
| @@ -16,6 +19,8 @@ | |||
| 16 | #include "cores/VideoPlayer/Interface/Addon/InputStreamConstants.h" | 19 | #include "cores/VideoPlayer/Interface/Addon/InputStreamConstants.h" |
| 17 | #endif | 20 | #endif |
| 18 | 21 | ||
| 22 | #include <stdbool.h> | ||
| 23 | |||
| 19 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | 24 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ |
| 20 | // "C" Definitions group 1 - General PVR | 25 | // "C" Definitions group 1 - General PVR |
| 21 | #ifdef __cplusplus | 26 | #ifdef __cplusplus |
| @@ -205,7 +210,7 @@ extern "C" | |||
| 205 | /// { | 210 | /// { |
| 206 | /// if (instanceType == ADDON_INSTANCE_INPUTSTREAM) | 211 | /// if (instanceType == ADDON_INSTANCE_INPUTSTREAM) |
| 207 | /// { | 212 | /// { |
| 208 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my special inputstream"); | 213 | /// kodi::Log(ADDON_LOG_INFO, "Creating my special inputstream"); |
| 209 | /// if (instanceID == "my_special_id_1") | 214 | /// if (instanceID == "my_special_id_1") |
| 210 | /// addonInstance = new CMyPVRClientInstance_Type1(instance, version); | 215 | /// addonInstance = new CMyPVRClientInstance_Type1(instance, version); |
| 211 | /// else if (instanceID == "my_special_id_2") | 216 | /// else if (instanceID == "my_special_id_2") |
| @@ -286,3 +291,5 @@ extern "C" | |||
| 286 | #ifdef __cplusplus | 291 | #ifdef __cplusplus |
| 287 | } | 292 | } |
| 288 | #endif /* __cplusplus */ | 293 | #endif /* __cplusplus */ |
| 294 | |||
| 295 | #endif /* !C_API_ADDONINSTANCE_PVR_GENERAL_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h index df2216f..2ead263 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h | |||
| @@ -8,6 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_ADDONINSTANCE_PVR_MENUHOOK_H | ||
| 12 | #define C_API_ADDONINSTANCE_PVR_MENUHOOK_H | ||
| 13 | |||
| 11 | #include "pvr_defines.h" | 14 | #include "pvr_defines.h" |
| 12 | 15 | ||
| 13 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | 16 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ |
| @@ -70,3 +73,5 @@ extern "C" | |||
| 70 | #ifdef __cplusplus | 73 | #ifdef __cplusplus |
| 71 | } | 74 | } |
| 72 | #endif /* __cplusplus */ | 75 | #endif /* __cplusplus */ |
| 76 | |||
| 77 | #endif /* !C_API_ADDONINSTANCE_PVR_MENUHOOK_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h index 1a7fc66..2e2c081 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h | |||
| @@ -8,6 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_ADDONINSTANCE_PVR_RECORDINGS_H | ||
| 12 | #define C_API_ADDONINSTANCE_PVR_RECORDINGS_H | ||
| 13 | |||
| 11 | #include "pvr_defines.h" | 14 | #include "pvr_defines.h" |
| 12 | 15 | ||
| 13 | #include <stdbool.h> | 16 | #include <stdbool.h> |
| @@ -141,3 +144,5 @@ extern "C" | |||
| 141 | #ifdef __cplusplus | 144 | #ifdef __cplusplus |
| 142 | } | 145 | } |
| 143 | #endif /* __cplusplus */ | 146 | #endif /* __cplusplus */ |
| 147 | |||
| 148 | #endif /* !C_API_ADDONINSTANCE_PVR_RECORDINGS_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h index 04b4059..1206c67 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h | |||
| @@ -8,6 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_ADDONINSTANCE_PVR_STREAM_H | ||
| 12 | #define C_API_ADDONINSTANCE_PVR_STREAM_H | ||
| 13 | |||
| 11 | #include "pvr_defines.h" | 14 | #include "pvr_defines.h" |
| 12 | 15 | ||
| 13 | #ifdef BUILD_KODI_ADDON | 16 | #ifdef BUILD_KODI_ADDON |
| @@ -153,3 +156,5 @@ extern "C" | |||
| 153 | #ifdef __cplusplus | 156 | #ifdef __cplusplus |
| 154 | } | 157 | } |
| 155 | #endif /* __cplusplus */ | 158 | #endif /* __cplusplus */ |
| 159 | |||
| 160 | #endif /* !C_API_ADDONINSTANCE_PVR_STREAM_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h index bc16adb..209726d 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h | |||
| @@ -8,6 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_ADDONINSTANCE_PVR_TIMERS_H | ||
| 12 | #define C_API_ADDONINSTANCE_PVR_TIMERS_H | ||
| 13 | |||
| 11 | #include "pvr_defines.h" | 14 | #include "pvr_defines.h" |
| 12 | 15 | ||
| 13 | #include <stdbool.h> | 16 | #include <stdbool.h> |
| @@ -405,3 +408,5 @@ extern "C" | |||
| 405 | #ifdef __cplusplus | 408 | #ifdef __cplusplus |
| 406 | } | 409 | } |
| 407 | #endif /* __cplusplus */ | 410 | #endif /* __cplusplus */ |
| 411 | |||
| 412 | #endif /* !C_API_ADDONINSTANCE_PVR_TIMERS_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/screensaver.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/screensaver.h new file mode 100644 index 0000000..32cf6e1 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/screensaver.h | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../addon_base.h" | ||
| 12 | |||
| 13 | #ifdef __cplusplus | ||
| 14 | extern "C" | ||
| 15 | { | ||
| 16 | #endif /* __cplusplus */ | ||
| 17 | |||
| 18 | struct AddonInstance_Screensaver; | ||
| 19 | |||
| 20 | /*! | ||
| 21 | * @brief Screensaver properties | ||
| 22 | * | ||
| 23 | * Not to be used outside this header. | ||
| 24 | */ | ||
| 25 | typedef struct AddonProps_Screensaver | ||
| 26 | { | ||
| 27 | ADDON_HARDWARE_CONTEXT device; | ||
| 28 | int x; | ||
| 29 | int y; | ||
| 30 | int width; | ||
| 31 | int height; | ||
| 32 | float pixelRatio; | ||
| 33 | const char* name; | ||
| 34 | const char* presets; | ||
| 35 | const char* profile; | ||
| 36 | } AddonProps_Screensaver; | ||
| 37 | |||
| 38 | /*! | ||
| 39 | * @brief Screensaver callbacks | ||
| 40 | * | ||
| 41 | * Not to be used outside this header. | ||
| 42 | */ | ||
| 43 | typedef struct AddonToKodiFuncTable_Screensaver | ||
| 44 | { | ||
| 45 | KODI_HANDLE kodiInstance; | ||
| 46 | } AddonToKodiFuncTable_Screensaver; | ||
| 47 | |||
| 48 | /*! | ||
| 49 | * @brief Screensaver function hooks | ||
| 50 | * | ||
| 51 | * Not to be used outside this header. | ||
| 52 | */ | ||
| 53 | typedef struct KodiToAddonFuncTable_Screensaver | ||
| 54 | { | ||
| 55 | KODI_HANDLE addonInstance; | ||
| 56 | bool(__cdecl* Start)(struct AddonInstance_Screensaver* instance); | ||
| 57 | void(__cdecl* Stop)(struct AddonInstance_Screensaver* instance); | ||
| 58 | void(__cdecl* Render)(struct AddonInstance_Screensaver* instance); | ||
| 59 | } KodiToAddonFuncTable_Screensaver; | ||
| 60 | |||
| 61 | /*! | ||
| 62 | * @brief Screensaver instance | ||
| 63 | * | ||
| 64 | * Not to be used outside this header. | ||
| 65 | */ | ||
| 66 | typedef struct AddonInstance_Screensaver | ||
| 67 | { | ||
| 68 | struct AddonProps_Screensaver* props; | ||
| 69 | struct AddonToKodiFuncTable_Screensaver* toKodi; | ||
| 70 | struct KodiToAddonFuncTable_Screensaver* toAddon; | ||
| 71 | } AddonInstance_Screensaver; | ||
| 72 | |||
| 73 | #ifdef __cplusplus | ||
| 74 | } /* extern "C" */ | ||
| 75 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/vfs.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/vfs.h new file mode 100644 index 0000000..a6c3f44 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/vfs.h | |||
| @@ -0,0 +1,149 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * | ||
| 4 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 5 | * See LICENSES/README.md for more information. | ||
| 6 | */ | ||
| 7 | |||
| 8 | #pragma once | ||
| 9 | |||
| 10 | #ifndef C_API_ADDONINSTANCE_VFS_H | ||
| 11 | #define C_API_ADDONINSTANCE_VFS_H | ||
| 12 | |||
| 13 | #include "../addon_base.h" | ||
| 14 | #include "../filesystem.h" | ||
| 15 | |||
| 16 | #define VFS_FILE_HANDLE void* | ||
| 17 | |||
| 18 | #ifdef __cplusplus | ||
| 19 | extern "C" | ||
| 20 | { | ||
| 21 | #endif /* __cplusplus */ | ||
| 22 | |||
| 23 | struct VFSURL | ||
| 24 | { | ||
| 25 | const char* url; | ||
| 26 | const char* domain; | ||
| 27 | const char* hostname; | ||
| 28 | const char* filename; | ||
| 29 | unsigned int port; | ||
| 30 | const char* options; | ||
| 31 | const char* username; | ||
| 32 | const char* password; | ||
| 33 | const char* redacted; | ||
| 34 | const char* sharename; | ||
| 35 | const char* protocol; | ||
| 36 | }; | ||
| 37 | |||
| 38 | typedef struct VFSGetDirectoryCallbacks /* internal */ | ||
| 39 | { | ||
| 40 | bool(__cdecl* get_keyboard_input)(KODI_HANDLE ctx, | ||
| 41 | const char* heading, | ||
| 42 | char** input, | ||
| 43 | bool hidden_input); | ||
| 44 | void(__cdecl* set_error_dialog)(KODI_HANDLE ctx, | ||
| 45 | const char* heading, | ||
| 46 | const char* line1, | ||
| 47 | const char* line2, | ||
| 48 | const char* line3); | ||
| 49 | void(__cdecl* require_authentication)(KODI_HANDLE ctx, const char* url); | ||
| 50 | KODI_HANDLE ctx; | ||
| 51 | } VFSGetDirectoryCallbacks; | ||
| 52 | |||
| 53 | typedef struct AddonProps_VFSEntry /* internal */ | ||
| 54 | { | ||
| 55 | int dummy; | ||
| 56 | } AddonProps_VFSEntry; | ||
| 57 | |||
| 58 | typedef struct AddonToKodiFuncTable_VFSEntry /* internal */ | ||
| 59 | { | ||
| 60 | KODI_HANDLE kodiInstance; | ||
| 61 | } AddonToKodiFuncTable_VFSEntry; | ||
| 62 | |||
| 63 | struct AddonInstance_VFSEntry; | ||
| 64 | typedef struct KodiToAddonFuncTable_VFSEntry /* internal */ | ||
| 65 | { | ||
| 66 | KODI_HANDLE addonInstance; | ||
| 67 | |||
| 68 | VFS_FILE_HANDLE(__cdecl* open) | ||
| 69 | (const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url); | ||
| 70 | VFS_FILE_HANDLE(__cdecl* open_for_write) | ||
| 71 | (const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url, bool overwrite); | ||
| 72 | ssize_t(__cdecl* read)(const struct AddonInstance_VFSEntry* instance, | ||
| 73 | VFS_FILE_HANDLE context, | ||
| 74 | uint8_t* buffer, | ||
| 75 | size_t buf_size); | ||
| 76 | ssize_t(__cdecl* write)(const struct AddonInstance_VFSEntry* instance, | ||
| 77 | VFS_FILE_HANDLE context, | ||
| 78 | const uint8_t* buffer, | ||
| 79 | size_t buf_size); | ||
| 80 | int64_t(__cdecl* seek)(const struct AddonInstance_VFSEntry* instance, | ||
| 81 | VFS_FILE_HANDLE context, | ||
| 82 | int64_t position, | ||
| 83 | int whence); | ||
| 84 | int(__cdecl* truncate)(const struct AddonInstance_VFSEntry* instance, | ||
| 85 | VFS_FILE_HANDLE context, | ||
| 86 | int64_t size); | ||
| 87 | int64_t(__cdecl* get_length)(const struct AddonInstance_VFSEntry* instance, | ||
| 88 | VFS_FILE_HANDLE context); | ||
| 89 | int64_t(__cdecl* get_position)(const struct AddonInstance_VFSEntry* instance, | ||
| 90 | VFS_FILE_HANDLE context); | ||
| 91 | int(__cdecl* get_chunk_size)(const struct AddonInstance_VFSEntry* instance, | ||
| 92 | VFS_FILE_HANDLE context); | ||
| 93 | bool(__cdecl* io_control_get_seek_possible)(const struct AddonInstance_VFSEntry* instance, | ||
| 94 | VFS_FILE_HANDLE context); | ||
| 95 | bool(__cdecl* io_control_get_cache_status)(const struct AddonInstance_VFSEntry* instance, | ||
| 96 | VFS_FILE_HANDLE context, | ||
| 97 | VFS_CACHE_STATUS_DATA* status); | ||
| 98 | bool(__cdecl* io_control_set_cache_rate)(const struct AddonInstance_VFSEntry* instance, | ||
| 99 | VFS_FILE_HANDLE context, | ||
| 100 | unsigned int rate); | ||
| 101 | bool(__cdecl* io_control_set_retry)(const struct AddonInstance_VFSEntry* instance, | ||
| 102 | VFS_FILE_HANDLE context, | ||
| 103 | bool retry); | ||
| 104 | int(__cdecl* stat)(const struct AddonInstance_VFSEntry* instance, | ||
| 105 | const struct VFSURL* url, | ||
| 106 | struct STAT_STRUCTURE* buffer); | ||
| 107 | bool(__cdecl* close)(const struct AddonInstance_VFSEntry* instance, VFS_FILE_HANDLE context); | ||
| 108 | |||
| 109 | bool(__cdecl* exists)(const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url); | ||
| 110 | void(__cdecl* clear_out_idle)(const struct AddonInstance_VFSEntry* instance); | ||
| 111 | void(__cdecl* disconnect_all)(const struct AddonInstance_VFSEntry* instance); | ||
| 112 | bool(__cdecl* delete_it)(const struct AddonInstance_VFSEntry* instance, | ||
| 113 | const struct VFSURL* url); | ||
| 114 | bool(__cdecl* rename)(const struct AddonInstance_VFSEntry* instance, | ||
| 115 | const struct VFSURL* url, | ||
| 116 | const struct VFSURL* url2); | ||
| 117 | bool(__cdecl* directory_exists)(const struct AddonInstance_VFSEntry* instance, | ||
| 118 | const struct VFSURL* url); | ||
| 119 | bool(__cdecl* remove_directory)(const struct AddonInstance_VFSEntry* instance, | ||
| 120 | const struct VFSURL* url); | ||
| 121 | bool(__cdecl* create_directory)(const struct AddonInstance_VFSEntry* instance, | ||
| 122 | const struct VFSURL* url); | ||
| 123 | bool(__cdecl* get_directory)(const struct AddonInstance_VFSEntry* instance, | ||
| 124 | const struct VFSURL* url, | ||
| 125 | struct VFSDirEntry** entries, | ||
| 126 | int* num_entries, | ||
| 127 | struct VFSGetDirectoryCallbacks* callbacks); | ||
| 128 | bool(__cdecl* contains_files)(const struct AddonInstance_VFSEntry* instance, | ||
| 129 | const struct VFSURL* url, | ||
| 130 | struct VFSDirEntry** entries, | ||
| 131 | int* num_entries, | ||
| 132 | char* rootpath); | ||
| 133 | void(__cdecl* free_directory)(const struct AddonInstance_VFSEntry* instance, | ||
| 134 | struct VFSDirEntry* entries, | ||
| 135 | int num_entries); | ||
| 136 | } KodiToAddonFuncTable_VFSEntry; | ||
| 137 | |||
| 138 | typedef struct AddonInstance_VFSEntry /* internal */ | ||
| 139 | { | ||
| 140 | struct AddonProps_VFSEntry* props; | ||
| 141 | struct AddonToKodiFuncTable_VFSEntry* toKodi; | ||
| 142 | struct KodiToAddonFuncTable_VFSEntry* toAddon; | ||
| 143 | } AddonInstance_VFSEntry; | ||
| 144 | |||
| 145 | #ifdef __cplusplus | ||
| 146 | } /* extern "C" */ | ||
| 147 | #endif /* __cplusplus */ | ||
| 148 | |||
| 149 | #endif /* !C_API_ADDONINSTANCE_VFS_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/visualization.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/visualization.h new file mode 100644 index 0000000..913aad8 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/visualization.h | |||
| @@ -0,0 +1,117 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../addon_base.h" | ||
| 12 | |||
| 13 | #define VIZ_LYRICS_SIZE 32768 | ||
| 14 | |||
| 15 | #ifdef __cplusplus | ||
| 16 | extern "C" | ||
| 17 | { | ||
| 18 | #endif /* __cplusplus */ | ||
| 19 | |||
| 20 | struct VIS_INFO | ||
| 21 | { | ||
| 22 | bool bWantsFreq; | ||
| 23 | int iSyncDelay; | ||
| 24 | }; | ||
| 25 | |||
| 26 | struct VIS_TRACK | ||
| 27 | { | ||
| 28 | const char *title; | ||
| 29 | const char *artist; | ||
| 30 | const char *album; | ||
| 31 | const char *albumArtist; | ||
| 32 | const char *genre; | ||
| 33 | const char *comment; | ||
| 34 | const char *lyrics; | ||
| 35 | |||
| 36 | const char *reserved1; | ||
| 37 | const char *reserved2; | ||
| 38 | |||
| 39 | int trackNumber; | ||
| 40 | int discNumber; | ||
| 41 | int duration; | ||
| 42 | int year; | ||
| 43 | int rating; | ||
| 44 | |||
| 45 | int reserved3; | ||
| 46 | int reserved4; | ||
| 47 | }; | ||
| 48 | |||
| 49 | typedef struct AddonProps_Visualization | ||
| 50 | { | ||
| 51 | ADDON_HARDWARE_CONTEXT device; | ||
| 52 | int x; | ||
| 53 | int y; | ||
| 54 | int width; | ||
| 55 | int height; | ||
| 56 | float pixelRatio; | ||
| 57 | const char* name; | ||
| 58 | const char* presets; | ||
| 59 | const char* profile; | ||
| 60 | } AddonProps_Visualization; | ||
| 61 | |||
| 62 | typedef struct AddonToKodiFuncTable_Visualization | ||
| 63 | { | ||
| 64 | KODI_HANDLE kodiInstance; | ||
| 65 | void(__cdecl* transfer_preset)(KODI_HANDLE kodiInstance, const char* preset); | ||
| 66 | void(__cdecl* clear_presets)(KODI_HANDLE kodiInstance); | ||
| 67 | } AddonToKodiFuncTable_Visualization; | ||
| 68 | |||
| 69 | struct AddonInstance_Visualization; | ||
| 70 | |||
| 71 | typedef struct KodiToAddonFuncTable_Visualization | ||
| 72 | { | ||
| 73 | KODI_HANDLE addonInstance; | ||
| 74 | bool(__cdecl* start)(const struct AddonInstance_Visualization* instance, | ||
| 75 | int channels, | ||
| 76 | int samples_per_sec, | ||
| 77 | int bits_per_sample, | ||
| 78 | const char* song_name); | ||
| 79 | void(__cdecl* stop)(const struct AddonInstance_Visualization* instance); | ||
| 80 | |||
| 81 | void(__cdecl* get_info)(const struct AddonInstance_Visualization* instance, | ||
| 82 | struct VIS_INFO* info); | ||
| 83 | |||
| 84 | void(__cdecl* audio_data)(const struct AddonInstance_Visualization* instance, | ||
| 85 | const float* audio_data, | ||
| 86 | int audio_data_length, | ||
| 87 | float* freq_data, | ||
| 88 | int freq_data_length); | ||
| 89 | bool(__cdecl* is_dirty)(const struct AddonInstance_Visualization* instance); | ||
| 90 | void(__cdecl* render)(const struct AddonInstance_Visualization* instance); | ||
| 91 | |||
| 92 | unsigned int(__cdecl* get_presets)(const struct AddonInstance_Visualization* instance); | ||
| 93 | int(__cdecl* get_active_preset)(const struct AddonInstance_Visualization* instance); | ||
| 94 | bool(__cdecl* prev_preset)(const struct AddonInstance_Visualization* instance); | ||
| 95 | bool(__cdecl* next_preset)(const struct AddonInstance_Visualization* instance); | ||
| 96 | bool(__cdecl* load_preset)(const struct AddonInstance_Visualization* instance, int select); | ||
| 97 | bool(__cdecl* random_preset)(const struct AddonInstance_Visualization* instance); | ||
| 98 | bool(__cdecl* lock_preset)(const struct AddonInstance_Visualization* instance); | ||
| 99 | bool(__cdecl* rate_preset)(const struct AddonInstance_Visualization* instance, bool plus_minus); | ||
| 100 | bool(__cdecl* is_locked)(const struct AddonInstance_Visualization* instance); | ||
| 101 | |||
| 102 | bool(__cdecl* update_albumart)(const struct AddonInstance_Visualization* instance, | ||
| 103 | const char* albumart); | ||
| 104 | bool(__cdecl* update_track)(const struct AddonInstance_Visualization* instance, | ||
| 105 | const struct VIS_TRACK* track); | ||
| 106 | } KodiToAddonFuncTable_Visualization; | ||
| 107 | |||
| 108 | typedef struct AddonInstance_Visualization | ||
| 109 | { | ||
| 110 | struct AddonProps_Visualization* props; | ||
| 111 | struct AddonToKodiFuncTable_Visualization* toKodi; | ||
| 112 | struct KodiToAddonFuncTable_Visualization* toAddon; | ||
| 113 | } AddonInstance_Visualization; | ||
| 114 | |||
| 115 | #ifdef __cplusplus | ||
| 116 | } /* extern "C" */ | ||
| 117 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon_base.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h index 1924d77..faa99fa 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon_base.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h | |||
| @@ -8,6 +8,13 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_ADDON_BASE_H | ||
| 12 | #define C_API_ADDON_BASE_H | ||
| 13 | |||
| 14 | #if !defined(NOMINMAX) | ||
| 15 | #define NOMINMAX | ||
| 16 | #endif | ||
| 17 | |||
| 11 | #include "stdbool.h" | 18 | #include "stdbool.h" |
| 12 | #include "stdint.h" | 19 | #include "stdint.h" |
| 13 | 20 | ||
| @@ -53,6 +60,9 @@ | |||
| 53 | #define ATTRIBUTE_FORCEINLINE inline | 60 | #define ATTRIBUTE_FORCEINLINE inline |
| 54 | #endif | 61 | #endif |
| 55 | 62 | ||
| 63 | // Hardware specific device context interface | ||
| 64 | #define ADDON_HARDWARE_CONTEXT void* | ||
| 65 | |||
| 56 | /* | 66 | /* |
| 57 | * To have a on add-on and kodi itself handled string always on known size! | 67 | * To have a on add-on and kodi itself handled string always on known size! |
| 58 | */ | 68 | */ |
| @@ -250,3 +260,5 @@ extern "C" | |||
| 250 | #ifdef __cplusplus | 260 | #ifdef __cplusplus |
| 251 | } | 261 | } |
| 252 | #endif /* __cplusplus */ | 262 | #endif /* __cplusplus */ |
| 263 | |||
| 264 | #endif /* !C_API_ADDON_BASE_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/audio_engine.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h index 02e96ac..97510f7 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/audio_engine.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h | |||
| @@ -8,7 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "stdint.h" | 11 | #ifndef C_API_AUDIO_ENGINE_H |
| 12 | #define C_API_AUDIO_ENGINE_H | ||
| 13 | |||
| 14 | #include <stdbool.h> | ||
| 15 | #include <stdint.h> | ||
| 12 | 16 | ||
| 13 | #ifdef __cplusplus | 17 | #ifdef __cplusplus |
| 14 | extern "C" | 18 | extern "C" |
| @@ -35,7 +39,7 @@ extern "C" | |||
| 35 | /// m_audioengine = new kodi::audioengine::CAEStream(format, AUDIO_STREAM_FORCE_RESAMPLE | AUDIO_STREAM_AUTOSTART); | 39 | /// m_audioengine = new kodi::audioengine::CAEStream(format, AUDIO_STREAM_FORCE_RESAMPLE | AUDIO_STREAM_AUTOSTART); |
| 36 | /// ~~~~~~~~~~~~~ | 40 | /// ~~~~~~~~~~~~~ |
| 37 | /// | 41 | /// |
| 38 | //@{ | 42 | ///@{ |
| 39 | typedef enum AudioEngineStreamOptions | 43 | typedef enum AudioEngineStreamOptions |
| 40 | { | 44 | { |
| 41 | /// force resample even if rates match | 45 | /// force resample even if rates match |
| @@ -45,7 +49,7 @@ extern "C" | |||
| 45 | /// autostart the stream when enough data is buffered | 49 | /// autostart the stream when enough data is buffered |
| 46 | AUDIO_STREAM_AUTOSTART = 1 << 2, | 50 | AUDIO_STREAM_AUTOSTART = 1 << 2, |
| 47 | } AudioEngineStreamOptions; | 51 | } AudioEngineStreamOptions; |
| 48 | //@} | 52 | ///@} |
| 49 | //---------------------------------------------------------------------------- | 53 | //---------------------------------------------------------------------------- |
| 50 | 54 | ||
| 51 | //============================================================================ | 55 | //============================================================================ |
| @@ -63,7 +67,7 @@ extern "C" | |||
| 63 | /// format.SetChannelLayout(std::vector<AudioEngineChannel>(AUDIOENGINE_CH_FL, AUDIOENGINE_CH_FR)); | 67 | /// format.SetChannelLayout(std::vector<AudioEngineChannel>(AUDIOENGINE_CH_FL, AUDIOENGINE_CH_FR)); |
| 64 | /// ~~~~~~~~~~~~~ | 68 | /// ~~~~~~~~~~~~~ |
| 65 | /// | 69 | /// |
| 66 | //@{ | 70 | ///@{ |
| 67 | enum AudioEngineChannel | 71 | enum AudioEngineChannel |
| 68 | { | 72 | { |
| 69 | /// Used inside to indicate the end of a list and not for addon use directly. | 73 | /// Used inside to indicate the end of a list and not for addon use directly. |
| @@ -113,7 +117,7 @@ extern "C" | |||
| 113 | /// Maximum possible value, to use e.g. as size inside list | 117 | /// Maximum possible value, to use e.g. as size inside list |
| 114 | AUDIOENGINE_CH_MAX | 118 | AUDIOENGINE_CH_MAX |
| 115 | }; | 119 | }; |
| 116 | //@} | 120 | ///@} |
| 117 | //---------------------------------------------------------------------------- | 121 | //---------------------------------------------------------------------------- |
| 118 | 122 | ||
| 119 | //============================================================================ | 123 | //============================================================================ |
| @@ -141,7 +145,7 @@ extern "C" | |||
| 141 | /// format.SetDataFormat(AUDIOENGINE_FMT_FLOATP); | 145 | /// format.SetDataFormat(AUDIOENGINE_FMT_FLOATP); |
| 142 | /// ~~~~~~~~~~~~~ | 146 | /// ~~~~~~~~~~~~~ |
| 143 | /// | 147 | /// |
| 144 | //@{ | 148 | ///@{ |
| 145 | enum AudioEngineDataFormat | 149 | enum AudioEngineDataFormat |
| 146 | { | 150 | { |
| 147 | /// To define format as invalid | 151 | /// To define format as invalid |
| @@ -217,7 +221,7 @@ extern "C" | |||
| 217 | /// Amount of sample formats. | 221 | /// Amount of sample formats. |
| 218 | AUDIOENGINE_FMT_MAX | 222 | AUDIOENGINE_FMT_MAX |
| 219 | }; | 223 | }; |
| 220 | //@} | 224 | ///@} |
| 221 | //---------------------------------------------------------------------------- | 225 | //---------------------------------------------------------------------------- |
| 222 | 226 | ||
| 223 | /*! | 227 | /*! |
| @@ -306,3 +310,5 @@ extern "C" | |||
| 306 | #ifdef __cplusplus | 310 | #ifdef __cplusplus |
| 307 | } | 311 | } |
| 308 | #endif /* __cplusplus */ | 312 | #endif /* __cplusplus */ |
| 313 | |||
| 314 | #endif /* !C_API_AUDIO_ENGINE_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/filesystem.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h index b68a24c..70f9400 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/filesystem.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h | |||
| @@ -8,6 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_FILESYSTEM_H | ||
| 12 | #define C_API_FILESYSTEM_H | ||
| 13 | |||
| 11 | #include <stdbool.h> | 14 | #include <stdbool.h> |
| 12 | #include <stdint.h> | 15 | #include <stdint.h> |
| 13 | #include <time.h> | 16 | #include <time.h> |
| @@ -25,8 +28,15 @@ typedef intptr_t ssize_t; | |||
| 25 | #ifdef DeleteFile | 28 | #ifdef DeleteFile |
| 26 | #undef DeleteFile | 29 | #undef DeleteFile |
| 27 | #endif // DeleteFile | 30 | #endif // DeleteFile |
| 31 | #ifdef RemoveDirectory | ||
| 32 | #undef RemoveDirectory | ||
| 33 | #endif // RemoveDirectory | ||
| 28 | #endif // _WIN32 | 34 | #endif // _WIN32 |
| 29 | 35 | ||
| 36 | #ifdef TARGET_POSIX // Linux, Mac, FreeBSD | ||
| 37 | #include <sys/types.h> | ||
| 38 | #endif // TARGET_POSIX | ||
| 39 | |||
| 30 | #ifdef __cplusplus | 40 | #ifdef __cplusplus |
| 31 | extern "C" | 41 | extern "C" |
| 32 | { | 42 | { |
| @@ -194,6 +204,19 @@ extern "C" | |||
| 194 | bool isDirectory; | 204 | bool isDirectory; |
| 195 | /// The stat url is a symbolic link | 205 | /// The stat url is a symbolic link |
| 196 | bool isSymLink; | 206 | bool isSymLink; |
| 207 | /// The stat url is block special | ||
| 208 | bool isBlock; | ||
| 209 | /// The stat url is character special | ||
| 210 | bool isCharacter; | ||
| 211 | /// The stat url is FIFO special | ||
| 212 | bool isFifo; | ||
| 213 | /// The stat url is regular | ||
| 214 | bool isRegular; | ||
| 215 | /// The stat url is socket | ||
| 216 | bool isSocket; | ||
| 217 | /// The file serial number, which distinguishes this file from all other files on the same | ||
| 218 | /// device. | ||
| 219 | uint64_t fileSerialNumber; | ||
| 197 | }; | 220 | }; |
| 198 | 221 | ||
| 199 | struct VFS_CACHE_STATUS_DATA | 222 | struct VFS_CACHE_STATUS_DATA |
| @@ -290,6 +313,7 @@ extern "C" | |||
| 290 | 313 | ||
| 291 | bool (*get_disk_space)( | 314 | bool (*get_disk_space)( |
| 292 | void* kodiBase, const char* path, uint64_t* capacity, uint64_t* free, uint64_t* available); | 315 | void* kodiBase, const char* path, uint64_t* capacity, uint64_t* free, uint64_t* available); |
| 316 | bool (*remove_directory_recursive)(void* kodiBase, const char* path); | ||
| 293 | } AddonToKodiFuncTable_kodi_filesystem; | 317 | } AddonToKodiFuncTable_kodi_filesystem; |
| 294 | 318 | ||
| 295 | //}}} | 319 | //}}} |
| @@ -297,3 +321,5 @@ extern "C" | |||
| 297 | #ifdef __cplusplus | 321 | #ifdef __cplusplus |
| 298 | } /* extern "C" */ | 322 | } /* extern "C" */ |
| 299 | #endif /* __cplusplus */ | 323 | #endif /* __cplusplus */ |
| 324 | |||
| 325 | #endif /* !C_API_FILESYSTEM_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/general.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/general.h index ede8e94..12afd02 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/general.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/general.h | |||
| @@ -8,6 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifndef C_API_GENERAL_H | ||
| 12 | #define C_API_GENERAL_H | ||
| 13 | |||
| 14 | #include <stdbool.h> | ||
| 15 | |||
| 11 | #ifdef __cplusplus | 16 | #ifdef __cplusplus |
| 12 | extern "C" | 17 | extern "C" |
| 13 | { | 18 | { |
| @@ -121,3 +126,5 @@ extern "C" | |||
| 121 | #ifdef __cplusplus | 126 | #ifdef __cplusplus |
| 122 | } /* extern "C" */ | 127 | } /* extern "C" */ |
| 123 | #endif /* __cplusplus */ | 128 | #endif /* __cplusplus */ |
| 129 | |||
| 130 | #endif /* !C_API_GENERAL_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/CMakeLists.txt new file mode 100644 index 0000000..53c4e60 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/CMakeLists.txt | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | set(HEADERS definitions.h | ||
| 2 | general.h | ||
| 3 | list_item.h | ||
| 4 | window.h) | ||
| 5 | |||
| 6 | if(NOT ENABLE_STATIC_LIBS) | ||
| 7 | core_add_library(addons_kodi-dev-kit_include_kodi_c-api_gui) | ||
| 8 | endif() | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/CMakeLists.txt new file mode 100644 index 0000000..2e6cd53 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/CMakeLists.txt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | set(HEADERS button.h | ||
| 2 | edit.h | ||
| 3 | fade_label.h | ||
| 4 | image.h | ||
| 5 | label.h | ||
| 6 | progress.h | ||
| 7 | radio_button.h | ||
| 8 | rendering.h | ||
| 9 | settings_slider.h | ||
| 10 | slider.h | ||
| 11 | spin.h | ||
| 12 | text_box.h) | ||
| 13 | |||
| 14 | if(NOT ENABLE_STATIC_LIBS) | ||
| 15 | core_add_library(addons_kodi-dev-kit_include_kodi_c-api_gui_controls) | ||
| 16 | endif() | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/button.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/button.h new file mode 100644 index 0000000..84fd822 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/button.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_CONTROLS_BUTTON_H | ||
| 12 | #define C_API_GUI_CONTROLS_BUTTON_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_control_button | ||
| 22 | { | ||
| 23 | void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible); | ||
| 24 | void (*set_enabled)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool enabled); | ||
| 25 | void (*set_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* label); | ||
| 26 | char* (*get_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 27 | void (*set_label2)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* label); | ||
| 28 | char* (*get_label2)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 29 | } AddonToKodiFuncTable_kodi_gui_control_button; | ||
| 30 | |||
| 31 | #ifdef __cplusplus | ||
| 32 | } /* extern "C" */ | ||
| 33 | #endif /* __cplusplus */ | ||
| 34 | |||
| 35 | #endif /* !C_API_GUI_CONTROLS_BUTTON_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/edit.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/edit.h new file mode 100644 index 0000000..ca38b27 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/edit.h | |||
| @@ -0,0 +1,79 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_CONTROLS_EDIT_H | ||
| 12 | #define C_API_GUI_CONTROLS_EDIT_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit_Defs | ||
| 23 | /// @{ | ||
| 24 | /// @anchor AddonGUIInputType | ||
| 25 | /// @brief Text input types used on kodi::gui::controls::CEdit | ||
| 26 | enum AddonGUIInputType | ||
| 27 | { | ||
| 28 | /// Text inside edit control only readable | ||
| 29 | ADDON_INPUT_TYPE_READONLY = -1, | ||
| 30 | /// Normal text entries | ||
| 31 | ADDON_INPUT_TYPE_TEXT = 0, | ||
| 32 | /// To use on edit control only numeric numbers | ||
| 33 | ADDON_INPUT_TYPE_NUMBER, | ||
| 34 | /// To insert seconds | ||
| 35 | ADDON_INPUT_TYPE_SECONDS, | ||
| 36 | /// To insert time | ||
| 37 | ADDON_INPUT_TYPE_TIME, | ||
| 38 | /// To insert a date | ||
| 39 | ADDON_INPUT_TYPE_DATE, | ||
| 40 | /// Used for write in IP addresses | ||
| 41 | ADDON_INPUT_TYPE_IPADDRESS, | ||
| 42 | /// Text field used as password entry field with not visible text | ||
| 43 | ADDON_INPUT_TYPE_PASSWORD, | ||
| 44 | /// Text field used as password entry field with not visible text but | ||
| 45 | /// returned as MD5 value | ||
| 46 | ADDON_INPUT_TYPE_PASSWORD_MD5, | ||
| 47 | /// Use text field for search purpose | ||
| 48 | ADDON_INPUT_TYPE_SEARCH, | ||
| 49 | /// Text field as filter | ||
| 50 | ADDON_INPUT_TYPE_FILTER, | ||
| 51 | /// | ||
| 52 | ADDON_INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW | ||
| 53 | }; | ||
| 54 | /// @} | ||
| 55 | //---------------------------------------------------------------------------- | ||
| 56 | |||
| 57 | typedef struct AddonToKodiFuncTable_kodi_gui_control_edit | ||
| 58 | { | ||
| 59 | void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible); | ||
| 60 | void (*set_enabled)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool enabled); | ||
| 61 | void (*set_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* label); | ||
| 62 | char* (*get_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 63 | void (*set_text)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* text); | ||
| 64 | char* (*get_text)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 65 | void (*set_cursor_position)(KODI_HANDLE kodiBase, | ||
| 66 | KODI_GUI_CONTROL_HANDLE handle, | ||
| 67 | unsigned int position); | ||
| 68 | unsigned int (*get_cursor_position)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 69 | void (*set_input_type)(KODI_HANDLE kodiBase, | ||
| 70 | KODI_GUI_CONTROL_HANDLE handle, | ||
| 71 | int type, | ||
| 72 | const char* heading); | ||
| 73 | } AddonToKodiFuncTable_kodi_gui_control_edit; | ||
| 74 | |||
| 75 | #ifdef __cplusplus | ||
| 76 | } /* extern "C" */ | ||
| 77 | #endif /* __cplusplus */ | ||
| 78 | |||
| 79 | #endif /* !C_API_GUI_CONTROLS_EDIT_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/fade_label.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/fade_label.h new file mode 100644 index 0000000..fea014b --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/fade_label.h | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_CONTROLS_FADE_LABEL_H | ||
| 12 | #define C_API_GUI_CONTROLS_FADE_LABEL_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_control_fade_label | ||
| 22 | { | ||
| 23 | void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible); | ||
| 24 | void (*add_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* text); | ||
| 25 | char* (*get_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 26 | void (*set_scrolling)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool scroll); | ||
| 27 | void (*reset)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 28 | } AddonToKodiFuncTable_kodi_gui_control_fade_label; | ||
| 29 | |||
| 30 | #ifdef __cplusplus | ||
| 31 | } /* extern "C" */ | ||
| 32 | #endif /* __cplusplus */ | ||
| 33 | |||
| 34 | #endif /* !C_API_GUI_CONTROLS_FADE_LABEL_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/image.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/image.h new file mode 100644 index 0000000..4a46e6d --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/image.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_CONTROLS_IMAGE_H | ||
| 12 | #define C_API_GUI_CONTROLS_IMAGE_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_control_image | ||
| 22 | { | ||
| 23 | void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible); | ||
| 24 | void (*set_filename)(KODI_HANDLE kodiBase, | ||
| 25 | KODI_GUI_CONTROL_HANDLE handle, | ||
| 26 | const char* filename, | ||
| 27 | bool use_cache); | ||
| 28 | void (*set_color_diffuse)(KODI_HANDLE kodiBase, | ||
| 29 | KODI_GUI_CONTROL_HANDLE handle, | ||
| 30 | uint32_t color_diffuse); | ||
| 31 | } AddonToKodiFuncTable_kodi_gui_control_image; | ||
| 32 | |||
| 33 | #ifdef __cplusplus | ||
| 34 | } /* extern "C" */ | ||
| 35 | #endif /* __cplusplus */ | ||
| 36 | |||
| 37 | #endif /* !C_API_GUI_CONTROLS_IMAGE_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/label.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/label.h new file mode 100644 index 0000000..d8a9fe4 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/label.h | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_CONTROLS_LABEL_H | ||
| 12 | #define C_API_GUI_CONTROLS_LABEL_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_control_label | ||
| 22 | { | ||
| 23 | void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible); | ||
| 24 | void (*set_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* text); | ||
| 25 | char* (*get_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 26 | } AddonToKodiFuncTable_kodi_gui_control_label; | ||
| 27 | |||
| 28 | #ifdef __cplusplus | ||
| 29 | } /* extern "C" */ | ||
| 30 | #endif /* __cplusplus */ | ||
| 31 | |||
| 32 | #endif /* !C_API_GUI_CONTROLS_LABEL_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/progress.h new file mode 100644 index 0000000..88638e0 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/progress.h | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_CONTROLS_PROGRESS_H | ||
| 12 | #define C_API_GUI_CONTROLS_PROGRESS_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_control_progress | ||
| 22 | { | ||
| 23 | void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible); | ||
| 24 | void (*set_percentage)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, float percent); | ||
| 25 | float (*get_percentage)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 26 | } AddonToKodiFuncTable_kodi_gui_control_progress; | ||
| 27 | |||
| 28 | #ifdef __cplusplus | ||
| 29 | } /* extern "C" */ | ||
| 30 | #endif /* __cplusplus */ | ||
| 31 | |||
| 32 | #endif /* !C_API_GUI_CONTROLS_PROGRESS_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/radio_button.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/radio_button.h new file mode 100644 index 0000000..a672d95 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/radio_button.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_CONTROLS_RADIO_BUTTON_H | ||
| 12 | #define C_API_GUI_CONTROLS_RADIO_BUTTON_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_control_radio_button | ||
| 22 | { | ||
| 23 | void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible); | ||
| 24 | void (*set_enabled)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool enabled); | ||
| 25 | void (*set_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* text); | ||
| 26 | char* (*get_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 27 | void (*set_selected)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool selected); | ||
| 28 | bool (*is_selected)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 29 | } AddonToKodiFuncTable_kodi_gui_control_radio_button; | ||
| 30 | |||
| 31 | #ifdef __cplusplus | ||
| 32 | } /* extern "C" */ | ||
| 33 | #endif /* __cplusplus */ | ||
| 34 | |||
| 35 | #endif /* !C_API_GUI_CONTROLS_RADIO_BUTTON_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/rendering.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/rendering.h new file mode 100644 index 0000000..d4053a6 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/rendering.h | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_CONTROLS_RENDERING_H | ||
| 12 | #define C_API_GUI_CONTROLS_RENDERING_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_control_rendering | ||
| 22 | { | ||
| 23 | void (*set_callbacks)( | ||
| 24 | KODI_HANDLE kodiBase, | ||
| 25 | KODI_GUI_CONTROL_HANDLE handle, | ||
| 26 | KODI_GUI_CLIENT_HANDLE clienthandle, | ||
| 27 | bool (*createCB)(KODI_GUI_CLIENT_HANDLE, int, int, int, int, ADDON_HARDWARE_CONTEXT), | ||
| 28 | void (*renderCB)(KODI_GUI_CLIENT_HANDLE), | ||
| 29 | void (*stopCB)(KODI_GUI_CLIENT_HANDLE), | ||
| 30 | bool (*dirtyCB)(KODI_GUI_CLIENT_HANDLE)); | ||
| 31 | void (*destroy)(void* kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 32 | } AddonToKodiFuncTable_kodi_gui_control_rendering; | ||
| 33 | |||
| 34 | #ifdef __cplusplus | ||
| 35 | } /* extern "C" */ | ||
| 36 | #endif /* __cplusplus */ | ||
| 37 | |||
| 38 | #endif /* !C_API_GUI_CONTROLS_RENDERING_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/settings_slider.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/settings_slider.h new file mode 100644 index 0000000..2cbc972 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/settings_slider.h | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_CONTROLS_SETTINGS_SLIDER_H | ||
| 12 | #define C_API_GUI_CONTROLS_SETTINGS_SLIDER_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_control_settings_slider | ||
| 22 | { | ||
| 23 | void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible); | ||
| 24 | void (*set_enabled)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool enabled); | ||
| 25 | void (*set_text)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* label); | ||
| 26 | void (*reset)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 27 | void (*set_int_range)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int start, int end); | ||
| 28 | void (*set_int_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int value); | ||
| 29 | int (*get_int_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 30 | void (*set_int_interval)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int interval); | ||
| 31 | void (*set_percentage)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, float percent); | ||
| 32 | float (*get_percentage)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 33 | void (*set_float_range)(KODI_HANDLE kodiBase, | ||
| 34 | KODI_GUI_CONTROL_HANDLE handle, | ||
| 35 | float start, | ||
| 36 | float end); | ||
| 37 | void (*set_float_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, float value); | ||
| 38 | float (*get_float_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 39 | void (*set_float_interval)(KODI_HANDLE kodiBase, | ||
| 40 | KODI_GUI_CONTROL_HANDLE handle, | ||
| 41 | float interval); | ||
| 42 | } AddonToKodiFuncTable_kodi_gui_control_settings_slider; | ||
| 43 | |||
| 44 | #ifdef __cplusplus | ||
| 45 | } /* extern "C" */ | ||
| 46 | #endif /* __cplusplus */ | ||
| 47 | |||
| 48 | #endif /* !C_API_GUI_CONTROLS_SETTINGS_SLIDER_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/slider.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/slider.h new file mode 100644 index 0000000..0a67208 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/slider.h | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_CONTROLS_SLIDER_H | ||
| 12 | #define C_API_GUI_CONTROLS_SLIDER_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_control_slider | ||
| 22 | { | ||
| 23 | void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible); | ||
| 24 | void (*set_enabled)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool enabled); | ||
| 25 | void (*reset)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 26 | char* (*get_description)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 27 | void (*set_int_range)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int start, int end); | ||
| 28 | void (*set_int_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int value); | ||
| 29 | int (*get_int_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 30 | void (*set_int_interval)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int interval); | ||
| 31 | void (*set_percentage)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, float percent); | ||
| 32 | float (*get_percentage)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 33 | void (*set_float_range)(KODI_HANDLE kodiBase, | ||
| 34 | KODI_GUI_CONTROL_HANDLE handle, | ||
| 35 | float start, | ||
| 36 | float end); | ||
| 37 | void (*set_float_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, float value); | ||
| 38 | float (*get_float_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 39 | void (*set_float_interval)(KODI_HANDLE kodiBase, | ||
| 40 | KODI_GUI_CONTROL_HANDLE handle, | ||
| 41 | float interval); | ||
| 42 | } AddonToKodiFuncTable_kodi_gui_control_slider; | ||
| 43 | |||
| 44 | #ifdef __cplusplus | ||
| 45 | } /* extern "C" */ | ||
| 46 | #endif /* __cplusplus */ | ||
| 47 | |||
| 48 | #endif /* !C_API_GUI_CONTROLS_SLIDER_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/spin.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/spin.h new file mode 100644 index 0000000..d5e5c86 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/spin.h | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_CONTROLS_SPIN_H | ||
| 12 | #define C_API_GUI_CONTROLS_SPIN_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_control_spin | ||
| 22 | { | ||
| 23 | void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible); | ||
| 24 | void (*set_enabled)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool enabled); | ||
| 25 | void (*set_text)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* text); | ||
| 26 | void (*reset)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 27 | void (*set_type)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int type); | ||
| 28 | void (*add_string_label)(KODI_HANDLE kodiBase, | ||
| 29 | KODI_GUI_CONTROL_HANDLE handle, | ||
| 30 | const char* label, | ||
| 31 | const char* value); | ||
| 32 | void (*set_string_value)(KODI_HANDLE kodiBase, | ||
| 33 | KODI_GUI_CONTROL_HANDLE handle, | ||
| 34 | const char* value); | ||
| 35 | char* (*get_string_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 36 | void (*add_int_label)(KODI_HANDLE kodiBase, | ||
| 37 | KODI_GUI_CONTROL_HANDLE handle, | ||
| 38 | const char* label, | ||
| 39 | int value); | ||
| 40 | void (*set_int_range)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int start, int end); | ||
| 41 | void (*set_int_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int value); | ||
| 42 | int (*get_int_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 43 | void (*set_float_range)(KODI_HANDLE kodiBase, | ||
| 44 | KODI_GUI_CONTROL_HANDLE handle, | ||
| 45 | float start, | ||
| 46 | float end); | ||
| 47 | void (*set_float_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, float value); | ||
| 48 | float (*get_float_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 49 | void (*set_float_interval)(KODI_HANDLE kodiBase, | ||
| 50 | KODI_GUI_CONTROL_HANDLE handle, | ||
| 51 | float interval); | ||
| 52 | } AddonToKodiFuncTable_kodi_gui_control_spin; | ||
| 53 | |||
| 54 | #ifdef __cplusplus | ||
| 55 | } /* extern "C" */ | ||
| 56 | #endif /* __cplusplus */ | ||
| 57 | |||
| 58 | #endif /* !C_API_GUI_CONTROLS_SPIN_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/text_box.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/text_box.h new file mode 100644 index 0000000..276d04c --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/text_box.h | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_CONTROLS_TEXT_BOX_H | ||
| 12 | #define C_API_GUI_CONTROLS_TEXT_BOX_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_control_text_box | ||
| 22 | { | ||
| 23 | void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible); | ||
| 24 | void (*reset)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 25 | void (*set_text)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* text); | ||
| 26 | char* (*get_text)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle); | ||
| 27 | void (*scroll)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, unsigned int scroll); | ||
| 28 | void (*set_auto_scrolling)( | ||
| 29 | KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int delay, int time, int repeat); | ||
| 30 | } AddonToKodiFuncTable_kodi_gui_control_text_box; | ||
| 31 | |||
| 32 | #ifdef __cplusplus | ||
| 33 | } /* extern "C" */ | ||
| 34 | #endif /* __cplusplus */ | ||
| 35 | |||
| 36 | #endif /* !C_API_GUI_CONTROLS_TEXT_BOX_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/definitions.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/definitions.h new file mode 100644 index 0000000..ec60bc2 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/definitions.h | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_DEFINITIONS_H | ||
| 12 | #define C_API_GUI_DEFINITIONS_H | ||
| 13 | |||
| 14 | #include "../addon_base.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef void* KODI_GUI_HANDLE; | ||
| 22 | typedef void* KODI_GUI_CLIENT_HANDLE; | ||
| 23 | typedef void* KODI_GUI_CONTROL_HANDLE; | ||
| 24 | typedef void* KODI_GUI_LISTITEM_HANDLE; | ||
| 25 | typedef void* KODI_GUI_WINDOW_HANDLE; | ||
| 26 | |||
| 27 | struct AddonToKodiFuncTable_kodi_gui_general; | ||
| 28 | struct AddonToKodiFuncTable_kodi_gui_control_button; | ||
| 29 | struct AddonToKodiFuncTable_kodi_gui_control_edit; | ||
| 30 | struct AddonToKodiFuncTable_kodi_gui_control_fade_label; | ||
| 31 | struct AddonToKodiFuncTable_kodi_gui_control_label; | ||
| 32 | struct AddonToKodiFuncTable_kodi_gui_control_image; | ||
| 33 | struct AddonToKodiFuncTable_kodi_gui_control_progress; | ||
| 34 | struct AddonToKodiFuncTable_kodi_gui_control_radio_button; | ||
| 35 | struct AddonToKodiFuncTable_kodi_gui_control_rendering; | ||
| 36 | struct AddonToKodiFuncTable_kodi_gui_control_settings_slider; | ||
| 37 | struct AddonToKodiFuncTable_kodi_gui_control_slider; | ||
| 38 | struct AddonToKodiFuncTable_kodi_gui_control_spin; | ||
| 39 | struct AddonToKodiFuncTable_kodi_gui_control_text_box; | ||
| 40 | struct AddonToKodiFuncTable_kodi_gui_dialogContextMenu; | ||
| 41 | struct AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress; | ||
| 42 | struct AddonToKodiFuncTable_kodi_gui_dialogFileBrowser; | ||
| 43 | struct AddonToKodiFuncTable_kodi_gui_dialogKeyboard; | ||
| 44 | struct AddonToKodiFuncTable_kodi_gui_dialogNumeric; | ||
| 45 | struct AddonToKodiFuncTable_kodi_gui_dialogOK; | ||
| 46 | struct AddonToKodiFuncTable_kodi_gui_dialogProgress; | ||
| 47 | struct AddonToKodiFuncTable_kodi_gui_dialogSelect; | ||
| 48 | struct AddonToKodiFuncTable_kodi_gui_dialogTextViewer; | ||
| 49 | struct AddonToKodiFuncTable_kodi_gui_dialogYesNo; | ||
| 50 | struct AddonToKodiFuncTable_kodi_gui_listItem; | ||
| 51 | struct AddonToKodiFuncTable_kodi_gui_window; | ||
| 52 | |||
| 53 | typedef struct AddonToKodiFuncTable_kodi_gui | ||
| 54 | { | ||
| 55 | struct AddonToKodiFuncTable_kodi_gui_general* general; | ||
| 56 | struct AddonToKodiFuncTable_kodi_gui_control_button* control_button; | ||
| 57 | struct AddonToKodiFuncTable_kodi_gui_control_edit* control_edit; | ||
| 58 | struct AddonToKodiFuncTable_kodi_gui_control_fade_label* control_fade_label; | ||
| 59 | struct AddonToKodiFuncTable_kodi_gui_control_label* control_label; | ||
| 60 | struct AddonToKodiFuncTable_kodi_gui_control_image* control_image; | ||
| 61 | struct AddonToKodiFuncTable_kodi_gui_control_progress* control_progress; | ||
| 62 | struct AddonToKodiFuncTable_kodi_gui_control_radio_button* control_radio_button; | ||
| 63 | struct AddonToKodiFuncTable_kodi_gui_control_rendering* control_rendering; | ||
| 64 | struct AddonToKodiFuncTable_kodi_gui_control_settings_slider* control_settings_slider; | ||
| 65 | struct AddonToKodiFuncTable_kodi_gui_control_slider* control_slider; | ||
| 66 | struct AddonToKodiFuncTable_kodi_gui_control_spin* control_spin; | ||
| 67 | struct AddonToKodiFuncTable_kodi_gui_control_text_box* control_text_box; | ||
| 68 | KODI_HANDLE control_dummy1; | ||
| 69 | KODI_HANDLE control_dummy2; | ||
| 70 | KODI_HANDLE control_dummy3; | ||
| 71 | KODI_HANDLE control_dummy4; | ||
| 72 | KODI_HANDLE control_dummy5; | ||
| 73 | KODI_HANDLE control_dummy6; | ||
| 74 | KODI_HANDLE control_dummy7; | ||
| 75 | KODI_HANDLE control_dummy8; | ||
| 76 | KODI_HANDLE control_dummy9; | ||
| 77 | KODI_HANDLE control_dummy10; /* This and above used to add new controls */ | ||
| 78 | struct AddonToKodiFuncTable_kodi_gui_dialogContextMenu* dialogContextMenu; | ||
| 79 | struct AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress* dialogExtendedProgress; | ||
| 80 | struct AddonToKodiFuncTable_kodi_gui_dialogFileBrowser* dialogFileBrowser; | ||
| 81 | struct AddonToKodiFuncTable_kodi_gui_dialogKeyboard* dialogKeyboard; | ||
| 82 | struct AddonToKodiFuncTable_kodi_gui_dialogNumeric* dialogNumeric; | ||
| 83 | struct AddonToKodiFuncTable_kodi_gui_dialogOK* dialogOK; | ||
| 84 | struct AddonToKodiFuncTable_kodi_gui_dialogProgress* dialogProgress; | ||
| 85 | struct AddonToKodiFuncTable_kodi_gui_dialogSelect* dialogSelect; | ||
| 86 | struct AddonToKodiFuncTable_kodi_gui_dialogTextViewer* dialogTextViewer; | ||
| 87 | struct AddonToKodiFuncTable_kodi_gui_dialogYesNo* dialogYesNo; | ||
| 88 | KODI_HANDLE dialog_dummy1; | ||
| 89 | KODI_HANDLE dialog_dummy2; | ||
| 90 | KODI_HANDLE dialog_dummy3; | ||
| 91 | KODI_HANDLE dialog_dummy4; | ||
| 92 | KODI_HANDLE dialog_dummy5; | ||
| 93 | KODI_HANDLE dialog_dummy6; | ||
| 94 | KODI_HANDLE dialog_dummy7; | ||
| 95 | KODI_HANDLE dialog_dummy8; | ||
| 96 | KODI_HANDLE dialog_dummy9; | ||
| 97 | KODI_HANDLE dialog_dummy10; /* This and above used to add new dialogs */ | ||
| 98 | struct AddonToKodiFuncTable_kodi_gui_listItem* listItem; | ||
| 99 | struct AddonToKodiFuncTable_kodi_gui_window* window; | ||
| 100 | } AddonToKodiFuncTable_kodi_gui; | ||
| 101 | |||
| 102 | #ifdef __cplusplus | ||
| 103 | } /* extern "C" */ | ||
| 104 | #endif /* __cplusplus */ | ||
| 105 | |||
| 106 | #endif /* !C_API_GUI_DEFINITIONS_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/CMakeLists.txt new file mode 100644 index 0000000..bc35e91 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/CMakeLists.txt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | set(HEADERS context_menu.h | ||
| 2 | extended_progress.h | ||
| 3 | filebrowser.h | ||
| 4 | keyboard.h | ||
| 5 | numeric.h | ||
| 6 | ok.h | ||
| 7 | progress.h | ||
| 8 | select.h | ||
| 9 | text_viewer.h | ||
| 10 | yes_no.h) | ||
| 11 | |||
| 12 | if(NOT ENABLE_STATIC_LIBS) | ||
| 13 | core_add_library(addons_kodi-dev-kit_include_kodi_c-api_gui_dialogs) | ||
| 14 | endif() | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/context_menu.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/context_menu.h new file mode 100644 index 0000000..8bb5370 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/context_menu.h | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_DIALOGS_CONTEXT_MENU_H | ||
| 12 | #define C_API_GUI_DIALOGS_CONTEXT_MENU_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogContextMenu | ||
| 22 | { | ||
| 23 | int (*open)(KODI_HANDLE kodiBase, | ||
| 24 | const char* heading, | ||
| 25 | const char* entries[], | ||
| 26 | unsigned int size); | ||
| 27 | } AddonToKodiFuncTable_kodi_gui_dialogContextMenu; | ||
| 28 | |||
| 29 | #ifdef __cplusplus | ||
| 30 | } /* extern "C" */ | ||
| 31 | #endif /* __cplusplus */ | ||
| 32 | |||
| 33 | #endif /* !C_API_GUI_DIALOGS_CONTEXT_MENU_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/extended_progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/extended_progress.h new file mode 100644 index 0000000..e53588f --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/extended_progress.h | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_DIALOGS_EXTENDED_PROGRESS_H | ||
| 12 | #define C_API_GUI_DIALOGS_EXTENDED_PROGRESS_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress | ||
| 22 | { | ||
| 23 | KODI_GUI_HANDLE (*new_dialog)(KODI_HANDLE kodiBase, const char* title); | ||
| 24 | void (*delete_dialog)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle); | ||
| 25 | char* (*get_title)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle); | ||
| 26 | void (*set_title)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, const char* title); | ||
| 27 | char* (*get_text)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle); | ||
| 28 | void (*set_text)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, const char* text); | ||
| 29 | bool (*is_finished)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle); | ||
| 30 | void (*mark_finished)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle); | ||
| 31 | float (*get_percentage)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle); | ||
| 32 | void (*set_percentage)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, float percentage); | ||
| 33 | void (*set_progress)(KODI_HANDLE kodiBase, | ||
| 34 | KODI_GUI_HANDLE handle, | ||
| 35 | int currentItem, | ||
| 36 | int itemCount); | ||
| 37 | } AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress; | ||
| 38 | |||
| 39 | #ifdef __cplusplus | ||
| 40 | } /* extern "C" */ | ||
| 41 | #endif /* __cplusplus */ | ||
| 42 | |||
| 43 | #endif /* !C_API_GUI_DIALOGS_EXTENDED_PROGRESS_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/filebrowser.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/filebrowser.h new file mode 100644 index 0000000..7ae4fac --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/filebrowser.h | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_DIALOGS_FILEBROWSER_H | ||
| 12 | #define C_API_GUI_DIALOGS_FILEBROWSER_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogFileBrowser | ||
| 22 | { | ||
| 23 | bool (*show_and_get_directory)(KODI_HANDLE kodiBase, | ||
| 24 | const char* shares, | ||
| 25 | const char* heading, | ||
| 26 | const char* path_in, | ||
| 27 | char** path_out, | ||
| 28 | bool writeOnly); | ||
| 29 | bool (*show_and_get_file)(KODI_HANDLE kodiBase, | ||
| 30 | const char* shares, | ||
| 31 | const char* mask, | ||
| 32 | const char* heading, | ||
| 33 | const char* path_in, | ||
| 34 | char** path_out, | ||
| 35 | bool use_thumbs, | ||
| 36 | bool use_file_directories); | ||
| 37 | bool (*show_and_get_file_from_dir)(KODI_HANDLE kodiBase, | ||
| 38 | const char* directory, | ||
| 39 | const char* mask, | ||
| 40 | const char* heading, | ||
| 41 | const char* path_in, | ||
| 42 | char** path_out, | ||
| 43 | bool use_thumbs, | ||
| 44 | bool use_file_directories, | ||
| 45 | bool singleList); | ||
| 46 | bool (*show_and_get_file_list)(KODI_HANDLE kodiBase, | ||
| 47 | const char* shares, | ||
| 48 | const char* mask, | ||
| 49 | const char* heading, | ||
| 50 | char*** file_list, | ||
| 51 | unsigned int* entries, | ||
| 52 | bool use_thumbs, | ||
| 53 | bool use_file_directories); | ||
| 54 | bool (*show_and_get_source)(KODI_HANDLE kodiBase, | ||
| 55 | const char* path_in, | ||
| 56 | char** path_out, | ||
| 57 | bool allow_network_shares, | ||
| 58 | const char* additional_share, | ||
| 59 | const char* type); | ||
| 60 | bool (*show_and_get_image)(KODI_HANDLE kodiBase, | ||
| 61 | const char* shares, | ||
| 62 | const char* heading, | ||
| 63 | const char* path_in, | ||
| 64 | char** path_out); | ||
| 65 | bool (*show_and_get_image_list)(KODI_HANDLE kodiBase, | ||
| 66 | const char* shares, | ||
| 67 | const char* heading, | ||
| 68 | char*** file_list, | ||
| 69 | unsigned int* entries); | ||
| 70 | void (*clear_file_list)(KODI_HANDLE kodiBase, char*** file_list, unsigned int entries); | ||
| 71 | } AddonToKodiFuncTable_kodi_gui_dialogFileBrowser; | ||
| 72 | |||
| 73 | #ifdef __cplusplus | ||
| 74 | } /* extern "C" */ | ||
| 75 | #endif /* __cplusplus */ | ||
| 76 | |||
| 77 | #endif /* !C_API_GUI_DIALOGS_FILEBROWSER_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/keyboard.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/keyboard.h new file mode 100644 index 0000000..fc3c34c --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/keyboard.h | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_DIALOGS_KEYBOARD_H | ||
| 12 | #define C_API_GUI_DIALOGS_KEYBOARD_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogKeyboard | ||
| 22 | { | ||
| 23 | bool (*show_and_get_input_with_head)(KODI_HANDLE kodiBase, | ||
| 24 | const char* text_in, | ||
| 25 | char** text_out, | ||
| 26 | const char* heading, | ||
| 27 | bool allow_empty_result, | ||
| 28 | bool hiddenInput, | ||
| 29 | unsigned int auto_close_ms); | ||
| 30 | bool (*show_and_get_input)(KODI_HANDLE kodiBase, | ||
| 31 | const char* text_in, | ||
| 32 | char** text_out, | ||
| 33 | bool allow_empty_result, | ||
| 34 | unsigned int auto_close_ms); | ||
| 35 | bool (*show_and_get_new_password_with_head)(KODI_HANDLE kodiBase, | ||
| 36 | const char* password_in, | ||
| 37 | char** password_out, | ||
| 38 | const char* heading, | ||
| 39 | bool allow_empty_result, | ||
| 40 | unsigned int auto_close_ms); | ||
| 41 | bool (*show_and_get_new_password)(KODI_HANDLE kodiBase, | ||
| 42 | const char* password_in, | ||
| 43 | char** password_out, | ||
| 44 | unsigned int auto_close_ms); | ||
| 45 | bool (*show_and_verify_new_password_with_head)(KODI_HANDLE kodiBase, | ||
| 46 | char** password_out, | ||
| 47 | const char* heading, | ||
| 48 | bool allow_empty_result, | ||
| 49 | unsigned int auto_close_ms); | ||
| 50 | bool (*show_and_verify_new_password)(KODI_HANDLE kodiBase, | ||
| 51 | char** password_out, | ||
| 52 | unsigned int auto_close_ms); | ||
| 53 | int (*show_and_verify_password)(KODI_HANDLE kodiBase, | ||
| 54 | const char* password_in, | ||
| 55 | char** password_out, | ||
| 56 | const char* heading, | ||
| 57 | int retries, | ||
| 58 | unsigned int auto_close_ms); | ||
| 59 | bool (*show_and_get_filter)(KODI_HANDLE kodiBase, | ||
| 60 | const char* text_in, | ||
| 61 | char** text_out, | ||
| 62 | bool searching, | ||
| 63 | unsigned int auto_close_ms); | ||
| 64 | bool (*send_text_to_active_keyboard)(KODI_HANDLE kodiBase, | ||
| 65 | const char* text, | ||
| 66 | bool close_keyboard); | ||
| 67 | bool (*is_keyboard_activated)(KODI_HANDLE kodiBase); | ||
| 68 | } AddonToKodiFuncTable_kodi_gui_dialogKeyboard; | ||
| 69 | |||
| 70 | #ifdef __cplusplus | ||
| 71 | } /* extern "C" */ | ||
| 72 | #endif /* __cplusplus */ | ||
| 73 | |||
| 74 | #endif /* !C_API_GUI_DIALOGS_KEYBOARD_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/numeric.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/numeric.h new file mode 100644 index 0000000..df23cd7 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/numeric.h | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_DIALOGS_NUMERIC_H | ||
| 12 | #define C_API_GUI_DIALOGS_NUMERIC_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogNumeric | ||
| 22 | { | ||
| 23 | bool (*show_and_verify_new_password)(KODI_HANDLE kodiBase, char** password); | ||
| 24 | int (*show_and_verify_password)(KODI_HANDLE kodiBase, | ||
| 25 | const char* password, | ||
| 26 | const char* heading, | ||
| 27 | int retries); | ||
| 28 | bool (*show_and_verify_input)(KODI_HANDLE kodiBase, | ||
| 29 | const char* verify_in, | ||
| 30 | char** verify_out, | ||
| 31 | const char* heading, | ||
| 32 | bool verify_input); | ||
| 33 | bool (*show_and_get_time)(KODI_HANDLE kodiBase, struct tm* time, const char* heading); | ||
| 34 | bool (*show_and_get_date)(KODI_HANDLE kodiBase, struct tm* date, const char* heading); | ||
| 35 | bool (*show_and_get_ip_address)(KODI_HANDLE kodiBase, | ||
| 36 | const char* ip_address_in, | ||
| 37 | char** ip_address_out, | ||
| 38 | const char* heading); | ||
| 39 | bool (*show_and_get_number)(KODI_HANDLE kodiBase, | ||
| 40 | const char* input_in, | ||
| 41 | char** input_out, | ||
| 42 | const char* heading, | ||
| 43 | unsigned int auto_close_ms); | ||
| 44 | bool (*show_and_get_seconds)(KODI_HANDLE kodiBase, | ||
| 45 | const char* time_in, | ||
| 46 | char** time_out, | ||
| 47 | const char* heading); | ||
| 48 | } AddonToKodiFuncTable_kodi_gui_dialogNumeric; | ||
| 49 | |||
| 50 | #ifdef __cplusplus | ||
| 51 | } /* extern "C" */ | ||
| 52 | #endif /* __cplusplus */ | ||
| 53 | |||
| 54 | #endif /* !C_API_GUI_DIALOGS_NUMERIC_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/ok.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/ok.h new file mode 100644 index 0000000..9f37051 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/ok.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_DIALOGS_OK_H | ||
| 12 | #define C_API_GUI_DIALOGS_OK_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogOK | ||
| 22 | { | ||
| 23 | void (*show_and_get_input_single_text)(KODI_HANDLE kodiBase, | ||
| 24 | const char* heading, | ||
| 25 | const char* text); | ||
| 26 | void (*show_and_get_input_line_text)(KODI_HANDLE kodiBase, | ||
| 27 | const char* heading, | ||
| 28 | const char* line0, | ||
| 29 | const char* line1, | ||
| 30 | const char* line2); | ||
| 31 | } AddonToKodiFuncTable_kodi_gui_dialogOK; | ||
| 32 | |||
| 33 | #ifdef __cplusplus | ||
| 34 | } /* extern "C" */ | ||
| 35 | #endif /* __cplusplus */ | ||
| 36 | |||
| 37 | #endif /* !C_API_GUI_DIALOGS_OK_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/progress.h new file mode 100644 index 0000000..f1c8972 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/progress.h | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_DIALOGS_PROGRESS_H | ||
| 12 | #define C_API_GUI_DIALOGS_PROGRESS_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogProgress | ||
| 22 | { | ||
| 23 | KODI_GUI_HANDLE (*new_dialog)(KODI_HANDLE kodiBase); | ||
| 24 | void (*delete_dialog)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle); | ||
| 25 | void (*open)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle); | ||
| 26 | void (*set_heading)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, const char* heading); | ||
| 27 | void (*set_line)(KODI_HANDLE kodiBase, | ||
| 28 | KODI_GUI_HANDLE handle, | ||
| 29 | unsigned int lineNo, | ||
| 30 | const char* line); | ||
| 31 | void (*set_can_cancel)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, bool canCancel); | ||
| 32 | bool (*is_canceled)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle); | ||
| 33 | void (*set_percentage)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, int percentage); | ||
| 34 | int (*get_percentage)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle); | ||
| 35 | void (*show_progress_bar)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, bool pnOff); | ||
| 36 | void (*set_progress_max)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, int max); | ||
| 37 | void (*set_progress_advance)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, int nSteps); | ||
| 38 | bool (*abort)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle); | ||
| 39 | } AddonToKodiFuncTable_kodi_gui_dialogProgress; | ||
| 40 | |||
| 41 | #ifdef __cplusplus | ||
| 42 | } /* extern "C" */ | ||
| 43 | #endif /* __cplusplus */ | ||
| 44 | |||
| 45 | #endif /* !C_API_GUI_DIALOGS_PROGRESS_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/select.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/select.h new file mode 100644 index 0000000..41ab82f --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/select.h | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_DIALOGS_SELECT_H | ||
| 12 | #define C_API_GUI_DIALOGS_SELECT_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogSelect | ||
| 22 | { | ||
| 23 | int (*open)(KODI_HANDLE kodiBase, | ||
| 24 | const char* heading, | ||
| 25 | const char* entries[], | ||
| 26 | unsigned int size, | ||
| 27 | int selected, | ||
| 28 | unsigned int autoclose); | ||
| 29 | bool (*open_multi_select)(KODI_HANDLE kodiBase, | ||
| 30 | const char* heading, | ||
| 31 | const char* entryIDs[], | ||
| 32 | const char* entryNames[], | ||
| 33 | bool entriesSelected[], | ||
| 34 | unsigned int size, | ||
| 35 | unsigned int autoclose); | ||
| 36 | } AddonToKodiFuncTable_kodi_gui_dialogSelect; | ||
| 37 | |||
| 38 | #ifdef __cplusplus | ||
| 39 | } /* extern "C" */ | ||
| 40 | #endif /* __cplusplus */ | ||
| 41 | |||
| 42 | #endif /* !C_API_GUI_DIALOGS_SELECT_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/text_viewer.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/text_viewer.h new file mode 100644 index 0000000..eb38b0b --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/text_viewer.h | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_DIALOGS_TEXT_VIEWER_H | ||
| 12 | #define C_API_GUI_DIALOGS_TEXT_VIEWER_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogTextViewer | ||
| 22 | { | ||
| 23 | void (*open)(KODI_HANDLE kodiBase, const char* heading, const char* text); | ||
| 24 | } AddonToKodiFuncTable_kodi_gui_dialogTextViewer; | ||
| 25 | |||
| 26 | #ifdef __cplusplus | ||
| 27 | } /* extern "C" */ | ||
| 28 | #endif /* __cplusplus */ | ||
| 29 | |||
| 30 | #endif /* !C_API_GUI_DIALOGS_TEXT_VIEWER_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/yes_no.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/yes_no.h new file mode 100644 index 0000000..01ed806 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/yes_no.h | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_DIALOGS_YES_NO_H | ||
| 12 | #define C_API_GUI_DIALOGS_YES_NO_H | ||
| 13 | |||
| 14 | #include "../definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogYesNo | ||
| 22 | { | ||
| 23 | bool (*show_and_get_input_single_text)(KODI_HANDLE kodiBase, | ||
| 24 | const char* heading, | ||
| 25 | const char* text, | ||
| 26 | bool* canceled, | ||
| 27 | const char* noLabel, | ||
| 28 | const char* yesLabel); | ||
| 29 | bool (*show_and_get_input_line_text)(KODI_HANDLE kodiBase, | ||
| 30 | const char* heading, | ||
| 31 | const char* line0, | ||
| 32 | const char* line1, | ||
| 33 | const char* line2, | ||
| 34 | const char* noLabel, | ||
| 35 | const char* yesLabel); | ||
| 36 | bool (*show_and_get_input_line_button_text)(KODI_HANDLE kodiBase, | ||
| 37 | const char* heading, | ||
| 38 | const char* line0, | ||
| 39 | const char* line1, | ||
| 40 | const char* line2, | ||
| 41 | bool* canceled, | ||
| 42 | const char* noLabel, | ||
| 43 | const char* yesLabel); | ||
| 44 | } AddonToKodiFuncTable_kodi_gui_dialogYesNo; | ||
| 45 | |||
| 46 | #ifdef __cplusplus | ||
| 47 | } /* extern "C" */ | ||
| 48 | #endif /* __cplusplus */ | ||
| 49 | |||
| 50 | #endif /* !C_API_GUI_DIALOGS_YES_NO_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/general.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/general.h new file mode 100644 index 0000000..d0d256c --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/general.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_GENERAL_H | ||
| 12 | #define C_API_GUI_GENERAL_H | ||
| 13 | |||
| 14 | #include "definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_general | ||
| 22 | { | ||
| 23 | void (*lock)(); | ||
| 24 | void (*unlock)(); | ||
| 25 | int (*get_screen_height)(KODI_HANDLE kodiBase); | ||
| 26 | int (*get_screen_width)(KODI_HANDLE kodiBase); | ||
| 27 | int (*get_video_resolution)(KODI_HANDLE kodiBase); | ||
| 28 | int (*get_current_window_dialog_id)(KODI_HANDLE kodiBase); | ||
| 29 | int (*get_current_window_id)(KODI_HANDLE kodiBase); | ||
| 30 | ADDON_HARDWARE_CONTEXT (*get_hw_context)(KODI_HANDLE kodiBase); | ||
| 31 | } AddonToKodiFuncTable_kodi_gui_general; | ||
| 32 | |||
| 33 | #ifdef __cplusplus | ||
| 34 | } /* extern "C" */ | ||
| 35 | #endif /* __cplusplus */ | ||
| 36 | |||
| 37 | #endif /* !C_API_GUI_GENERAL_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/CMakeLists.txt new file mode 100644 index 0000000..c0bbd11 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/CMakeLists.txt | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | set(HEADERS action_ids.h) | ||
| 2 | |||
| 3 | if(NOT ENABLE_STATIC_LIBS) | ||
| 4 | core_add_library(addons_kodi-dev-kit_include_kodi_c-api_gui_input) | ||
| 5 | endif() | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/action_ids.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/action_ids.h new file mode 100644 index 0000000..274f3d9 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/action_ids.h | |||
| @@ -0,0 +1,763 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_ACTION_IDS_H | ||
| 12 | #define C_API_GUI_ACTION_IDS_H | ||
| 13 | |||
| 14 | /// @defgroup cpp_kodi_gui_Defs_action_ids enum ADDON_ACTION | ||
| 15 | /// @ingroup cpp_kodi_gui_Defs | ||
| 16 | /// @brief **Action Id's**\n | ||
| 17 | /// Actions that we have defined. | ||
| 18 | /// | ||
| 19 | ///@{ | ||
| 20 | enum ADDON_ACTION | ||
| 21 | { | ||
| 22 | /// @ingroup cpp_kodi_gui_key_action_ids | ||
| 23 | ///@{ | ||
| 24 | |||
| 25 | /// @brief <b>`0 `</b>: None. | ||
| 26 | ADDON_ACTION_NONE = 0, | ||
| 27 | |||
| 28 | /// @brief <b>`1 `</b>: Move left. | ||
| 29 | ADDON_ACTION_MOVE_LEFT = 1, | ||
| 30 | |||
| 31 | /// @brief <b>`2 `</b>: Move right. | ||
| 32 | ADDON_ACTION_MOVE_RIGHT = 2, | ||
| 33 | |||
| 34 | /// @brief <b>`3 `</b>: Move up. | ||
| 35 | ADDON_ACTION_MOVE_UP = 3, | ||
| 36 | |||
| 37 | /// @brief <b>`4 `</b>: Move down. | ||
| 38 | ADDON_ACTION_MOVE_DOWN = 4, | ||
| 39 | |||
| 40 | /// @brief <b>`5 `</b>: Page up. | ||
| 41 | ADDON_ACTION_PAGE_UP = 5, | ||
| 42 | |||
| 43 | /// @brief <b>`6 `</b>: Page down. | ||
| 44 | ADDON_ACTION_PAGE_DOWN = 6, | ||
| 45 | |||
| 46 | /// @brief <b>`7 `</b>: Select item. | ||
| 47 | ADDON_ACTION_SELECT_ITEM = 7, | ||
| 48 | |||
| 49 | /// @brief <b>`8 `</b>: Highlight item. | ||
| 50 | ADDON_ACTION_HIGHLIGHT_ITEM = 8, | ||
| 51 | |||
| 52 | /// @brief <b>`9 `</b>: Parent directory. | ||
| 53 | ADDON_ACTION_PARENT_DIR = 9, | ||
| 54 | |||
| 55 | /// @brief <b>`10 `</b>: Previous menu. | ||
| 56 | ADDON_ACTION_PREVIOUS_MENU = 10, | ||
| 57 | |||
| 58 | /// @brief <b>`11 `</b>: Show info. | ||
| 59 | ADDON_ACTION_SHOW_INFO = 11, | ||
| 60 | |||
| 61 | /// @brief <b>`12 `</b>: Pause. | ||
| 62 | ADDON_ACTION_PAUSE = 12, | ||
| 63 | |||
| 64 | /// @brief <b>`13 `</b>: Stop. | ||
| 65 | ADDON_ACTION_STOP = 13, | ||
| 66 | |||
| 67 | /// @brief <b>`14 `</b>: Next item. | ||
| 68 | ADDON_ACTION_NEXT_ITEM = 14, | ||
| 69 | |||
| 70 | /// @brief <b>`15 `</b>: Previous item. | ||
| 71 | ADDON_ACTION_PREV_ITEM = 15, | ||
| 72 | |||
| 73 | /// @brief <b>`16 `</b>: Can be used to specify specific action in a window, Playback control is handled in ADDON_ACTION_PLAYER_* | ||
| 74 | ADDON_ACTION_FORWARD = 16, | ||
| 75 | |||
| 76 | /// @brief <b>`17 `</b>: Can be used to specify specific action in a window, Playback control is handled in ADDON_ACTION_PLAYER_* | ||
| 77 | ADDON_ACTION_REWIND = 17, | ||
| 78 | |||
| 79 | /// @brief <b>`18 `</b>: Toggle between GUI and movie or GUI and visualisation. | ||
| 80 | ADDON_ACTION_SHOW_GUI = 18, | ||
| 81 | |||
| 82 | /// @brief <b>`19 `</b>: Toggle quick-access zoom modes. Can b used in videoFullScreen.zml window id=2005 | ||
| 83 | ADDON_ACTION_ASPECT_RATIO = 19, | ||
| 84 | |||
| 85 | /// @brief <b>`20 `</b>: Seek +1% in the movie. Can b used in videoFullScreen.xml window id=2005 | ||
| 86 | ADDON_ACTION_STEP_FORWARD = 20, | ||
| 87 | |||
| 88 | /// @brief <b>`21 `</b>: Seek -1% in the movie. Can b used in videoFullScreen.xml window id=2005 | ||
| 89 | ADDON_ACTION_STEP_BACK = 21, | ||
| 90 | |||
| 91 | /// @brief <b>`22 `</b>: Seek +10% in the movie. Can b used in videoFullScreen.xml window id=2005 | ||
| 92 | ADDON_ACTION_BIG_STEP_FORWARD = 22, | ||
| 93 | |||
| 94 | /// @brief <b>`23 `</b>: Seek -10% in the movie. Can b used in videoFullScreen.xml window id=2005 | ||
| 95 | ADDON_ACTION_BIG_STEP_BACK = 23, | ||
| 96 | |||
| 97 | /// @brief <b>`24 `</b>: Show/hide OSD. Can b used in videoFullScreen.xml window id=2005 | ||
| 98 | ADDON_ACTION_SHOW_OSD = 24, | ||
| 99 | |||
| 100 | /// @brief <b>`25 `</b>: Turn subtitles on/off. Can b used in videoFullScreen.xml window id=2005 | ||
| 101 | ADDON_ACTION_SHOW_SUBTITLES = 25, | ||
| 102 | |||
| 103 | /// @brief <b>`26 `</b>: Switch to next subtitle of movie. Can b used in videoFullScreen.xml window id=2005 | ||
| 104 | ADDON_ACTION_NEXT_SUBTITLE = 26, | ||
| 105 | |||
| 106 | /// @brief <b>`27 `</b>: Show debug info for VideoPlayer | ||
| 107 | ADDON_ACTION_PLAYER_DEBUG = 27, | ||
| 108 | |||
| 109 | /// @brief <b>`28 `</b>: Show next picture of slideshow. Can b used in slideshow.xml window id=2007 | ||
| 110 | ADDON_ACTION_NEXT_PICTURE = 28, | ||
| 111 | |||
| 112 | /// @brief <b>`29 `</b>: Show previous picture of slideshow. Can b used in slideshow.xml window id=2007 | ||
| 113 | ADDON_ACTION_PREV_PICTURE = 29, | ||
| 114 | |||
| 115 | /// @brief <b>`30 `</b>: Zoom in picture during slideshow. Can b used in slideshow.xml window id=2007 | ||
| 116 | ADDON_ACTION_ZOOM_OUT = 30, | ||
| 117 | |||
| 118 | /// @brief <b>`31 `</b>: Zoom out picture during slideshow. Can b used in slideshow.xml window id=2007 | ||
| 119 | ADDON_ACTION_ZOOM_IN = 31, | ||
| 120 | |||
| 121 | /// @brief <b>`32 `</b>: Used to toggle between source view and destination view. Can be used in myfiles.xml window id=3 | ||
| 122 | ADDON_ACTION_TOGGLE_SOURCE_DEST = 32, | ||
| 123 | |||
| 124 | /// @brief <b>`33 `</b>: Used to toggle between current view and playlist view. Can b used in all mymusic xml files | ||
| 125 | ADDON_ACTION_SHOW_PLAYLIST = 33, | ||
| 126 | |||
| 127 | /// @brief <b>`34 `</b>: Used to queue a item to the playlist. Can b used in all mymusic xml files | ||
| 128 | ADDON_ACTION_QUEUE_ITEM = 34, | ||
| 129 | |||
| 130 | /// @brief <b>`35 `</b>: Not used anymore | ||
| 131 | ADDON_ACTION_REMOVE_ITEM = 35, | ||
| 132 | |||
| 133 | /// @brief <b>`36 `</b>: Not used anymore | ||
| 134 | ADDON_ACTION_SHOW_FULLSCREEN = 36, | ||
| 135 | |||
| 136 | /// @brief <b>`37 `</b>: Zoom 1x picture during slideshow. Can b used in slideshow.xml window id=2007 | ||
| 137 | ADDON_ACTION_ZOOM_LEVEL_NORMAL = 37, | ||
| 138 | |||
| 139 | /// @brief <b>`38 `</b>: Zoom 2x picture during slideshow. Can b used in slideshow.xml window id=2007 | ||
| 140 | ADDON_ACTION_ZOOM_LEVEL_1 = 38, | ||
| 141 | |||
| 142 | /// @brief <b>`39 `</b>: Zoom 3x picture during slideshow. Can b used in slideshow.xml window id=2007 | ||
| 143 | ADDON_ACTION_ZOOM_LEVEL_2 = 39, | ||
| 144 | |||
| 145 | /// @brief <b>`40 `</b>: Zoom 4x picture during slideshow. Can b used in slideshow.xml window id=2007 | ||
| 146 | ADDON_ACTION_ZOOM_LEVEL_3 = 40, | ||
| 147 | |||
| 148 | /// @brief <b>`41 `</b>: Zoom 5x picture during slideshow. Can b used in slideshow.xml window id=2007 | ||
| 149 | ADDON_ACTION_ZOOM_LEVEL_4 = 41, | ||
| 150 | |||
| 151 | /// @brief <b>`42 `</b>: Zoom 6x picture during slideshow. Can b used in slideshow.xml window id=2007 | ||
| 152 | ADDON_ACTION_ZOOM_LEVEL_5 = 42, | ||
| 153 | |||
| 154 | /// @brief <b>`43 `</b>: Zoom 7x picture during slideshow. Can b used in slideshow.xml window id=2007 | ||
| 155 | ADDON_ACTION_ZOOM_LEVEL_6 = 43, | ||
| 156 | |||
| 157 | /// @brief <b>`44 `</b>: Zoom 8x picture during slideshow. Can b used in slideshow.xml window id=2007 | ||
| 158 | ADDON_ACTION_ZOOM_LEVEL_7 = 44, | ||
| 159 | |||
| 160 | /// @brief <b>`45 `</b>: Zoom 9x picture during slideshow. Can b used in slideshow.xml window id=2007 | ||
| 161 | ADDON_ACTION_ZOOM_LEVEL_8 = 45, | ||
| 162 | |||
| 163 | /// @brief <b>`46 `</b>: Zoom 10x picture during slideshow. Can b used in slideshow.xml window id=2007 | ||
| 164 | ADDON_ACTION_ZOOM_LEVEL_9 = 46, | ||
| 165 | |||
| 166 | /// @brief <b>`47 `</b>: Select next arrow. Can b used in: settingsScreenCalibration.xml windowid=11 | ||
| 167 | ADDON_ACTION_CALIBRATE_SWAP_ARROWS = 47, | ||
| 168 | |||
| 169 | /// @brief <b>`48 `</b>: Reset calibration to defaults. Can b used in: `settingsScreenCalibration.xml` windowid=11/settingsUICalibration.xml windowid=10 | ||
| 170 | ADDON_ACTION_CALIBRATE_RESET = 48, | ||
| 171 | |||
| 172 | /// @brief <b>`49 `</b>: Analog thumbstick move. Can b used in: `slideshow.xml` | ||
| 173 | /// windowid=2007/settingsScreenCalibration.xml windowid=11/settingsUICalibration.xml | ||
| 174 | /// windowid=10 | ||
| 175 | /// @note see also ADDON_ACTION_ANALOG_MOVE_X_LEFT, ADDON_ACTION_ANALOG_MOVE_X_RIGHT, | ||
| 176 | /// ADDON_ACTION_ANALOG_MOVE_Y_UP, ADDON_ACTION_ANALOG_MOVE_Y_DOWN | ||
| 177 | ADDON_ACTION_ANALOG_MOVE = 49, | ||
| 178 | |||
| 179 | /// @brief <b>`50 `</b>: Rotate current picture clockwise during slideshow. Can be used in slideshow.xml window id=2007 | ||
| 180 | ADDON_ACTION_ROTATE_PICTURE_CW = 50, | ||
| 181 | |||
| 182 | /// @brief <b>`51 `</b>: Rotate current picture counterclockwise during slideshow. Can be used in slideshow.xml window id=2007 | ||
| 183 | ADDON_ACTION_ROTATE_PICTURE_CCW = 51, | ||
| 184 | |||
| 185 | /// @brief <b>`52 `</b>: Decrease subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005 | ||
| 186 | ADDON_ACTION_SUBTITLE_DELAY_MIN = 52, | ||
| 187 | |||
| 188 | /// @brief <b>`53 `</b>: Increase subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005 | ||
| 189 | ADDON_ACTION_SUBTITLE_DELAY_PLUS = 53, | ||
| 190 | |||
| 191 | /// @brief <b>`54 `</b>: Increase avsync delay. Can b used in videoFullScreen.xml window id=2005 | ||
| 192 | ADDON_ACTION_AUDIO_DELAY_MIN = 54, | ||
| 193 | |||
| 194 | /// @brief <b>`55 `</b>: Decrease avsync delay. Can b used in videoFullScreen.xml window id=2005 | ||
| 195 | ADDON_ACTION_AUDIO_DELAY_PLUS = 55, | ||
| 196 | |||
| 197 | /// @brief <b>`56 `</b>: Select next language in movie. Can b used in videoFullScreen.xml window id=2005 | ||
| 198 | ADDON_ACTION_AUDIO_NEXT_LANGUAGE = 56, | ||
| 199 | |||
| 200 | /// @brief <b>`57 `</b>: Switch 2 next resolution. Can b used during screen calibration settingsScreenCalibration.xml windowid=11 | ||
| 201 | ADDON_ACTION_CHANGE_RESOLUTION = 57, | ||
| 202 | |||
| 203 | /// @brief <b>`58 `</b>: remote keys 0-9. are used by multiple windows | ||
| 204 | /// for example in videoFullScreen.xml window id=2005 you can | ||
| 205 | /// enter time (mmss) to jump to particular point in the movie | ||
| 206 | /// with spincontrols you can enter 3digit number to quickly set | ||
| 207 | /// spincontrol to desired value | ||
| 208 | /// | ||
| 209 | /// Remote key 0 | ||
| 210 | ADDON_ACTION_REMOTE_0 = 58, | ||
| 211 | |||
| 212 | /// @brief <b>`59 `</b>: Remote key 1 | ||
| 213 | ADDON_ACTION_REMOTE_1 = 59, | ||
| 214 | |||
| 215 | /// @brief <b>`60 `</b>: Remote key 2 | ||
| 216 | ADDON_ACTION_REMOTE_2 = 60, | ||
| 217 | |||
| 218 | /// @brief <b>`61 `</b>: Remote key 3 | ||
| 219 | ADDON_ACTION_REMOTE_3 = 61, | ||
| 220 | |||
| 221 | /// @brief <b>`62 `</b>: Remote key 4 | ||
| 222 | ADDON_ACTION_REMOTE_4 = 62, | ||
| 223 | |||
| 224 | /// @brief <b>`63 `</b>: Remote key 5 | ||
| 225 | ADDON_ACTION_REMOTE_5 = 63, | ||
| 226 | |||
| 227 | /// @brief <b>`64 `</b>: Remote key 6 | ||
| 228 | ADDON_ACTION_REMOTE_6 = 64, | ||
| 229 | |||
| 230 | /// @brief <b>`65 `</b>: Remote key 7 | ||
| 231 | ADDON_ACTION_REMOTE_7 = 65, | ||
| 232 | |||
| 233 | /// @brief <b>`66 `</b>: Remote key 8 | ||
| 234 | ADDON_ACTION_REMOTE_8 = 66, | ||
| 235 | |||
| 236 | /// @brief <b>`67 `</b>: Remote key 9 | ||
| 237 | ADDON_ACTION_REMOTE_9 = 67, | ||
| 238 | |||
| 239 | /// @brief <b>`69 `</b>: Show player process info (video decoder, pixel format, pvr signal strength and the like | ||
| 240 | ADDON_ACTION_PLAYER_PROCESS_INFO = 69, | ||
| 241 | |||
| 242 | /// @brief <b>`70 `</b>: Program select. | ||
| 243 | ADDON_ACTION_PLAYER_PROGRAM_SELECT = 70, | ||
| 244 | |||
| 245 | /// @brief <b>`71 `</b>: Resolution select. | ||
| 246 | ADDON_ACTION_PLAYER_RESOLUTION_SELECT = 71, | ||
| 247 | |||
| 248 | /// @brief <b>`76 `</b>: Jumps a few seconds back during playback of movie. Can b used in videoFullScreen.xml window id=2005 | ||
| 249 | ADDON_ACTION_SMALL_STEP_BACK = 76, | ||
| 250 | |||
| 251 | /// @brief <b>`77 `</b>: FF in current file played. global action, can be used anywhere | ||
| 252 | ADDON_ACTION_PLAYER_FORWARD = 77, | ||
| 253 | |||
| 254 | /// @brief <b>`78 `</b>: RW in current file played. global action, can be used anywhere | ||
| 255 | ADDON_ACTION_PLAYER_REWIND = 78, | ||
| 256 | |||
| 257 | /// @brief <b>`79 `</b>: Play current song. Unpauses song and sets playspeed to 1x. global action, can be used anywhere | ||
| 258 | ADDON_ACTION_PLAYER_PLAY = 79, | ||
| 259 | |||
| 260 | /// @brief <b>`80 `</b>: Delete current selected item. Can be used in myfiles.xml window id=3 and in myvideoTitle.xml window id=25 | ||
| 261 | ADDON_ACTION_DELETE_ITEM = 80, | ||
| 262 | |||
| 263 | /// @brief <b>`81 `</b>: Copy current selected item. Can be used in myfiles.xml window id=3 | ||
| 264 | ADDON_ACTION_COPY_ITEM = 81, | ||
| 265 | |||
| 266 | /// @brief <b>`82 `</b>: move current selected item. Can be used in myfiles.xml window id=3 | ||
| 267 | ADDON_ACTION_MOVE_ITEM = 82, | ||
| 268 | |||
| 269 | /// @brief <b>`85 `</b>: Take a screenshot. | ||
| 270 | ADDON_ACTION_TAKE_SCREENSHOT = 85, | ||
| 271 | |||
| 272 | /// @brief <b>`87 `</b>: Rename item. | ||
| 273 | ADDON_ACTION_RENAME_ITEM = 87, | ||
| 274 | |||
| 275 | /// @brief <b>`87 `</b>: Volume up. | ||
| 276 | ADDON_ACTION_VOLUME_UP = 88, | ||
| 277 | |||
| 278 | /// @brief <b>`87 `</b>: Volume down. | ||
| 279 | ADDON_ACTION_VOLUME_DOWN = 89, | ||
| 280 | |||
| 281 | /// @brief <b>`90 `</b>: Volume amplication. | ||
| 282 | ADDON_ACTION_VOLAMP = 90, | ||
| 283 | |||
| 284 | /// @brief <b>`90 `</b>: Mute. | ||
| 285 | ADDON_ACTION_MUTE = 91, | ||
| 286 | |||
| 287 | /// @brief <b>`90 `</b>: Nav back. | ||
| 288 | ADDON_ACTION_NAV_BACK = 92, | ||
| 289 | |||
| 290 | /// @brief <b>`90 `</b>: Volume amp up, | ||
| 291 | ADDON_ACTION_VOLAMP_UP = 93, | ||
| 292 | |||
| 293 | /// @brief <b>`94 `</b>: Volume amp down. | ||
| 294 | ADDON_ACTION_VOLAMP_DOWN = 94, | ||
| 295 | |||
| 296 | /// @brief <b>`95 `</b>: Creates an episode bookmark on the currently playing video file containing more than one | ||
| 297 | /// episode | ||
| 298 | ADDON_ACTION_CREATE_EPISODE_BOOKMARK = 95, | ||
| 299 | |||
| 300 | /// @brief <b>`96 `</b>: Creates a bookmark of the currently playing video file | ||
| 301 | ADDON_ACTION_CREATE_BOOKMARK = 96, | ||
| 302 | |||
| 303 | /// @brief <b>`97 `</b>: Goto the next chapter, if not available perform a big step forward | ||
| 304 | ADDON_ACTION_CHAPTER_OR_BIG_STEP_FORWARD = 97, | ||
| 305 | |||
| 306 | /// @brief <b>`98 `</b>: Goto the previous chapter, if not available perform a big step back | ||
| 307 | ADDON_ACTION_CHAPTER_OR_BIG_STEP_BACK = 98, | ||
| 308 | |||
| 309 | /// @brief <b>`99 `</b>: Switch to next subtitle of movie, but will not enable/disable the subtitles. Can be used | ||
| 310 | /// in videoFullScreen.xml window id=2005 | ||
| 311 | ADDON_ACTION_CYCLE_SUBTITLE = 99, | ||
| 312 | |||
| 313 | /// @brief <b>`100`</b>: Mouse action values start. | ||
| 314 | /// | ||
| 315 | /// Ends with @ref ADDON_ACTION_MOUSE_END. | ||
| 316 | ADDON_ACTION_MOUSE_START = 100, | ||
| 317 | |||
| 318 | /// @brief <b>`100`</b>: Mouse left click. | ||
| 319 | ADDON_ACTION_MOUSE_LEFT_CLICK = 100, | ||
| 320 | |||
| 321 | /// @brief <b>`101`</b>: Mouse right click. | ||
| 322 | ADDON_ACTION_MOUSE_RIGHT_CLICK = 101, | ||
| 323 | |||
| 324 | /// @brief <b>`102`</b>: Mouse middle click. | ||
| 325 | ADDON_ACTION_MOUSE_MIDDLE_CLICK = 102, | ||
| 326 | |||
| 327 | /// @brief <b>`103`</b>: Mouse double click. | ||
| 328 | ADDON_ACTION_MOUSE_DOUBLE_CLICK = 103, | ||
| 329 | |||
| 330 | /// @brief <b>`104`</b>: Mouse wheel up. | ||
| 331 | ADDON_ACTION_MOUSE_WHEEL_UP = 104, | ||
| 332 | |||
| 333 | /// @brief <b>`105`</b>: Mouse wheel down. | ||
| 334 | ADDON_ACTION_MOUSE_WHEEL_DOWN = 105, | ||
| 335 | |||
| 336 | /// @brief <b>`106`</b>: Mouse drag. | ||
| 337 | ADDON_ACTION_MOUSE_DRAG = 106, | ||
| 338 | |||
| 339 | /// @brief <b>`107`</b>: Mouse move. | ||
| 340 | ADDON_ACTION_MOUSE_MOVE = 107, | ||
| 341 | |||
| 342 | /// @brief <b>`108`</b>: Mouse long click. | ||
| 343 | ADDON_ACTION_MOUSE_LONG_CLICK = 108, | ||
| 344 | |||
| 345 | /// @brief <b>`109`</b>: Mouse drag end. | ||
| 346 | ADDON_ACTION_MOUSE_DRAG_END = 109, | ||
| 347 | |||
| 348 | /// @brief <b>`109`</b>: Mouse action values end. | ||
| 349 | /// | ||
| 350 | /// Starts with @ref ADDON_ACTION_MOUSE_START. | ||
| 351 | ADDON_ACTION_MOUSE_END = 109, | ||
| 352 | |||
| 353 | /// @brief <b>`110`</b>: Backspace. | ||
| 354 | ADDON_ACTION_BACKSPACE = 110, | ||
| 355 | |||
| 356 | /// @brief <b>`111`</b>: Scroll up. | ||
| 357 | ADDON_ACTION_SCROLL_UP = 111, | ||
| 358 | |||
| 359 | /// @brief <b>`112`</b>: Scroll down. | ||
| 360 | ADDON_ACTION_SCROLL_DOWN = 112, | ||
| 361 | |||
| 362 | /// @brief <b>`113`</b>: Analog forward. | ||
| 363 | ADDON_ACTION_ANALOG_FORWARD = 113, | ||
| 364 | |||
| 365 | /// @brief <b>`114`</b>: Analog rewind. | ||
| 366 | ADDON_ACTION_ANALOG_REWIND = 114, | ||
| 367 | |||
| 368 | /// @brief <b>`115`</b>: move item up in playlist | ||
| 369 | ADDON_ACTION_MOVE_ITEM_UP = 115, | ||
| 370 | |||
| 371 | /// @brief <b>`116`</b>: move item down in playlist | ||
| 372 | ADDON_ACTION_MOVE_ITEM_DOWN = 116, | ||
| 373 | |||
| 374 | /// @brief <b>`117`</b>: pops up the context menu | ||
| 375 | ADDON_ACTION_CONTEXT_MENU = 117, | ||
| 376 | |||
| 377 | /// @brief <b>`118`</b>: stuff for virtual keyboard shortcuts | ||
| 378 | ADDON_ACTION_SHIFT = 118, | ||
| 379 | |||
| 380 | /// @brief <b>`119`</b>: stuff for virtual keyboard shortcuts | ||
| 381 | ADDON_ACTION_SYMBOLS = 119, | ||
| 382 | |||
| 383 | /// @brief <b>`120`</b>: stuff for virtual keyboard shortcuts | ||
| 384 | ADDON_ACTION_CURSOR_LEFT = 120, | ||
| 385 | |||
| 386 | /// @brief <b>`121`</b>: stuff for virtual keyboard shortcuts | ||
| 387 | ADDON_ACTION_CURSOR_RIGHT = 121, | ||
| 388 | |||
| 389 | /// @brief <b>`122`</b>: Build in function | ||
| 390 | ADDON_ACTION_BUILT_IN_FUNCTION = 122, | ||
| 391 | |||
| 392 | /// @brief <b>`114`</b>: Displays current time, can be used in videoFullScreen.xml window id=2005 | ||
| 393 | ADDON_ACTION_SHOW_OSD_TIME = 123, | ||
| 394 | |||
| 395 | /// @brief <b>`124`</b>: Seeks forward, and displays the seek bar. | ||
| 396 | ADDON_ACTION_ANALOG_SEEK_FORWARD = 124, | ||
| 397 | |||
| 398 | /// @brief <b>`125`</b>: Seeks backward, and displays the seek bar. | ||
| 399 | ADDON_ACTION_ANALOG_SEEK_BACK = 125, | ||
| 400 | |||
| 401 | /// @brief <b>`126`</b>: Visualization preset show. | ||
| 402 | ADDON_ACTION_VIS_PRESET_SHOW = 126, | ||
| 403 | |||
| 404 | /// @brief <b>`128`</b>: Visualization preset next. | ||
| 405 | ADDON_ACTION_VIS_PRESET_NEXT = 128, | ||
| 406 | |||
| 407 | /// @brief <b>`129`</b>: Visualization preset previous. | ||
| 408 | ADDON_ACTION_VIS_PRESET_PREV = 129, | ||
| 409 | |||
| 410 | /// @brief <b>`130`</b>: Visualization preset lock. | ||
| 411 | ADDON_ACTION_VIS_PRESET_LOCK = 130, | ||
| 412 | |||
| 413 | /// @brief <b>`131`</b>: Visualization preset random. | ||
| 414 | ADDON_ACTION_VIS_PRESET_RANDOM = 131, | ||
| 415 | |||
| 416 | /// @brief <b>`132`</b>: Visualization preset plus. | ||
| 417 | ADDON_ACTION_VIS_RATE_PRESET_PLUS = 132, | ||
| 418 | |||
| 419 | /// @brief <b>`133`</b>: Visualization preset minus. | ||
| 420 | ADDON_ACTION_VIS_RATE_PRESET_MINUS = 133, | ||
| 421 | |||
| 422 | /// @brief <b>`134`</b>: Show Videomenu | ||
| 423 | ADDON_ACTION_SHOW_VIDEOMENU = 134, | ||
| 424 | |||
| 425 | /// @brief <b>`135`</b>: Enter. | ||
| 426 | ADDON_ACTION_ENTER = 135, | ||
| 427 | |||
| 428 | /// @brief <b>`136`</b>: Increase rating. | ||
| 429 | ADDON_ACTION_INCREASE_RATING = 136, | ||
| 430 | |||
| 431 | /// @brief <b>`137`</b>: Decrease rating. | ||
| 432 | ADDON_ACTION_DECREASE_RATING = 137, | ||
| 433 | |||
| 434 | /// @brief <b>`138`</b>: Switch to next scene/cutpoint in movie. | ||
| 435 | ADDON_ACTION_NEXT_SCENE = 138, | ||
| 436 | |||
| 437 | /// @brief <b>`139`</b>: Switch to previous scene/cutpoint in movie. | ||
| 438 | ADDON_ACTION_PREV_SCENE = 139, | ||
| 439 | |||
| 440 | /// @brief <b>`140`</b>: Jump through a list or container to next letter. | ||
| 441 | ADDON_ACTION_NEXT_LETTER = 140, | ||
| 442 | |||
| 443 | /// @brief <b>`141`</b>: Jump through a list or container to previous letter. | ||
| 444 | ADDON_ACTION_PREV_LETTER = 141, | ||
| 445 | |||
| 446 | /// @brief <b>`142`</b>: Jump direct to a particular letter using SMS-style input | ||
| 447 | /// | ||
| 448 | /// Jump to SMS2. | ||
| 449 | ADDON_ACTION_JUMP_SMS2 = 142, | ||
| 450 | |||
| 451 | /// @brief <b>`143`</b>: Jump to SMS3. | ||
| 452 | ADDON_ACTION_JUMP_SMS3 = 143, | ||
| 453 | |||
| 454 | /// @brief <b>`144`</b>: Jump to SMS4. | ||
| 455 | ADDON_ACTION_JUMP_SMS4 = 144, | ||
| 456 | |||
| 457 | /// @brief <b>`145`</b>: Jump to SMS5. | ||
| 458 | ADDON_ACTION_JUMP_SMS5 = 145, | ||
| 459 | |||
| 460 | /// @brief <b>`146`</b>: Jump to SMS6. | ||
| 461 | ADDON_ACTION_JUMP_SMS6 = 146, | ||
| 462 | |||
| 463 | /// @brief <b>`147`</b>: Jump to SMS7. | ||
| 464 | ADDON_ACTION_JUMP_SMS7 = 147, | ||
| 465 | |||
| 466 | /// @brief <b>`148`</b>: Jump to SMS8. | ||
| 467 | ADDON_ACTION_JUMP_SMS8 = 148, | ||
| 468 | |||
| 469 | /// @brief <b>`149`</b>: Jump to SMS9. | ||
| 470 | ADDON_ACTION_JUMP_SMS9 = 149, | ||
| 471 | |||
| 472 | /// @brief <b>`150`</b>: Filter clear. | ||
| 473 | ADDON_ACTION_FILTER_CLEAR = 150, | ||
| 474 | |||
| 475 | /// @brief <b>`151`</b>: Filter SMS2. | ||
| 476 | ADDON_ACTION_FILTER_SMS2 = 151, | ||
| 477 | |||
| 478 | /// @brief <b>`152`</b>: Filter SMS3. | ||
| 479 | ADDON_ACTION_FILTER_SMS3 = 152, | ||
| 480 | |||
| 481 | /// @brief <b>`153`</b>: Filter SMS4. | ||
| 482 | ADDON_ACTION_FILTER_SMS4 = 153, | ||
| 483 | |||
| 484 | /// @brief <b>`154`</b>: Filter SMS5. | ||
| 485 | ADDON_ACTION_FILTER_SMS5 = 154, | ||
| 486 | |||
| 487 | /// @brief <b>`155`</b>: Filter SMS6. | ||
| 488 | ADDON_ACTION_FILTER_SMS6 = 155, | ||
| 489 | |||
| 490 | /// @brief <b>`156`</b>: Filter SMS7. | ||
| 491 | ADDON_ACTION_FILTER_SMS7 = 156, | ||
| 492 | |||
| 493 | /// @brief <b>`157`</b>: Filter SMS8. | ||
| 494 | ADDON_ACTION_FILTER_SMS8 = 157, | ||
| 495 | |||
| 496 | /// @brief <b>`158`</b>: Filter SMS9. | ||
| 497 | ADDON_ACTION_FILTER_SMS9 = 158, | ||
| 498 | |||
| 499 | /// @brief <b>`159`</b>: First page. | ||
| 500 | ADDON_ACTION_FIRST_PAGE = 159, | ||
| 501 | |||
| 502 | /// @brief <b>`160`</b>: Last page. | ||
| 503 | ADDON_ACTION_LAST_PAGE = 160, | ||
| 504 | |||
| 505 | /// @brief <b>`161`</b>: Audio delay. | ||
| 506 | ADDON_ACTION_AUDIO_DELAY = 161, | ||
| 507 | |||
| 508 | /// @brief <b>`162`</b>: Subtitle delay. | ||
| 509 | ADDON_ACTION_SUBTITLE_DELAY = 162, | ||
| 510 | |||
| 511 | /// @brief <b>`163`</b>: Menu. | ||
| 512 | ADDON_ACTION_MENU = 163, | ||
| 513 | |||
| 514 | /// @brief <b>`164`</b>: Set rating. | ||
| 515 | ADDON_ACTION_SET_RATING = 164, | ||
| 516 | |||
| 517 | /// @brief <b>`170`</b>: Record. | ||
| 518 | ADDON_ACTION_RECORD = 170, | ||
| 519 | |||
| 520 | /// @brief <b>`180`</b>: Paste. | ||
| 521 | ADDON_ACTION_PASTE = 180, | ||
| 522 | |||
| 523 | /// @brief <b>`181`</b>: Next control. | ||
| 524 | ADDON_ACTION_NEXT_CONTROL = 181, | ||
| 525 | |||
| 526 | /// @brief <b>`182`</b>: Previous control. | ||
| 527 | ADDON_ACTION_PREV_CONTROL = 182, | ||
| 528 | |||
| 529 | /// @brief <b>`183`</b>: Channel switch. | ||
| 530 | ADDON_ACTION_CHANNEL_SWITCH = 183, | ||
| 531 | |||
| 532 | /// @brief <b>`184`</b>: Channel up. | ||
| 533 | ADDON_ACTION_CHANNEL_UP = 184, | ||
| 534 | |||
| 535 | /// @brief <b>`185`</b>: Channel down. | ||
| 536 | ADDON_ACTION_CHANNEL_DOWN = 185, | ||
| 537 | |||
| 538 | /// @brief <b>`186`</b>: Next channel group. | ||
| 539 | ADDON_ACTION_NEXT_CHANNELGROUP = 186, | ||
| 540 | |||
| 541 | /// @brief <b>`187`</b>: Previous channel group. | ||
| 542 | ADDON_ACTION_PREVIOUS_CHANNELGROUP = 187, | ||
| 543 | |||
| 544 | /// @brief <b>`188`</b>: PVR play. | ||
| 545 | ADDON_ACTION_PVR_PLAY = 188, | ||
| 546 | |||
| 547 | /// @brief <b>`189`</b>: PVR play TV. | ||
| 548 | ADDON_ACTION_PVR_PLAY_TV = 189, | ||
| 549 | |||
| 550 | /// @brief <b>`190`</b>: PVR play radio. | ||
| 551 | ADDON_ACTION_PVR_PLAY_RADIO = 190, | ||
| 552 | |||
| 553 | /// @brief <b>`191`</b>: PVR show timer rule. | ||
| 554 | ADDON_ACTION_PVR_SHOW_TIMER_RULE = 191, | ||
| 555 | |||
| 556 | /// @brief <b>`192`</b>: Channel number sep | ||
| 557 | ADDON_ACTION_CHANNEL_NUMBER_SEP = 192, | ||
| 558 | |||
| 559 | /// @brief <b>`193`</b>: PVR announce reminders | ||
| 560 | ADDON_ACTION_PVR_ANNOUNCE_REMINDERS = 193, | ||
| 561 | |||
| 562 | /// @brief <b>`199`</b>: Switch 2 desktop resolution | ||
| 563 | ADDON_ACTION_TOGGLE_FULLSCREEN = 199, | ||
| 564 | |||
| 565 | /// @brief <b>`200`</b>: Toggle watched status (videos) | ||
| 566 | ADDON_ACTION_TOGGLE_WATCHED = 200, | ||
| 567 | |||
| 568 | /// @brief <b>`201`</b>: Scan item | ||
| 569 | ADDON_ACTION_SCAN_ITEM = 201, | ||
| 570 | |||
| 571 | /// @brief <b>`202`</b>: Switch digital <-> analog | ||
| 572 | ADDON_ACTION_TOGGLE_DIGITAL_ANALOG = 202, | ||
| 573 | |||
| 574 | /// @brief <b>`203`</b>: Reloads CButtonTranslator's keymaps | ||
| 575 | ADDON_ACTION_RELOAD_KEYMAPS = 203, | ||
| 576 | |||
| 577 | /// @brief <b>`204`</b>: Start the GUIControlProfiler running | ||
| 578 | ADDON_ACTION_GUIPROFILE_BEGIN = 204, | ||
| 579 | |||
| 580 | /// @brief <b>`215`</b>: Teletext Color button <b>Red</b> to control TopText | ||
| 581 | ADDON_ACTION_TELETEXT_RED = 215, | ||
| 582 | |||
| 583 | /// @brief <b>`216`</b>: Teletext Color button <b>Green</b> to control TopText | ||
| 584 | ADDON_ACTION_TELETEXT_GREEN = 216, | ||
| 585 | |||
| 586 | /// @brief <b>`217`</b>: Teletext Color button <b>Yellow</b> to control TopText | ||
| 587 | ADDON_ACTION_TELETEXT_YELLOW = 217, | ||
| 588 | |||
| 589 | /// @brief <b>`218`</b>: Teletext Color button <b>Blue</b> to control TopText | ||
| 590 | ADDON_ACTION_TELETEXT_BLUE = 218, | ||
| 591 | |||
| 592 | /// @brief <b>`219`</b>: Increase par. | ||
| 593 | ADDON_ACTION_INCREASE_PAR = 219, | ||
| 594 | |||
| 595 | /// @brief <b>`220`</b>: Decrease par. | ||
| 596 | ADDON_ACTION_DECREASE_PAR = 220, | ||
| 597 | |||
| 598 | /// @brief <b>`227`</b>: Shift up video image in VideoPlayer | ||
| 599 | ADDON_ACTION_VSHIFT_UP = 227, | ||
| 600 | |||
| 601 | /// @brief <b>`228`</b>: Shift down video image in VideoPlayer | ||
| 602 | ADDON_ACTION_VSHIFT_DOWN = 228, | ||
| 603 | |||
| 604 | /// @brief <b>`229`</b>: Play/pause. If playing it pauses, if paused it plays. | ||
| 605 | ADDON_ACTION_PLAYER_PLAYPAUSE = 229, | ||
| 606 | |||
| 607 | /// @brief <b>`230`</b>: Shift up subtitles in VideoPlayer | ||
| 608 | ADDON_ACTION_SUBTITLE_VSHIFT_UP = 230, | ||
| 609 | |||
| 610 | /// @brief <b>`231`</b>: Shift down subtitles in VideoPlayer | ||
| 611 | ADDON_ACTION_SUBTITLE_VSHIFT_DOWN = 231, | ||
| 612 | |||
| 613 | /// @brief <b>`232`</b>: Toggle vertical alignment of subtitles | ||
| 614 | ADDON_ACTION_SUBTITLE_ALIGN = 232, | ||
| 615 | |||
| 616 | /// @brief <b>`233`</b>: Filter. | ||
| 617 | ADDON_ACTION_FILTER = 233, | ||
| 618 | |||
| 619 | /// @brief <b>`234`</b>: Switch player. | ||
| 620 | ADDON_ACTION_SWITCH_PLAYER = 234, | ||
| 621 | |||
| 622 | /// @brief <b>`235`</b>: Stereo mode next. | ||
| 623 | ADDON_ACTION_STEREOMODE_NEXT = 235, | ||
| 624 | |||
| 625 | /// @brief <b>`236`</b>: Stereo mode previous. | ||
| 626 | ADDON_ACTION_STEREOMODE_PREVIOUS = 236, | ||
| 627 | |||
| 628 | /// @brief <b>`237`</b>: Turns 3d mode on/off. | ||
| 629 | ADDON_ACTION_STEREOMODE_TOGGLE = 237, | ||
| 630 | |||
| 631 | /// @brief <b>`238`</b>: Stereo mode select. | ||
| 632 | ADDON_ACTION_STEREOMODE_SELECT = 238, | ||
| 633 | |||
| 634 | /// @brief <b>`239`</b>: Stereo mode to mono. | ||
| 635 | ADDON_ACTION_STEREOMODE_TOMONO = 239, | ||
| 636 | |||
| 637 | /// @brief <b>`240`</b>: Stereo mode set. | ||
| 638 | ADDON_ACTION_STEREOMODE_SET = 240, | ||
| 639 | |||
| 640 | /// @brief <b>`241`</b>: Settings reset. | ||
| 641 | ADDON_ACTION_SETTINGS_RESET = 241, | ||
| 642 | |||
| 643 | /// @brief <b>`242`</b>: Settings level change. | ||
| 644 | ADDON_ACTION_SETTINGS_LEVEL_CHANGE = 242, | ||
| 645 | |||
| 646 | /// @brief <b>`243`</b>: Show autoclosing OSD. Can b used in videoFullScreen.xml window id=2005 | ||
| 647 | ADDON_ACTION_TRIGGER_OSD = 243, | ||
| 648 | |||
| 649 | /// @brief <b>`244`</b>: Input text. | ||
| 650 | ADDON_ACTION_INPUT_TEXT = 244, | ||
| 651 | |||
| 652 | /// @brief <b>`245`</b>: Volume set. | ||
| 653 | ADDON_ACTION_VOLUME_SET = 245, | ||
| 654 | |||
| 655 | /// @brief <b>`246`</b>: Toggle commercial skip. | ||
| 656 | ADDON_ACTION_TOGGLE_COMMSKIP = 246, | ||
| 657 | |||
| 658 | /// @brief <b>`247`</b>: Browse for subtitle. Can be used in videofullscreen | ||
| 659 | ADDON_ACTION_BROWSE_SUBTITLE = 247, | ||
| 660 | |||
| 661 | /// @brief <b>`248`</b>: Send a reset command to the active game | ||
| 662 | ADDON_ACTION_PLAYER_RESET = 248, | ||
| 663 | |||
| 664 | /// @brief <b>`249`</b>: Toggle font. Used in TextViewer dialog | ||
| 665 | ADDON_ACTION_TOGGLE_FONT = 249, | ||
| 666 | |||
| 667 | /// @brief <b>`250`</b>: Cycle video streams. Used in videofullscreen. | ||
| 668 | ADDON_ACTION_VIDEO_NEXT_STREAM = 250, | ||
| 669 | |||
| 670 | /// @brief <b>`251`</b>: Used to queue an item to the next position in the playlist | ||
| 671 | ADDON_ACTION_QUEUE_ITEM_NEXT = 251, | ||
| 672 | |||
| 673 | /// @brief <b>`247`</b>: Toggle display HDR on/off | ||
| 674 | ADDON_ACTION_HDR_TOGGLE = 260, | ||
| 675 | |||
| 676 | /// @brief <b>`300`</b>: Voice actions | ||
| 677 | ADDON_ACTION_VOICE_RECOGNIZE = 300, | ||
| 678 | |||
| 679 | // Number 347 used om front by ADDON_ACTION_BROWSE_SUBTITLE | ||
| 680 | |||
| 681 | /// @brief <b>`401`</b>: Touch actions | ||
| 682 | ADDON_ACTION_TOUCH_TAP = 401, | ||
| 683 | |||
| 684 | /// @brief <b>`410`</b>: Touch actions | ||
| 685 | ADDON_ACTION_TOUCH_TAP_TEN = 410, | ||
| 686 | |||
| 687 | /// @brief <b>`411`</b>: Touch actions | ||
| 688 | ADDON_ACTION_TOUCH_LONGPRESS = 411, | ||
| 689 | |||
| 690 | /// @brief <b>`412`</b>: Touch actions | ||
| 691 | ADDON_ACTION_TOUCH_LONGPRESS_TEN = 420, | ||
| 692 | |||
| 693 | /// @brief <b>`500`</b>: Gesture notify. | ||
| 694 | ADDON_ACTION_GESTURE_NOTIFY = 500, | ||
| 695 | |||
| 696 | /// @brief <b>`501`</b>: Gesture begin. | ||
| 697 | ADDON_ACTION_GESTURE_BEGIN = 501, | ||
| 698 | |||
| 699 | /// @brief <b>`502`</b>: Send action with point and currentPinchScale (fingers together < 1.0 -> fingers apart > 1.0) | ||
| 700 | ADDON_ACTION_GESTURE_ZOOM = 502, | ||
| 701 | |||
| 702 | /// @brief <b>`503`</b>: Gesture rotate. | ||
| 703 | ADDON_ACTION_GESTURE_ROTATE = 503, | ||
| 704 | |||
| 705 | /// @brief <b>`504`</b>: Gesture pan. | ||
| 706 | ADDON_ACTION_GESTURE_PAN = 504, | ||
| 707 | |||
| 708 | /// @brief <b>`505`</b>: Gesture was interrupted in unspecified state | ||
| 709 | ADDON_ACTION_GESTURE_ABORT = 505, | ||
| 710 | |||
| 711 | /// @brief <b>`511`</b>: Gesture swipe left. | ||
| 712 | ADDON_ACTION_GESTURE_SWIPE_LEFT = 511, | ||
| 713 | |||
| 714 | /// @brief <b>`520`</b>: Gesture swipe left ten | ||
| 715 | ADDON_ACTION_GESTURE_SWIPE_LEFT_TEN = 520, | ||
| 716 | |||
| 717 | /// @brief <b>`521`</b>: Gesture swipe right | ||
| 718 | ADDON_ACTION_GESTURE_SWIPE_RIGHT = 521, | ||
| 719 | |||
| 720 | /// @brief <b>`530`</b>: Gesture swipe right ten | ||
| 721 | ADDON_ACTION_GESTURE_SWIPE_RIGHT_TEN = 530, | ||
| 722 | |||
| 723 | /// @brief <b>`531`</b>: Gesture swipe up | ||
| 724 | ADDON_ACTION_GESTURE_SWIPE_UP = 531, | ||
| 725 | |||
| 726 | /// @brief <b>`540`</b>: Gesture swipe up ten | ||
| 727 | ADDON_ACTION_GESTURE_SWIPE_UP_TEN = 540, | ||
| 728 | |||
| 729 | /// @brief <b>`541`</b>: Gesture swipe down. | ||
| 730 | ADDON_ACTION_GESTURE_SWIPE_DOWN = 541, | ||
| 731 | |||
| 732 | /// @brief <b>`550`</b>: Gesture swipe down ten. | ||
| 733 | ADDON_ACTION_GESTURE_SWIPE_DOWN_TEN = 550, | ||
| 734 | |||
| 735 | /// @brief <b>`599`</b>: 5xx is reserved for additional gesture actions | ||
| 736 | ADDON_ACTION_GESTURE_END = 599, | ||
| 737 | |||
| 738 | // other, non-gesture actions | ||
| 739 | |||
| 740 | /// @brief <b>`601`</b>: Analog thumbstick move, horizontal axis, left; see ADDON_ACTION_ANALOG_MOVE | ||
| 741 | ADDON_ACTION_ANALOG_MOVE_X_LEFT = 601, | ||
| 742 | |||
| 743 | /// @brief <b>`602`</b>: Analog thumbstick move, horizontal axis, right; see ADDON_ACTION_ANALOG_MOVE | ||
| 744 | ADDON_ACTION_ANALOG_MOVE_X_RIGHT = 602, | ||
| 745 | |||
| 746 | /// @brief <b>`603`</b>: Analog thumbstick move, vertical axis, up; see ADDON_ACTION_ANALOG_MOVE | ||
| 747 | ADDON_ACTION_ANALOG_MOVE_Y_UP = 603, | ||
| 748 | |||
| 749 | /// @brief <b>`604`</b>: Analog thumbstick move, vertical axis, down; see ADDON_ACTION_ANALOG_MOVE | ||
| 750 | ADDON_ACTION_ANALOG_MOVE_Y_DOWN = 604, | ||
| 751 | |||
| 752 | /// @brief <b>`998`</b>: ERROR action is used to play an error sound. | ||
| 753 | ADDON_ACTION_ERROR = 998, | ||
| 754 | |||
| 755 | /// @brief <b>`999`</b>: The NOOP action can be specified to disable an input event. This is | ||
| 756 | /// useful in user keyboard.xml etc to disable actions specified in the | ||
| 757 | /// system mappings. | ||
| 758 | ADDON_ACTION_NOOP = 999 | ||
| 759 | ///@} | ||
| 760 | }; | ||
| 761 | ///@} | ||
| 762 | |||
| 763 | #endif /* !C_API_GUI_ACTION_IDS_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/list_item.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/list_item.h new file mode 100644 index 0000000..f0c4dc7 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/list_item.h | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_LIST_ITEM_H | ||
| 12 | #define C_API_GUI_LIST_ITEM_H | ||
| 13 | |||
| 14 | #include "definitions.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | typedef struct AddonToKodiFuncTable_kodi_gui_listItem | ||
| 22 | { | ||
| 23 | KODI_GUI_LISTITEM_HANDLE(*create) | ||
| 24 | (KODI_HANDLE kodiBase, | ||
| 25 | const char* label, | ||
| 26 | const char* label2, | ||
| 27 | const char* path); | ||
| 28 | void (*destroy)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle); | ||
| 29 | |||
| 30 | char* (*get_label)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle); | ||
| 31 | void (*set_label)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle, const char* label); | ||
| 32 | char* (*get_label2)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle); | ||
| 33 | void (*set_label2)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle, const char* label); | ||
| 34 | char* (*get_art)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle, const char* type); | ||
| 35 | void (*set_art)(KODI_HANDLE kodiBase, | ||
| 36 | KODI_GUI_LISTITEM_HANDLE handle, | ||
| 37 | const char* type, | ||
| 38 | const char* image); | ||
| 39 | char* (*get_path)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle); | ||
| 40 | void (*set_path)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle, const char* path); | ||
| 41 | char* (*get_property)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle, const char* key); | ||
| 42 | void (*set_property)(KODI_HANDLE kodiBase, | ||
| 43 | KODI_GUI_LISTITEM_HANDLE handle, | ||
| 44 | const char* key, | ||
| 45 | const char* value); | ||
| 46 | void (*select)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle, bool select); | ||
| 47 | bool (*is_selected)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle); | ||
| 48 | } AddonToKodiFuncTable_kodi_gui_listItem; | ||
| 49 | |||
| 50 | #ifdef __cplusplus | ||
| 51 | } /* extern "C" */ | ||
| 52 | #endif /* __cplusplus */ | ||
| 53 | |||
| 54 | #endif /* !C_API_GUI_LIST_ITEM_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/window.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/window.h new file mode 100644 index 0000000..0f844f5 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/window.h | |||
| @@ -0,0 +1,183 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_GUI_WINDOW_H | ||
| 12 | #define C_API_GUI_WINDOW_H | ||
| 13 | |||
| 14 | #include "definitions.h" | ||
| 15 | #include "input/action_ids.h" | ||
| 16 | |||
| 17 | #include <stddef.h> | ||
| 18 | |||
| 19 | #define ADDON_MAX_CONTEXT_ENTRIES 20 | ||
| 20 | #define ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH 80 | ||
| 21 | |||
| 22 | #ifdef __cplusplus | ||
| 23 | extern "C" | ||
| 24 | { | ||
| 25 | #endif /* __cplusplus */ | ||
| 26 | |||
| 27 | typedef struct gui_context_menu_pair | ||
| 28 | { | ||
| 29 | unsigned int id; | ||
| 30 | char name[ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH]; | ||
| 31 | } gui_context_menu_pair; | ||
| 32 | |||
| 33 | typedef struct AddonToKodiFuncTable_kodi_gui_window | ||
| 34 | { | ||
| 35 | /* Window creation functions */ | ||
| 36 | KODI_GUI_WINDOW_HANDLE(*create) | ||
| 37 | (KODI_HANDLE kodiBase, | ||
| 38 | const char* xml_filename, | ||
| 39 | const char* default_skin, | ||
| 40 | bool as_dialog, | ||
| 41 | bool is_media); | ||
| 42 | void (*destroy)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle); | ||
| 43 | |||
| 44 | void (*set_callbacks)(KODI_HANDLE kodiBase, | ||
| 45 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 46 | KODI_GUI_CLIENT_HANDLE clienthandle, | ||
| 47 | bool (*CBInit)(KODI_GUI_CLIENT_HANDLE), | ||
| 48 | bool (*CBFocus)(KODI_GUI_CLIENT_HANDLE, int), | ||
| 49 | bool (*CBClick)(KODI_GUI_CLIENT_HANDLE, int), | ||
| 50 | bool (*CBOnAction)(KODI_GUI_CLIENT_HANDLE, enum ADDON_ACTION), | ||
| 51 | void (*CBGetContextButtons)( | ||
| 52 | KODI_GUI_CLIENT_HANDLE, int, gui_context_menu_pair*, unsigned int*), | ||
| 53 | bool (*CBOnContextButton)(KODI_GUI_CLIENT_HANDLE, int, unsigned int)); | ||
| 54 | bool (*show)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle); | ||
| 55 | bool (*close)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle); | ||
| 56 | bool (*do_modal)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle); | ||
| 57 | |||
| 58 | /* Window control functions */ | ||
| 59 | bool (*set_focus_id)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 60 | int (*get_focus_id)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle); | ||
| 61 | void (*set_control_label)(KODI_HANDLE kodiBase, | ||
| 62 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 63 | int control_id, | ||
| 64 | const char* label); | ||
| 65 | void (*set_control_visible)(KODI_HANDLE kodiBase, | ||
| 66 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 67 | int control_id, | ||
| 68 | bool visible); | ||
| 69 | void (*set_control_selected)(KODI_HANDLE kodiBase, | ||
| 70 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 71 | int control_id, | ||
| 72 | bool selected); | ||
| 73 | |||
| 74 | /* Window property functions */ | ||
| 75 | void (*set_property)(KODI_HANDLE kodiBase, | ||
| 76 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 77 | const char* key, | ||
| 78 | const char* value); | ||
| 79 | void (*set_property_int)(KODI_HANDLE kodiBase, | ||
| 80 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 81 | const char* key, | ||
| 82 | int value); | ||
| 83 | void (*set_property_bool)(KODI_HANDLE kodiBase, | ||
| 84 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 85 | const char* key, | ||
| 86 | bool value); | ||
| 87 | void (*set_property_double)(KODI_HANDLE kodiBase, | ||
| 88 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 89 | const char* key, | ||
| 90 | double value); | ||
| 91 | char* (*get_property)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, const char* key); | ||
| 92 | int (*get_property_int)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, const char* key); | ||
| 93 | bool (*get_property_bool)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, const char* key); | ||
| 94 | double (*get_property_double)(KODI_HANDLE kodiBase, | ||
| 95 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 96 | const char* key); | ||
| 97 | void (*clear_properties)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle); | ||
| 98 | void (*clear_property)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, const char* key); | ||
| 99 | |||
| 100 | /* List item functions */ | ||
| 101 | void (*clear_item_list)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle); | ||
| 102 | void (*add_list_item)(KODI_HANDLE kodiBase, | ||
| 103 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 104 | KODI_GUI_LISTITEM_HANDLE item, | ||
| 105 | int list_position); | ||
| 106 | void (*remove_list_item_from_position)(KODI_HANDLE kodiBase, | ||
| 107 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 108 | int list_position); | ||
| 109 | void (*remove_list_item)(KODI_HANDLE kodiBase, | ||
| 110 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 111 | KODI_GUI_LISTITEM_HANDLE item); | ||
| 112 | KODI_GUI_LISTITEM_HANDLE(*get_list_item) | ||
| 113 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int list_position); | ||
| 114 | void (*set_current_list_position)(KODI_HANDLE kodiBase, | ||
| 115 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 116 | int list_position); | ||
| 117 | int (*get_current_list_position)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle); | ||
| 118 | int (*get_list_size)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle); | ||
| 119 | void (*set_container_property)(KODI_HANDLE kodiBase, | ||
| 120 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 121 | const char* key, | ||
| 122 | const char* value); | ||
| 123 | void (*set_container_content)(KODI_HANDLE kodiBase, | ||
| 124 | KODI_GUI_WINDOW_HANDLE handle, | ||
| 125 | const char* value); | ||
| 126 | int (*get_current_container_id)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle); | ||
| 127 | |||
| 128 | /* Various functions */ | ||
| 129 | void (*mark_dirty_region)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle); | ||
| 130 | |||
| 131 | /* GUI control access functions */ | ||
| 132 | KODI_GUI_CONTROL_HANDLE(*get_control_button) | ||
| 133 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 134 | KODI_GUI_CONTROL_HANDLE(*get_control_edit) | ||
| 135 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 136 | KODI_GUI_CONTROL_HANDLE(*get_control_fade_label) | ||
| 137 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 138 | KODI_GUI_CONTROL_HANDLE(*get_control_image) | ||
| 139 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 140 | KODI_GUI_CONTROL_HANDLE(*get_control_label) | ||
| 141 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 142 | KODI_GUI_CONTROL_HANDLE(*get_control_progress) | ||
| 143 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 144 | KODI_GUI_CONTROL_HANDLE(*get_control_radio_button) | ||
| 145 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 146 | KODI_GUI_CONTROL_HANDLE(*get_control_render_addon) | ||
| 147 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 148 | KODI_GUI_CONTROL_HANDLE(*get_control_settings_slider) | ||
| 149 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 150 | KODI_GUI_CONTROL_HANDLE(*get_control_slider) | ||
| 151 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 152 | KODI_GUI_CONTROL_HANDLE(*get_control_spin) | ||
| 153 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 154 | KODI_GUI_CONTROL_HANDLE(*get_control_text_box) | ||
| 155 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 156 | KODI_GUI_CONTROL_HANDLE(*get_control_dummy1) | ||
| 157 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 158 | KODI_GUI_CONTROL_HANDLE(*get_control_dummy2) | ||
| 159 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 160 | KODI_GUI_CONTROL_HANDLE(*get_control_dummy3) | ||
| 161 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 162 | KODI_GUI_CONTROL_HANDLE(*get_control_dummy4) | ||
| 163 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 164 | KODI_GUI_CONTROL_HANDLE(*get_control_dummy5) | ||
| 165 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 166 | KODI_GUI_CONTROL_HANDLE(*get_control_dummy6) | ||
| 167 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 168 | KODI_GUI_CONTROL_HANDLE(*get_control_dummy7) | ||
| 169 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 170 | KODI_GUI_CONTROL_HANDLE(*get_control_dummy8) | ||
| 171 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 172 | KODI_GUI_CONTROL_HANDLE(*get_control_dummy9) | ||
| 173 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 174 | KODI_GUI_CONTROL_HANDLE(*get_control_dummy10) | ||
| 175 | (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id); | ||
| 176 | /* This above used to add new get_control_* functions */ | ||
| 177 | } AddonToKodiFuncTable_kodi_gui_window; | ||
| 178 | |||
| 179 | #ifdef __cplusplus | ||
| 180 | } /* extern "C" */ | ||
| 181 | #endif /* __cplusplus */ | ||
| 182 | |||
| 183 | #endif /* !C_API_GUI_WINDOW_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/network.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/network.h index 6c0441f..88d5231 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/network.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/network.h | |||
| @@ -8,7 +8,10 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include <stddef.h> | 11 | #ifndef C_API_NETWORK_H |
| 12 | #define C_API_NETWORK_H | ||
| 13 | |||
| 14 | #include <stdbool.h> | ||
| 12 | 15 | ||
| 13 | #ifdef __cplusplus | 16 | #ifdef __cplusplus |
| 14 | extern "C" | 17 | extern "C" |
| @@ -41,3 +44,5 @@ extern "C" | |||
| 41 | #ifdef __cplusplus | 44 | #ifdef __cplusplus |
| 42 | } /* extern "C" */ | 45 | } /* extern "C" */ |
| 43 | #endif /* __cplusplus */ | 46 | #endif /* __cplusplus */ |
| 47 | |||
| 48 | #endif /* C_API_NETWORK_H */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/platform/android/system.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/platform/android/system.h new file mode 100644 index 0000000..568a2fd --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/platform/android/system.h | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifndef C_API_PLATFORM_ANDROID_H | ||
| 12 | #define C_API_PLATFORM_ANDROID_H | ||
| 13 | |||
| 14 | #define INTERFACE_ANDROID_SYSTEM_NAME "ANDROID_SYSTEM" | ||
| 15 | #define INTERFACE_ANDROID_SYSTEM_VERSION "1.0.2" | ||
| 16 | #define INTERFACE_ANDROID_SYSTEM_VERSION_MIN "1.0.1" | ||
| 17 | |||
| 18 | #ifdef __cplusplus | ||
| 19 | extern "C" | ||
| 20 | { | ||
| 21 | #endif /* __cplusplus */ | ||
| 22 | |||
| 23 | struct AddonToKodiFuncTable_android_system | ||
| 24 | { | ||
| 25 | void* (*get_jni_env)(); | ||
| 26 | int (*get_sdk_version)(); | ||
| 27 | const char *(*get_class_name)(); | ||
| 28 | }; | ||
| 29 | |||
| 30 | #ifdef __cplusplus | ||
| 31 | } | ||
| 32 | #endif /* __cplusplus */ | ||
| 33 | |||
| 34 | #endif /* !C_API_PLATFORM_ANDROID_H */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/gui/CMakeLists.txt index 834ec00..8f12955 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/CMakeLists.txt +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/CMakeLists.txt | |||
| @@ -1,9 +1,8 @@ | |||
| 1 | set(HEADERS General.h | 1 | set(HEADERS General.h |
| 2 | ListItem.h | 2 | ListItem.h |
| 3 | Window.h | 3 | Window.h |
| 4 | definitions.h | ||
| 5 | renderHelper.h) | 4 | renderHelper.h) |
| 6 | 5 | ||
| 7 | if(NOT ENABLE_STATIC_LIBS) | 6 | if(NOT ENABLE_STATIC_LIBS) |
| 8 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_gui) | 7 | core_add_library(addons_kodi-dev-kit_include_kodi_gui) |
| 9 | endif() | 8 | endif() |
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/General.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/General.h new file mode 100644 index 0000000..85ba3f2 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/General.h | |||
| @@ -0,0 +1,176 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | #include "../c-api/gui/general.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================== | ||
| 22 | /// @addtogroup cpp_kodi_gui_general | ||
| 23 | /// Permits the use of the required functions of the add-on to Kodi. | ||
| 24 | /// | ||
| 25 | /// These are pure functions them no other initialization need. | ||
| 26 | /// | ||
| 27 | /// It has the header @ref kodi/gui/General.h "#include <kodi/gui/General.h>" be included | ||
| 28 | /// to enjoy it. | ||
| 29 | /// | ||
| 30 | |||
| 31 | //============================================================================== | ||
| 32 | /// @ingroup cpp_kodi_gui_general | ||
| 33 | /// @brief Performs a graphical lock of rendering engine. | ||
| 34 | /// | ||
| 35 | inline void ATTRIBUTE_HIDDEN Lock() | ||
| 36 | { | ||
| 37 | using namespace ::kodi::addon; | ||
| 38 | CAddonBase::m_interface->toKodi->kodi_gui->general->lock(); | ||
| 39 | } | ||
| 40 | //------------------------------------------------------------------------------ | ||
| 41 | |||
| 42 | //============================================================================== | ||
| 43 | /// @ingroup cpp_kodi_gui_general | ||
| 44 | /// @brief Performs a graphical unlock of previous locked rendering engine. | ||
| 45 | /// | ||
| 46 | inline void ATTRIBUTE_HIDDEN Unlock() | ||
| 47 | { | ||
| 48 | using namespace ::kodi::addon; | ||
| 49 | CAddonBase::m_interface->toKodi->kodi_gui->general->unlock(); | ||
| 50 | } | ||
| 51 | //------------------------------------------------------------------------------ | ||
| 52 | |||
| 53 | //============================================================================== | ||
| 54 | /// @ingroup cpp_kodi_gui_general | ||
| 55 | /// @brief Return the the current screen height with pixel. | ||
| 56 | /// | ||
| 57 | /// @return Screen height with pixel | ||
| 58 | /// | ||
| 59 | inline int ATTRIBUTE_HIDDEN GetScreenHeight() | ||
| 60 | { | ||
| 61 | using namespace ::kodi::addon; | ||
| 62 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_height( | ||
| 63 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 64 | } | ||
| 65 | //------------------------------------------------------------------------------ | ||
| 66 | |||
| 67 | //============================================================================== | ||
| 68 | /// @ingroup cpp_kodi_gui_general | ||
| 69 | /// @brief Return the the current screen width with pixel. | ||
| 70 | /// | ||
| 71 | /// @return Screen width with pixel | ||
| 72 | /// | ||
| 73 | inline int ATTRIBUTE_HIDDEN GetScreenWidth() | ||
| 74 | { | ||
| 75 | using namespace ::kodi::addon; | ||
| 76 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_width( | ||
| 77 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 78 | } | ||
| 79 | //------------------------------------------------------------------------------ | ||
| 80 | |||
| 81 | //============================================================================== | ||
| 82 | /// @ingroup cpp_kodi_gui_general | ||
| 83 | /// @brief Return the the current screen rendering resolution. | ||
| 84 | /// | ||
| 85 | /// @return Current screen rendering resolution | ||
| 86 | /// | ||
| 87 | inline int ATTRIBUTE_HIDDEN GetVideoResolution() | ||
| 88 | { | ||
| 89 | using namespace ::kodi::addon; | ||
| 90 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_video_resolution( | ||
| 91 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 92 | } | ||
| 93 | //------------------------------------------------------------------------------ | ||
| 94 | |||
| 95 | //============================================================================== | ||
| 96 | /// @ingroup cpp_kodi_gui_general | ||
| 97 | /// @brief Returns the id for the current 'active' dialog as an integer. | ||
| 98 | /// | ||
| 99 | /// @return The currently active dialog Id | ||
| 100 | /// | ||
| 101 | /// | ||
| 102 | ///------------------------------------------------------------------------- | ||
| 103 | /// | ||
| 104 | /// **Example:** | ||
| 105 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 106 | /// .. | ||
| 107 | /// int wid = kodi::gui::GetCurrentWindowDialogId(); | ||
| 108 | /// .. | ||
| 109 | /// ~~~~~~~~~~~~~ | ||
| 110 | /// | ||
| 111 | inline int ATTRIBUTE_HIDDEN GetCurrentWindowDialogId() | ||
| 112 | { | ||
| 113 | using namespace ::kodi::addon; | ||
| 114 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_dialog_id( | ||
| 115 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 116 | } | ||
| 117 | //------------------------------------------------------------------------------ | ||
| 118 | |||
| 119 | //============================================================================== | ||
| 120 | /// @ingroup cpp_kodi_gui_general | ||
| 121 | /// @brief Returns the id for the current 'active' window as an integer. | ||
| 122 | /// | ||
| 123 | /// @return The currently active window Id | ||
| 124 | /// | ||
| 125 | /// | ||
| 126 | ///------------------------------------------------------------------------- | ||
| 127 | /// | ||
| 128 | /// **Example:** | ||
| 129 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 130 | /// .. | ||
| 131 | /// int wid = kodi::gui::GetCurrentWindowId(); | ||
| 132 | /// .. | ||
| 133 | /// ~~~~~~~~~~~~~ | ||
| 134 | /// | ||
| 135 | inline int ATTRIBUTE_HIDDEN GetCurrentWindowId() | ||
| 136 | { | ||
| 137 | using namespace ::kodi::addon; | ||
| 138 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_id( | ||
| 139 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 140 | } | ||
| 141 | //------------------------------------------------------------------------------ | ||
| 142 | |||
| 143 | //============================================================================== | ||
| 144 | /// @ingroup cpp_kodi_gui_general | ||
| 145 | /// @brief To get hardware specific device context interface. | ||
| 146 | /// | ||
| 147 | /// @return A pointer to the used device with @ref cpp_kodi_Defs_HardwareContext "kodi::HardwareContext" | ||
| 148 | /// | ||
| 149 | /// @warning This function is only be supported under Windows, on all other | ||
| 150 | /// OS it return `nullptr`! | ||
| 151 | /// | ||
| 152 | /// @note Returned Windows class pointer is `ID3D11DeviceContext1`. | ||
| 153 | /// | ||
| 154 | /// | ||
| 155 | ///------------------------------------------------------------------------- | ||
| 156 | /// | ||
| 157 | /// **Example:** | ||
| 158 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 159 | /// #include <d3d11_1.h> | ||
| 160 | /// .. | ||
| 161 | /// ID3D11DeviceContext1* context = static_cast<ID3D11DeviceContext1*>(kodi::gui::GetHWContext()); | ||
| 162 | /// .. | ||
| 163 | /// ~~~~~~~~~~~~~ | ||
| 164 | /// | ||
| 165 | inline kodi::HardwareContext GetHWContext() | ||
| 166 | { | ||
| 167 | using namespace ::kodi::addon; | ||
| 168 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_hw_context( | ||
| 169 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 170 | } | ||
| 171 | //------------------------------------------------------------------------------ | ||
| 172 | |||
| 173 | } /* namespace gui */ | ||
| 174 | } /* namespace kodi */ | ||
| 175 | |||
| 176 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/ListItem.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/ListItem.h new file mode 100644 index 0000000..3a4d50b --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/ListItem.h | |||
| @@ -0,0 +1,345 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | #include "../c-api/gui/list_item.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | #include <memory> | ||
| 17 | |||
| 18 | namespace kodi | ||
| 19 | { | ||
| 20 | namespace gui | ||
| 21 | { | ||
| 22 | |||
| 23 | class CWindow; | ||
| 24 | |||
| 25 | class ATTRIBUTE_HIDDEN CAddonGUIControlBase | ||
| 26 | { | ||
| 27 | public: | ||
| 28 | KODI_GUI_LISTITEM_HANDLE GetControlHandle() const { return m_controlHandle; } | ||
| 29 | |||
| 30 | protected: | ||
| 31 | explicit CAddonGUIControlBase(CAddonGUIControlBase* window) | ||
| 32 | : m_controlHandle(nullptr), | ||
| 33 | m_interface(::kodi::addon::CAddonBase::m_interface->toKodi), | ||
| 34 | m_Window(window) | ||
| 35 | { | ||
| 36 | } | ||
| 37 | |||
| 38 | virtual ~CAddonGUIControlBase() = default; | ||
| 39 | |||
| 40 | friend class CWindow; | ||
| 41 | |||
| 42 | KODI_GUI_LISTITEM_HANDLE m_controlHandle; | ||
| 43 | AddonToKodiFuncTable_Addon* m_interface; | ||
| 44 | CAddonGUIControlBase* m_Window; | ||
| 45 | |||
| 46 | private: | ||
| 47 | CAddonGUIControlBase() = delete; | ||
| 48 | CAddonGUIControlBase(const CAddonGUIControlBase&) = delete; | ||
| 49 | CAddonGUIControlBase& operator=(const CAddonGUIControlBase&) = delete; | ||
| 50 | }; | ||
| 51 | |||
| 52 | class CListItem; | ||
| 53 | |||
| 54 | //============================================================================== | ||
| 55 | /// @addtogroup cpp_kodi_gui_windows_listitem | ||
| 56 | /// @brief @cpp_class{ kodi::gui::CListItem } | ||
| 57 | /// **Selectable window list item**\n | ||
| 58 | /// The list item control is used for creating item lists in Kodi. | ||
| 59 | /// | ||
| 60 | /// The with @ref ListItem.h "#include <kodi/gui/ListItem.h>" given | ||
| 61 | /// class is used to create a item entry for a list on window and to support it's | ||
| 62 | /// control. | ||
| 63 | /// | ||
| 64 | class ATTRIBUTE_HIDDEN CListItem : public CAddonGUIControlBase | ||
| 65 | { | ||
| 66 | public: | ||
| 67 | //============================================================================ | ||
| 68 | /// @ingroup cpp_kodi_gui_windows_listitem | ||
| 69 | /// @brief Class constructor with parameters. | ||
| 70 | /// | ||
| 71 | /// @param[in] label [opt] Item label | ||
| 72 | /// @param[in] label2 [opt] Second Item label (if needed) | ||
| 73 | /// @param[in] path [opt] Path to where item is defined | ||
| 74 | /// | ||
| 75 | CListItem(const std::string& label = "", | ||
| 76 | const std::string& label2 = "", | ||
| 77 | const std::string& path = "") | ||
| 78 | : CAddonGUIControlBase(nullptr) | ||
| 79 | { | ||
| 80 | m_controlHandle = m_interface->kodi_gui->listItem->create(m_interface->kodiBase, label.c_str(), | ||
| 81 | label2.c_str(), path.c_str()); | ||
| 82 | } | ||
| 83 | |||
| 84 | /* | ||
| 85 | * Constructor used for parts given by list items from addon window | ||
| 86 | * | ||
| 87 | * Related to call of "std::shared_ptr<CListItem> kodi::gui::CWindow::GetListItem(int listPos)" | ||
| 88 | * Not needed for addon development itself | ||
| 89 | */ | ||
| 90 | explicit CListItem(KODI_GUI_LISTITEM_HANDLE listItemHandle) : CAddonGUIControlBase(nullptr) | ||
| 91 | { | ||
| 92 | m_controlHandle = listItemHandle; | ||
| 93 | } | ||
| 94 | |||
| 95 | //============================================================================ | ||
| 96 | /// @ingroup cpp_kodi_gui_windows_listitem | ||
| 97 | /// @brief Class destructor | ||
| 98 | /// | ||
| 99 | ~CListItem() override | ||
| 100 | { | ||
| 101 | m_interface->kodi_gui->listItem->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 102 | } | ||
| 103 | //---------------------------------------------------------------------------- | ||
| 104 | |||
| 105 | //============================================================================ | ||
| 106 | /// @ingroup cpp_kodi_gui_windows_listitem | ||
| 107 | /// @brief Returns the listitem label. | ||
| 108 | /// | ||
| 109 | /// @return Label of item | ||
| 110 | /// | ||
| 111 | std::string GetLabel() | ||
| 112 | { | ||
| 113 | std::string label; | ||
| 114 | char* ret = m_interface->kodi_gui->listItem->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 115 | if (ret != nullptr) | ||
| 116 | { | ||
| 117 | if (std::strlen(ret)) | ||
| 118 | label = ret; | ||
| 119 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 120 | } | ||
| 121 | return label; | ||
| 122 | } | ||
| 123 | //---------------------------------------------------------------------------- | ||
| 124 | |||
| 125 | //============================================================================ | ||
| 126 | /// @ingroup cpp_kodi_gui_windows_listitem | ||
| 127 | /// @brief Sets the listitem label. | ||
| 128 | /// | ||
| 129 | /// @param[in] label string or unicode - text string. | ||
| 130 | /// | ||
| 131 | void SetLabel(const std::string& label) | ||
| 132 | { | ||
| 133 | m_interface->kodi_gui->listItem->set_label(m_interface->kodiBase, m_controlHandle, | ||
| 134 | label.c_str()); | ||
| 135 | } | ||
| 136 | //---------------------------------------------------------------------------- | ||
| 137 | |||
| 138 | //============================================================================ | ||
| 139 | /// @ingroup cpp_kodi_gui_windows_listitem | ||
| 140 | /// @brief Returns the second listitem label. | ||
| 141 | /// | ||
| 142 | /// @return Second label of item | ||
| 143 | /// | ||
| 144 | std::string GetLabel2() | ||
| 145 | { | ||
| 146 | std::string label; | ||
| 147 | char* ret = m_interface->kodi_gui->listItem->get_label2(m_interface->kodiBase, m_controlHandle); | ||
| 148 | if (ret != nullptr) | ||
| 149 | { | ||
| 150 | if (std::strlen(ret)) | ||
| 151 | label = ret; | ||
| 152 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 153 | } | ||
| 154 | return label; | ||
| 155 | } | ||
| 156 | //---------------------------------------------------------------------------- | ||
| 157 | |||
| 158 | //============================================================================ | ||
| 159 | /// @ingroup cpp_kodi_gui_windows_listitem | ||
| 160 | /// @brief Sets the listitem's label2. | ||
| 161 | /// | ||
| 162 | /// @param[in] label string or unicode - text string. | ||
| 163 | /// | ||
| 164 | void SetLabel2(const std::string& label) | ||
| 165 | { | ||
| 166 | m_interface->kodi_gui->listItem->set_label2(m_interface->kodiBase, m_controlHandle, | ||
| 167 | label.c_str()); | ||
| 168 | } | ||
| 169 | //---------------------------------------------------------------------------- | ||
| 170 | |||
| 171 | //============================================================================ | ||
| 172 | /// @ingroup cpp_kodi_gui_windows_listitem | ||
| 173 | /// @brief Sets the listitem's art | ||
| 174 | /// | ||
| 175 | /// @param[in] type Type of Art to set | ||
| 176 | /// - Some default art values (any string possible): | ||
| 177 | /// | value (type) | Type | | ||
| 178 | /// |:-------------:|:--------------------------------------------------| | ||
| 179 | /// | thumb | string - image filename | ||
| 180 | /// | poster | string - image filename | ||
| 181 | /// | banner | string - image filename | ||
| 182 | /// | fanart | string - image filename | ||
| 183 | /// | clearart | string - image filename | ||
| 184 | /// | clearlogo | string - image filename | ||
| 185 | /// | landscape | string - image filename | ||
| 186 | /// | icon | string - image filename | ||
| 187 | /// @return The url to use for Art | ||
| 188 | /// | ||
| 189 | std::string GetArt(const std::string& type) | ||
| 190 | { | ||
| 191 | std::string strReturn; | ||
| 192 | char* ret = m_interface->kodi_gui->listItem->get_art(m_interface->kodiBase, m_controlHandle, | ||
| 193 | type.c_str()); | ||
| 194 | if (ret != nullptr) | ||
| 195 | { | ||
| 196 | if (std::strlen(ret)) | ||
| 197 | strReturn = ret; | ||
| 198 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 199 | } | ||
| 200 | return strReturn; | ||
| 201 | } | ||
| 202 | //---------------------------------------------------------------------------- | ||
| 203 | |||
| 204 | //============================================================================ | ||
| 205 | /// @ingroup cpp_kodi_gui_windows_listitem | ||
| 206 | /// @brief Sets the listitem's art | ||
| 207 | /// | ||
| 208 | /// @param[in] type Type of Art to set | ||
| 209 | /// @param[in] url The url to use for Art | ||
| 210 | /// - Some default art values (any string possible): | ||
| 211 | /// | value (type) | Type | | ||
| 212 | /// |:-------------:|:--------------------------------------------------| | ||
| 213 | /// | thumb | string - image filename | ||
| 214 | /// | poster | string - image filename | ||
| 215 | /// | banner | string - image filename | ||
| 216 | /// | fanart | string - image filename | ||
| 217 | /// | clearart | string - image filename | ||
| 218 | /// | clearlogo | string - image filename | ||
| 219 | /// | landscape | string - image filename | ||
| 220 | /// | icon | string - image filename | ||
| 221 | /// | ||
| 222 | void SetArt(const std::string& type, const std::string& url) | ||
| 223 | { | ||
| 224 | m_interface->kodi_gui->listItem->set_art(m_interface->kodiBase, m_controlHandle, type.c_str(), | ||
| 225 | url.c_str()); | ||
| 226 | } | ||
| 227 | //---------------------------------------------------------------------------- | ||
| 228 | |||
| 229 | //============================================================================ | ||
| 230 | /// @ingroup cpp_kodi_gui_windows_listitem | ||
| 231 | /// @brief Returns the path / filename of this listitem. | ||
| 232 | /// | ||
| 233 | /// @return Path string | ||
| 234 | /// | ||
| 235 | std::string GetPath() | ||
| 236 | { | ||
| 237 | std::string strReturn; | ||
| 238 | char* ret = m_interface->kodi_gui->listItem->get_path(m_interface->kodiBase, m_controlHandle); | ||
| 239 | if (ret != nullptr) | ||
| 240 | { | ||
| 241 | if (std::strlen(ret)) | ||
| 242 | strReturn = ret; | ||
| 243 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 244 | } | ||
| 245 | return strReturn; | ||
| 246 | } | ||
| 247 | //---------------------------------------------------------------------------- | ||
| 248 | |||
| 249 | //============================================================================ | ||
| 250 | /// @ingroup cpp_kodi_gui_windows_listitem | ||
| 251 | /// @brief Sets the listitem's path. | ||
| 252 | /// | ||
| 253 | /// @param[in] path string or unicode - path, activated when item is clicked. | ||
| 254 | /// | ||
| 255 | /// @note You can use the above as keywords for arguments. | ||
| 256 | /// | ||
| 257 | void SetPath(const std::string& path) | ||
| 258 | { | ||
| 259 | m_interface->kodi_gui->listItem->set_path(m_interface->kodiBase, m_controlHandle, path.c_str()); | ||
| 260 | } | ||
| 261 | //---------------------------------------------------------------------------- | ||
| 262 | |||
| 263 | //============================================================================ | ||
| 264 | /// @ingroup cpp_kodi_gui_windows_listitem | ||
| 265 | /// @brief Sets a listitem property, similar to an infolabel. | ||
| 266 | /// | ||
| 267 | /// @param[in] key string - property name. | ||
| 268 | /// @param[in] value string or unicode - value of property. | ||
| 269 | /// | ||
| 270 | /// @note Key is NOT case sensitive. | ||
| 271 | /// You can use the above as keywords for arguments and skip certain@n | ||
| 272 | /// optional arguments.\n | ||
| 273 | /// Once you use a keyword, all following arguments require the | ||
| 274 | /// keyword. | ||
| 275 | /// | ||
| 276 | /// Some of these are treated internally by Kodi, such as the | ||
| 277 | /// <b>'StartOffset'</b> property, which is the offset in seconds at which to | ||
| 278 | /// start playback of an item. Others may be used in the skin to add | ||
| 279 | /// extra information, such as <b>'WatchedCount'</b> for tvshow items | ||
| 280 | /// | ||
| 281 | void SetProperty(const std::string& key, const std::string& value) | ||
| 282 | { | ||
| 283 | m_interface->kodi_gui->listItem->set_property(m_interface->kodiBase, m_controlHandle, | ||
| 284 | key.c_str(), value.c_str()); | ||
| 285 | } | ||
| 286 | //---------------------------------------------------------------------------- | ||
| 287 | |||
| 288 | //============================================================================ | ||
| 289 | /// @ingroup cpp_kodi_gui_windows_listitem | ||
| 290 | /// @brief Returns a listitem property as a string, similar to an infolabel. | ||
| 291 | /// | ||
| 292 | /// @param[in] key string - property name. | ||
| 293 | /// @return string - List item property | ||
| 294 | /// | ||
| 295 | /// @note Key is NOT case sensitive.\n | ||
| 296 | /// You can use the above as keywords for arguments and skip certain | ||
| 297 | /// optional arguments.\n | ||
| 298 | /// Once you use a keyword, all following arguments require the | ||
| 299 | /// keyword. | ||
| 300 | /// | ||
| 301 | std::string GetProperty(const std::string& key) | ||
| 302 | { | ||
| 303 | std::string label; | ||
| 304 | char* ret = m_interface->kodi_gui->listItem->get_property(m_interface->kodiBase, | ||
| 305 | m_controlHandle, key.c_str()); | ||
| 306 | if (ret != nullptr) | ||
| 307 | { | ||
| 308 | if (std::strlen(ret)) | ||
| 309 | label = ret; | ||
| 310 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 311 | } | ||
| 312 | return label; | ||
| 313 | } | ||
| 314 | //---------------------------------------------------------------------------- | ||
| 315 | |||
| 316 | //============================================================================ | ||
| 317 | /// @ingroup cpp_kodi_gui_windows_listitem | ||
| 318 | /// @brief To control selection of item in list (also multiple selection, | ||
| 319 | /// in list on serveral items possible). | ||
| 320 | /// | ||
| 321 | /// @param[in] selected if true becomes set as selected | ||
| 322 | /// | ||
| 323 | void Select(bool selected) | ||
| 324 | { | ||
| 325 | m_interface->kodi_gui->listItem->select(m_interface->kodiBase, m_controlHandle, selected); | ||
| 326 | } | ||
| 327 | //---------------------------------------------------------------------------- | ||
| 328 | |||
| 329 | //============================================================================ | ||
| 330 | /// @ingroup cpp_kodi_gui_windows_listitem | ||
| 331 | /// @brief Returns the listitem's selected status. | ||
| 332 | /// | ||
| 333 | /// @return true if selected, otherwise false | ||
| 334 | /// | ||
| 335 | bool IsSelected() | ||
| 336 | { | ||
| 337 | return m_interface->kodi_gui->listItem->is_selected(m_interface->kodiBase, m_controlHandle); | ||
| 338 | } | ||
| 339 | //---------------------------------------------------------------------------- | ||
| 340 | }; | ||
| 341 | |||
| 342 | } /* namespace gui */ | ||
| 343 | } /* namespace kodi */ | ||
| 344 | |||
| 345 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/Window.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/Window.h new file mode 100644 index 0000000..3066b3c --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/Window.h | |||
| @@ -0,0 +1,915 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../AddonBase.h" | ||
| 12 | #include "../c-api/gui/window.h" | ||
| 13 | #include "ListItem.h" | ||
| 14 | #include "input/ActionIDs.h" | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | |||
| 18 | namespace kodi | ||
| 19 | { | ||
| 20 | namespace gui | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_window_Defs Definitions, structures and enumerators | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 26 | /// @brief **Library definition values**\n | ||
| 27 | /// Additional values, structures and things that are used in the Window class. | ||
| 28 | /// | ||
| 29 | /// ------------------------------------------------------------------------ | ||
| 30 | /// | ||
| 31 | /// @link cpp_kodi_gui_windows_window Go back to normal functions from CWindow@endlink | ||
| 32 | /// | ||
| 33 | |||
| 34 | //============================================================================== | ||
| 35 | /// @ingroup cpp_kodi_gui_windows_window_Defs | ||
| 36 | /// @brief **Handler for addon-sided processing class**\n | ||
| 37 | /// If the callback functions used by the window are not used directly in the | ||
| 38 | /// @ref cpp_kodi_gui_windows_window "CWindow" class and are outside of it. | ||
| 39 | /// | ||
| 40 | /// This value here corresponds to a <b>`void*`</b> and returns the address | ||
| 41 | /// requested by the add-on for callbacks. | ||
| 42 | /// | ||
| 43 | using ClientHandle = KODI_GUI_CLIENT_HANDLE; | ||
| 44 | //------------------------------------------------------------------------------ | ||
| 45 | |||
| 46 | class CListItem; | ||
| 47 | |||
| 48 | //============================================================================== | ||
| 49 | /// @addtogroup cpp_kodi_gui_windows_window | ||
| 50 | /// @brief @cpp_class{ kodi::gui::CWindow } | ||
| 51 | /// **Main window control class**\n | ||
| 52 | /// The addon uses its own skin xml file and displays it in Kodi using this class. | ||
| 53 | /// | ||
| 54 | /// The with @ref Window.h "#include <kodi/gui/Window.h>" | ||
| 55 | /// included file brings support to create a window or dialog on Kodi. | ||
| 56 | /// | ||
| 57 | /// The add-on has to integrate its own @ref cpp_kodi_gui_windows_window_callbacks "callback functions" | ||
| 58 | /// in order to process the necessary user access to its window. | ||
| 59 | /// | ||
| 60 | /// | ||
| 61 | /// -------------------------------------------------------------------------- | ||
| 62 | /// | ||
| 63 | /// **Window header example:** | ||
| 64 | /// ~~~~~~~~~~~~~{.xml} | ||
| 65 | /// <?xml version="1.0" encoding="UTF-8"?> | ||
| 66 | /// <window> | ||
| 67 | /// <onload>RunScript(script.foobar)</onload> | ||
| 68 | /// <onunload>SetProperty(foo,bar)</onunload> | ||
| 69 | /// <defaultcontrol always="false">2</defaultcontrol> | ||
| 70 | /// <menucontrol>9000</menucontrol> | ||
| 71 | /// <backgroundcolor>0xff00ff00</backgroundcolor> | ||
| 72 | /// <views>50,51,509,510</views> | ||
| 73 | /// <visible>Window.IsActive(Home)</visible> | ||
| 74 | /// <animation effect="fade" time="100">WindowOpen</animation> | ||
| 75 | /// <animation effect="slide" end="0,576" time="100">WindowClose</animation> | ||
| 76 | /// <zorder>1</zorder> | ||
| 77 | /// <coordinates> | ||
| 78 | /// <left>40</left> | ||
| 79 | /// <top>50</top> | ||
| 80 | /// <origin x="100" y="50">Window.IsActive(Home)</origin> | ||
| 81 | /// </coordinates> | ||
| 82 | /// <previouswindow>MyVideos</previouswindow> | ||
| 83 | /// <controls> | ||
| 84 | /// <control> | ||
| 85 | /// </control> | ||
| 86 | /// .... | ||
| 87 | /// </controls> | ||
| 88 | /// </window> | ||
| 89 | /// ~~~~~~~~~~~~~ | ||
| 90 | /// | ||
| 91 | /// -------------------------------------------------------------------------- | ||
| 92 | /// | ||
| 93 | /// On functions defined input variable <b><tt>controlId</tt> (GUI control identifier)</b> | ||
| 94 | /// is the on window.xml defined value behind type added with <tt><b>id="..."</b></tt> and | ||
| 95 | /// used to identify for changes there and on callbacks. | ||
| 96 | /// | ||
| 97 | /// ~~~~~~~~~~~~~{.xml} | ||
| 98 | /// <control type="label" id="31"> | ||
| 99 | /// <description>Title Label</description> | ||
| 100 | /// ... | ||
| 101 | /// </control> | ||
| 102 | /// <control type="progress" id="32"> | ||
| 103 | /// <description>progress control</description> | ||
| 104 | /// ... | ||
| 105 | /// </control> | ||
| 106 | /// ~~~~~~~~~~~~~ | ||
| 107 | /// | ||
| 108 | /// | ||
| 109 | class ATTRIBUTE_HIDDEN CWindow : public CAddonGUIControlBase | ||
| 110 | { | ||
| 111 | public: | ||
| 112 | //============================================================================ | ||
| 113 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 114 | /// @brief Class constructor with needed values for window / dialog. | ||
| 115 | /// | ||
| 116 | /// Creates a new Window class. | ||
| 117 | /// | ||
| 118 | /// @param[in] xmlFilename XML file for the skin | ||
| 119 | /// @param[in] defaultSkin Default skin to use if needed not available | ||
| 120 | /// @param[in] asDialog Use window as dialog if set | ||
| 121 | /// @param[in] isMedia [opt] bool - if False, create a regular window. | ||
| 122 | /// if True, create a mediawindow. (default=false) | ||
| 123 | /// | ||
| 124 | /// @note <b>`isMedia`</b> value as true only usable for windows not for dialogs. | ||
| 125 | /// | ||
| 126 | CWindow(const std::string& xmlFilename, | ||
| 127 | const std::string& defaultSkin, | ||
| 128 | bool asDialog, | ||
| 129 | bool isMedia = false) | ||
| 130 | : CAddonGUIControlBase(nullptr) | ||
| 131 | { | ||
| 132 | m_controlHandle = m_interface->kodi_gui->window->create( | ||
| 133 | m_interface->kodiBase, xmlFilename.c_str(), defaultSkin.c_str(), asDialog, isMedia); | ||
| 134 | if (!m_controlHandle) | ||
| 135 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CWindow can't create window class from Kodi !!!"); | ||
| 136 | m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, this, | ||
| 137 | CBOnInit, CBOnFocus, CBOnClick, CBOnAction, | ||
| 138 | CBGetContextButtons, CBOnContextButton); | ||
| 139 | } | ||
| 140 | //---------------------------------------------------------------------------- | ||
| 141 | |||
| 142 | //============================================================================ | ||
| 143 | /// @ingroup CWindow | ||
| 144 | /// @brief Class destructor. | ||
| 145 | /// | ||
| 146 | ~CWindow() override | ||
| 147 | { | ||
| 148 | if (m_controlHandle) | ||
| 149 | m_interface->kodi_gui->window->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 150 | } | ||
| 151 | //---------------------------------------------------------------------------- | ||
| 152 | |||
| 153 | //============================================================================ | ||
| 154 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 155 | /// @brief Show this window. | ||
| 156 | /// | ||
| 157 | /// Shows this window by activating it, calling close() after it wil activate | ||
| 158 | /// the current window again. | ||
| 159 | /// | ||
| 160 | /// @note If your Add-On ends this window will be closed to. To show it forever, | ||
| 161 | /// make a loop at the end of your Add-On or use @ref DoModal() instead. | ||
| 162 | /// | ||
| 163 | /// @warning If used must be the class be global present until Kodi becomes | ||
| 164 | /// closed. The creation can be done before "Show" becomes called, but | ||
| 165 | /// not delete class after them. | ||
| 166 | /// | ||
| 167 | /// @return Return true if call and show is successed, if false was something | ||
| 168 | /// failed to get needed skin parts. | ||
| 169 | /// | ||
| 170 | bool Show() | ||
| 171 | { | ||
| 172 | return m_interface->kodi_gui->window->show(m_interface->kodiBase, m_controlHandle); | ||
| 173 | } | ||
| 174 | //---------------------------------------------------------------------------- | ||
| 175 | |||
| 176 | //============================================================================ | ||
| 177 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 178 | /// @brief Closes this window. | ||
| 179 | /// | ||
| 180 | /// Closes this window by activating the old window. | ||
| 181 | /// @note The window is not deleted with this method. | ||
| 182 | /// | ||
| 183 | void Close() { m_interface->kodi_gui->window->close(m_interface->kodiBase, m_controlHandle); } | ||
| 184 | //---------------------------------------------------------------------------- | ||
| 185 | |||
| 186 | //============================================================================ | ||
| 187 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 188 | /// @brief Display this window until close() is called. | ||
| 189 | /// | ||
| 190 | void DoModal() | ||
| 191 | { | ||
| 192 | m_interface->kodi_gui->window->do_modal(m_interface->kodiBase, m_controlHandle); | ||
| 193 | } | ||
| 194 | //---------------------------------------------------------------------------- | ||
| 195 | |||
| 196 | //============================================================================ | ||
| 197 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 198 | /// @brief Gives the control with the supplied focus. | ||
| 199 | /// | ||
| 200 | /// @param[in] controlId On skin defined id of control | ||
| 201 | /// @return Return true if call and focus is successed, if false was something | ||
| 202 | /// failed to get needed skin parts | ||
| 203 | /// | ||
| 204 | bool SetFocusId(int controlId) | ||
| 205 | { | ||
| 206 | return m_interface->kodi_gui->window->set_focus_id(m_interface->kodiBase, m_controlHandle, | ||
| 207 | controlId); | ||
| 208 | } | ||
| 209 | //---------------------------------------------------------------------------- | ||
| 210 | |||
| 211 | //============================================================================ | ||
| 212 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 213 | /// @brief Returns the id of the control which is focused. | ||
| 214 | /// | ||
| 215 | /// @return Focused control id | ||
| 216 | /// | ||
| 217 | int GetFocusId() | ||
| 218 | { | ||
| 219 | return m_interface->kodi_gui->window->get_focus_id(m_interface->kodiBase, m_controlHandle); | ||
| 220 | } | ||
| 221 | //---------------------------------------------------------------------------- | ||
| 222 | |||
| 223 | //============================================================================ | ||
| 224 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 225 | /// @brief To set the used label on given control id. | ||
| 226 | /// | ||
| 227 | /// @param[in] controlId Control id where label need to set | ||
| 228 | /// @param[in] label Label to use | ||
| 229 | /// | ||
| 230 | void SetControlLabel(int controlId, const std::string& label) | ||
| 231 | { | ||
| 232 | m_interface->kodi_gui->window->set_control_label(m_interface->kodiBase, m_controlHandle, | ||
| 233 | controlId, label.c_str()); | ||
| 234 | } | ||
| 235 | //---------------------------------------------------------------------------- | ||
| 236 | |||
| 237 | //============================================================================ | ||
| 238 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 239 | /// @brief To set the visibility on given control id. | ||
| 240 | /// | ||
| 241 | /// @param[in] controlId Control id where visibility is changed | ||
| 242 | /// @param[in] visible Boolean value with `true` for visible, `false` for hidden | ||
| 243 | /// | ||
| 244 | void SetControlVisible(int controlId, bool visible) | ||
| 245 | { | ||
| 246 | m_interface->kodi_gui->window->set_control_visible(m_interface->kodiBase, m_controlHandle, | ||
| 247 | controlId, visible); | ||
| 248 | } | ||
| 249 | //---------------------------------------------------------------------------- | ||
| 250 | |||
| 251 | //============================================================================ | ||
| 252 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 253 | /// @brief To set the selection on given control id. | ||
| 254 | /// | ||
| 255 | /// @param[in] controlId Control id where selection is changed | ||
| 256 | /// @param[in] selected Boolean value with `true` for selected, `false` for not | ||
| 257 | /// | ||
| 258 | void SetControlSelected(int controlId, bool selected) | ||
| 259 | { | ||
| 260 | m_interface->kodi_gui->window->set_control_selected(m_interface->kodiBase, m_controlHandle, | ||
| 261 | controlId, selected); | ||
| 262 | } | ||
| 263 | //---------------------------------------------------------------------------- | ||
| 264 | |||
| 265 | //============================================================================ | ||
| 266 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 267 | /// @brief Sets a window property, similar to an infolabel. | ||
| 268 | /// | ||
| 269 | /// @param[in] key string - property name. | ||
| 270 | /// @param[in] value string or unicode - value of property. | ||
| 271 | /// | ||
| 272 | /// @note Key is NOT case sensitive. Setting value to an empty string is | ||
| 273 | /// equivalent to clearProperty(key).\n | ||
| 274 | /// You can use the above as keywords for arguments and skip certain | ||
| 275 | /// optional arguments.\n | ||
| 276 | /// Once you use a keyword, all following arguments require the keyword. | ||
| 277 | /// | ||
| 278 | void SetProperty(const std::string& key, const std::string& value) | ||
| 279 | { | ||
| 280 | m_interface->kodi_gui->window->set_property(m_interface->kodiBase, m_controlHandle, key.c_str(), | ||
| 281 | value.c_str()); | ||
| 282 | } | ||
| 283 | //---------------------------------------------------------------------------- | ||
| 284 | |||
| 285 | //============================================================================ | ||
| 286 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 287 | /// @brief Returns a window property as a string, similar to an infolabel. | ||
| 288 | /// | ||
| 289 | /// @param[in] key string - property name. | ||
| 290 | /// @return The property as string (if present) | ||
| 291 | /// | ||
| 292 | /// @note Key is NOT case sensitive. Setting value to an empty string is | ||
| 293 | /// equivalent to clearProperty(key).\n | ||
| 294 | /// You can use the above as keywords for arguments and skip certain | ||
| 295 | /// optional arguments.\n | ||
| 296 | /// Once you use a keyword, all following arguments require the keyword. | ||
| 297 | /// | ||
| 298 | std::string GetProperty(const std::string& key) const | ||
| 299 | { | ||
| 300 | std::string label; | ||
| 301 | char* ret = m_interface->kodi_gui->window->get_property(m_interface->kodiBase, m_controlHandle, | ||
| 302 | key.c_str()); | ||
| 303 | if (ret != nullptr) | ||
| 304 | { | ||
| 305 | if (std::strlen(ret)) | ||
| 306 | label = ret; | ||
| 307 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 308 | } | ||
| 309 | return label; | ||
| 310 | } | ||
| 311 | //---------------------------------------------------------------------------- | ||
| 312 | |||
| 313 | //============================================================================ | ||
| 314 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 315 | /// @brief Sets a window property with integer value | ||
| 316 | /// | ||
| 317 | /// @param[in] key string - property name. | ||
| 318 | /// @param[in] value integer value to set | ||
| 319 | /// | ||
| 320 | void SetPropertyInt(const std::string& key, int value) | ||
| 321 | { | ||
| 322 | m_interface->kodi_gui->window->set_property_int(m_interface->kodiBase, m_controlHandle, | ||
| 323 | key.c_str(), value); | ||
| 324 | } | ||
| 325 | //---------------------------------------------------------------------------- | ||
| 326 | |||
| 327 | //============================================================================ | ||
| 328 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 329 | /// @brief Returns a window property with integer value | ||
| 330 | /// | ||
| 331 | /// @param[in] key string - property name. | ||
| 332 | /// @return integer value of property | ||
| 333 | /// | ||
| 334 | int GetPropertyInt(const std::string& key) const | ||
| 335 | { | ||
| 336 | return m_interface->kodi_gui->window->get_property_int(m_interface->kodiBase, m_controlHandle, | ||
| 337 | key.c_str()); | ||
| 338 | } | ||
| 339 | //---------------------------------------------------------------------------- | ||
| 340 | |||
| 341 | //============================================================================ | ||
| 342 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 343 | /// @brief Sets a window property with boolean value | ||
| 344 | /// | ||
| 345 | /// @param[in] key string - property name. | ||
| 346 | /// @param[in] value boolean value to set | ||
| 347 | /// | ||
| 348 | void SetPropertyBool(const std::string& key, bool value) | ||
| 349 | { | ||
| 350 | m_interface->kodi_gui->window->set_property_bool(m_interface->kodiBase, m_controlHandle, | ||
| 351 | key.c_str(), value); | ||
| 352 | } | ||
| 353 | //---------------------------------------------------------------------------- | ||
| 354 | |||
| 355 | //============================================================================ | ||
| 356 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 357 | /// @brief Returns a window property with boolean value | ||
| 358 | /// | ||
| 359 | /// @param[in] key string - property name. | ||
| 360 | /// @return boolean value of property | ||
| 361 | /// | ||
| 362 | bool GetPropertyBool(const std::string& key) const | ||
| 363 | { | ||
| 364 | return m_interface->kodi_gui->window->get_property_bool(m_interface->kodiBase, m_controlHandle, | ||
| 365 | key.c_str()); | ||
| 366 | } | ||
| 367 | //---------------------------------------------------------------------------- | ||
| 368 | |||
| 369 | //============================================================================ | ||
| 370 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 371 | /// @brief Sets a window property with double value | ||
| 372 | /// | ||
| 373 | /// @param[in] key string - property name. | ||
| 374 | /// @param[in] value double value to set | ||
| 375 | /// | ||
| 376 | void SetPropertyDouble(const std::string& key, double value) | ||
| 377 | { | ||
| 378 | m_interface->kodi_gui->window->set_property_double(m_interface->kodiBase, m_controlHandle, | ||
| 379 | key.c_str(), value); | ||
| 380 | } | ||
| 381 | //---------------------------------------------------------------------------- | ||
| 382 | |||
| 383 | //============================================================================ | ||
| 384 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 385 | /// @brief Returns a window property with double value | ||
| 386 | /// | ||
| 387 | /// @param[in] key string - property name. | ||
| 388 | /// @return double value of property | ||
| 389 | /// | ||
| 390 | double GetPropertyDouble(const std::string& key) const | ||
| 391 | { | ||
| 392 | return m_interface->kodi_gui->window->get_property_double(m_interface->kodiBase, | ||
| 393 | m_controlHandle, key.c_str()); | ||
| 394 | } | ||
| 395 | //---------------------------------------------------------------------------- | ||
| 396 | |||
| 397 | //============================================================================ | ||
| 398 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 399 | /// @brief Remove all present properties from window | ||
| 400 | /// | ||
| 401 | void ClearProperties() | ||
| 402 | { | ||
| 403 | m_interface->kodi_gui->window->clear_properties(m_interface->kodiBase, m_controlHandle); | ||
| 404 | } | ||
| 405 | //---------------------------------------------------------------------------- | ||
| 406 | |||
| 407 | //============================================================================ | ||
| 408 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 409 | /// @brief Clears the specific window property. | ||
| 410 | /// | ||
| 411 | /// @param[in] key string - property name. | ||
| 412 | /// | ||
| 413 | /// @note Key is NOT case sensitive. Equivalent to SetProperty(key, "") | ||
| 414 | /// You can use the above as keywords for arguments and skip certain | ||
| 415 | /// optional arguments. | ||
| 416 | /// Once you use a keyword, all following arguments require the | ||
| 417 | /// keyword. | ||
| 418 | /// | ||
| 419 | /// | ||
| 420 | ///----------------------------------------------------------------------- | ||
| 421 | /// | ||
| 422 | /// **Example:** | ||
| 423 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 424 | /// .. | ||
| 425 | /// ClearProperty('Category') | ||
| 426 | /// .. | ||
| 427 | /// ~~~~~~~~~~~~~ | ||
| 428 | /// | ||
| 429 | void ClearProperty(const std::string& key) | ||
| 430 | { | ||
| 431 | m_interface->kodi_gui->window->clear_property(m_interface->kodiBase, m_controlHandle, | ||
| 432 | key.c_str()); | ||
| 433 | } | ||
| 434 | //---------------------------------------------------------------------------- | ||
| 435 | |||
| 436 | /// @{ | ||
| 437 | //============================================================================ | ||
| 438 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 439 | /// @brief Function delete all entries in integrated list. | ||
| 440 | /// | ||
| 441 | void ClearList() | ||
| 442 | { | ||
| 443 | m_interface->kodi_gui->window->clear_item_list(m_interface->kodiBase, m_controlHandle); | ||
| 444 | } | ||
| 445 | //---------------------------------------------------------------------------- | ||
| 446 | |||
| 447 | //============================================================================ | ||
| 448 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 449 | /// @brief To add a list item in the on window integrated list. | ||
| 450 | /// | ||
| 451 | /// @param[in] item List item to add | ||
| 452 | /// @param[in] itemPosition [opt] The position for item, default is on end | ||
| 453 | /// | ||
| 454 | void AddListItem(std::shared_ptr<CListItem> item, int itemPosition = -1) | ||
| 455 | { | ||
| 456 | m_interface->kodi_gui->window->add_list_item(m_interface->kodiBase, m_controlHandle, | ||
| 457 | item->m_controlHandle, itemPosition); | ||
| 458 | } | ||
| 459 | //---------------------------------------------------------------------------- | ||
| 460 | |||
| 461 | //============================================================================ | ||
| 462 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 463 | /// @brief To add a list item based upon string in the on window integrated list. | ||
| 464 | /// | ||
| 465 | /// @param[in] item List item to add | ||
| 466 | /// @param[in] itemPosition [opt] The position for item, default is on end | ||
| 467 | /// | ||
| 468 | void AddListItem(const std::string item, int itemPosition = -1) | ||
| 469 | { | ||
| 470 | m_interface->kodi_gui->window->add_list_item( | ||
| 471 | m_interface->kodiBase, m_controlHandle, | ||
| 472 | std::make_shared<kodi::gui::CListItem>(item)->m_controlHandle, itemPosition); | ||
| 473 | } | ||
| 474 | //---------------------------------------------------------------------------- | ||
| 475 | |||
| 476 | //============================================================================ | ||
| 477 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 478 | /// @brief Remove list item on position. | ||
| 479 | /// | ||
| 480 | /// @param[in] itemPosition List position to remove | ||
| 481 | /// | ||
| 482 | void RemoveListItem(int itemPosition) | ||
| 483 | { | ||
| 484 | m_interface->kodi_gui->window->remove_list_item_from_position(m_interface->kodiBase, | ||
| 485 | m_controlHandle, itemPosition); | ||
| 486 | } | ||
| 487 | //---------------------------------------------------------------------------- | ||
| 488 | |||
| 489 | //============================================================================ | ||
| 490 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 491 | /// @brief Remove item with given control class from list. | ||
| 492 | /// | ||
| 493 | /// @param[in] item List item control class to remove | ||
| 494 | /// | ||
| 495 | void RemoveListItem(std::shared_ptr<CListItem> item) | ||
| 496 | { | ||
| 497 | m_interface->kodi_gui->window->remove_list_item(m_interface->kodiBase, m_controlHandle, | ||
| 498 | item->m_controlHandle); | ||
| 499 | } | ||
| 500 | //---------------------------------------------------------------------------- | ||
| 501 | |||
| 502 | //============================================================================ | ||
| 503 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 504 | /// @brief To get list item control class on wanted position. | ||
| 505 | /// | ||
| 506 | /// @param[in] listPos Position from where control is needed | ||
| 507 | /// @return The list item control class or null if not found | ||
| 508 | /// | ||
| 509 | /// @warning Function returns a new generated **CListItem** class! | ||
| 510 | /// | ||
| 511 | std::shared_ptr<CListItem> GetListItem(int listPos) | ||
| 512 | { | ||
| 513 | KODI_GUI_LISTITEM_HANDLE handle = m_interface->kodi_gui->window->get_list_item( | ||
| 514 | m_interface->kodiBase, m_controlHandle, listPos); | ||
| 515 | if (!handle) | ||
| 516 | return std::shared_ptr<CListItem>(); | ||
| 517 | |||
| 518 | return std::make_shared<kodi::gui::CListItem>(handle); | ||
| 519 | } | ||
| 520 | //---------------------------------------------------------------------------- | ||
| 521 | |||
| 522 | //============================================================================ | ||
| 523 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 524 | /// @brief To set position of selected part in list. | ||
| 525 | /// | ||
| 526 | /// @param[in] listPos Position to use | ||
| 527 | /// | ||
| 528 | void SetCurrentListPosition(int listPos) | ||
| 529 | { | ||
| 530 | m_interface->kodi_gui->window->set_current_list_position(m_interface->kodiBase, m_controlHandle, | ||
| 531 | listPos); | ||
| 532 | } | ||
| 533 | //---------------------------------------------------------------------------- | ||
| 534 | |||
| 535 | //============================================================================ | ||
| 536 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 537 | /// @brief To get current selected position in list | ||
| 538 | /// | ||
| 539 | /// @return Current list position | ||
| 540 | /// | ||
| 541 | int GetCurrentListPosition() | ||
| 542 | { | ||
| 543 | return m_interface->kodi_gui->window->get_current_list_position(m_interface->kodiBase, | ||
| 544 | m_controlHandle); | ||
| 545 | } | ||
| 546 | //---------------------------------------------------------------------------- | ||
| 547 | |||
| 548 | //============================================================================ | ||
| 549 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 550 | /// @brief To get the amount of entries in the list. | ||
| 551 | /// | ||
| 552 | /// @return Size of in window integrated control class | ||
| 553 | /// | ||
| 554 | int GetListSize() | ||
| 555 | { | ||
| 556 | return m_interface->kodi_gui->window->get_list_size(m_interface->kodiBase, m_controlHandle); | ||
| 557 | } | ||
| 558 | //---------------------------------------------------------------------------- | ||
| 559 | |||
| 560 | //============================================================================ | ||
| 561 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 562 | /// @brief Sets a container property, similar to an infolabel. | ||
| 563 | /// | ||
| 564 | /// @param[in] key string - property name. | ||
| 565 | /// @param[in] value string or unicode - value of property. | ||
| 566 | /// | ||
| 567 | /// @note Key is NOT case sensitive.\n | ||
| 568 | /// You can use the above as keywords for arguments and skip certain | ||
| 569 | /// optional arguments.\n | ||
| 570 | /// Once you use a keyword, all following arguments require the keyword. | ||
| 571 | /// | ||
| 572 | void SetContainerProperty(const std::string& key, const std::string& value) | ||
| 573 | { | ||
| 574 | m_interface->kodi_gui->window->set_container_property(m_interface->kodiBase, m_controlHandle, | ||
| 575 | key.c_str(), value.c_str()); | ||
| 576 | } | ||
| 577 | //---------------------------------------------------------------------------- | ||
| 578 | |||
| 579 | //============================================================================ | ||
| 580 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 581 | /// @brief Sets the content type of the container. | ||
| 582 | /// | ||
| 583 | /// @param[in] value string or unicode - content value. | ||
| 584 | /// | ||
| 585 | /// __Available content types__ | ||
| 586 | /// | Name | Media | | ||
| 587 | /// |:-----------:|:-----------------------------------------| | ||
| 588 | /// | actors | Videos | ||
| 589 | /// | addons | Addons, Music, Pictures, Programs, Videos | ||
| 590 | /// | albums | Music, Videos | ||
| 591 | /// | artists | Music, Videos | ||
| 592 | /// | countries | Music, Videos | ||
| 593 | /// | directors | Videos | ||
| 594 | /// | files | Music, Videos | ||
| 595 | /// | games | Games | ||
| 596 | /// | genres | Music, Videos | ||
| 597 | /// | images | Pictures | ||
| 598 | /// | mixed | Music, Videos | ||
| 599 | /// | movies | Videos | ||
| 600 | /// | Musicvideos | Music, Videos | ||
| 601 | /// | playlists | Music, Videos | ||
| 602 | /// | seasons | Videos | ||
| 603 | /// | sets | Videos | ||
| 604 | /// | songs | Music | ||
| 605 | /// | studios | Music, Videos | ||
| 606 | /// | tags | Music, Videos | ||
| 607 | /// | tvshows | Videos | ||
| 608 | /// | videos | Videos | ||
| 609 | /// | years | Music, Videos | ||
| 610 | /// | ||
| 611 | void SetContainerContent(const std::string& value) | ||
| 612 | { | ||
| 613 | m_interface->kodi_gui->window->set_container_content(m_interface->kodiBase, m_controlHandle, | ||
| 614 | value.c_str()); | ||
| 615 | } | ||
| 616 | //---------------------------------------------------------------------------- | ||
| 617 | |||
| 618 | //============================================================================ | ||
| 619 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 620 | /// @brief Get the id of the currently visible container. | ||
| 621 | /// | ||
| 622 | /// @return currently visible container id | ||
| 623 | /// | ||
| 624 | int GetCurrentContainerId() | ||
| 625 | { | ||
| 626 | return m_interface->kodi_gui->window->get_current_container_id(m_interface->kodiBase, | ||
| 627 | m_controlHandle); | ||
| 628 | } | ||
| 629 | //---------------------------------------------------------------------------- | ||
| 630 | /// @} | ||
| 631 | |||
| 632 | //============================================================================ | ||
| 633 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 634 | /// @brief To inform Kodi that it need to render region new. | ||
| 635 | /// | ||
| 636 | void MarkDirtyRegion() | ||
| 637 | { | ||
| 638 | return m_interface->kodi_gui->window->mark_dirty_region(m_interface->kodiBase, m_controlHandle); | ||
| 639 | } | ||
| 640 | //---------------------------------------------------------------------------- | ||
| 641 | |||
| 642 | //============================================================================ | ||
| 643 | /// @defgroup cpp_kodi_gui_windows_window_callbacks Callback functions from Kodi to add-on | ||
| 644 | /// @ingroup cpp_kodi_gui_windows_window | ||
| 645 | /// @{ | ||
| 646 | /// @brief <b>GUI window callback functions.</b>\n | ||
| 647 | /// Functions to handle control callbacks from Kodi | ||
| 648 | /// | ||
| 649 | /// ------------------------------------------------------------------------ | ||
| 650 | /// | ||
| 651 | /// @link cpp_kodi_gui_windows_window Go back to normal functions from CWindow@endlink | ||
| 652 | // | ||
| 653 | |||
| 654 | //============================================================================ | ||
| 655 | /// @ingroup cpp_kodi_gui_windows_window_callbacks | ||
| 656 | /// @brief OnInit method. | ||
| 657 | /// | ||
| 658 | /// @return Return true if initialize was done successful | ||
| 659 | /// | ||
| 660 | /// | ||
| 661 | virtual bool OnInit() { return false; } | ||
| 662 | //---------------------------------------------------------------------------- | ||
| 663 | |||
| 664 | //============================================================================ | ||
| 665 | /// @ingroup cpp_kodi_gui_windows_window_callbacks | ||
| 666 | /// @brief OnFocus method. | ||
| 667 | /// | ||
| 668 | /// @param[in] controlId GUI control identifier | ||
| 669 | /// @return Return true if focus condition was handled there or false to handle | ||
| 670 | /// them by Kodi itself | ||
| 671 | /// | ||
| 672 | /// | ||
| 673 | virtual bool OnFocus(int controlId) { return false; } | ||
| 674 | //---------------------------------------------------------------------------- | ||
| 675 | |||
| 676 | //============================================================================ | ||
| 677 | /// @ingroup cpp_kodi_gui_windows_window_callbacks | ||
| 678 | /// @brief OnClick method. | ||
| 679 | /// | ||
| 680 | /// @param[in] controlId GUI control identifier | ||
| 681 | /// @return Return true if click was handled there or false to handle them by | ||
| 682 | /// Kodi itself | ||
| 683 | /// | ||
| 684 | /// | ||
| 685 | virtual bool OnClick(int controlId) { return false; } | ||
| 686 | //---------------------------------------------------------------------------- | ||
| 687 | |||
| 688 | //============================================================================ | ||
| 689 | /// @ingroup cpp_kodi_gui_windows_window_callbacks | ||
| 690 | /// @brief OnAction method. | ||
| 691 | /// | ||
| 692 | /// @param[in] actionId The action id to perform, see | ||
| 693 | /// @ref kodi_key_action_ids to get list of | ||
| 694 | /// them | ||
| 695 | /// @return Return true if action was handled there | ||
| 696 | /// or false to handle them by Kodi itself | ||
| 697 | /// | ||
| 698 | /// | ||
| 699 | /// This method will receive all actions that the main program will send | ||
| 700 | /// to this window. | ||
| 701 | /// | ||
| 702 | /// @note | ||
| 703 | /// - By default, only the @c ADDON_ACTION_PREVIOUS_MENU and @c ADDON_ACTION_NAV_BACK actions are handled. | ||
| 704 | /// - Overwrite this method to let your code handle all actions. | ||
| 705 | /// - Don't forget to capture @ref ADDON_ACTION_PREVIOUS_MENU or @ref ADDON_ACTION_NAV_BACK, else the user can't close this window. | ||
| 706 | /// | ||
| 707 | /// | ||
| 708 | ///---------------------------------------------------------------------------- | ||
| 709 | /// | ||
| 710 | /// **Example:** | ||
| 711 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 712 | /// .. | ||
| 713 | /// // Window used with parent / child way | ||
| 714 | /// bool cYOUR_CLASS::OnAction(ADDON_ACTION actionId) | ||
| 715 | /// { | ||
| 716 | /// switch (action) | ||
| 717 | /// { | ||
| 718 | /// case ADDON_ACTION_PREVIOUS_MENU: | ||
| 719 | /// case ADDON_ACTION_NAV_BACK: | ||
| 720 | /// printf("action recieved: previous"); | ||
| 721 | /// Close(); | ||
| 722 | /// return true; | ||
| 723 | /// case ADDON_ACTION_SHOW_INFO: | ||
| 724 | /// printf("action recieved: show info"); | ||
| 725 | /// break; | ||
| 726 | /// case ADDON_ACTION_STOP: | ||
| 727 | /// printf("action recieved: stop"); | ||
| 728 | /// break; | ||
| 729 | /// case ADDON_ACTION_PAUSE: | ||
| 730 | /// printf("action recieved: pause"); | ||
| 731 | /// break; | ||
| 732 | /// default: | ||
| 733 | /// break; | ||
| 734 | /// } | ||
| 735 | /// return false; | ||
| 736 | /// } | ||
| 737 | /// .. | ||
| 738 | /// ~~~~~~~~~~~~~ | ||
| 739 | /// | ||
| 740 | virtual bool OnAction(ADDON_ACTION actionId) | ||
| 741 | { | ||
| 742 | switch (actionId) | ||
| 743 | { | ||
| 744 | case ADDON_ACTION_PREVIOUS_MENU: | ||
| 745 | case ADDON_ACTION_NAV_BACK: | ||
| 746 | Close(); | ||
| 747 | return true; | ||
| 748 | default: | ||
| 749 | break; | ||
| 750 | } | ||
| 751 | return false; | ||
| 752 | } | ||
| 753 | //---------------------------------------------------------------------------- | ||
| 754 | |||
| 755 | //============================================================================ | ||
| 756 | /// @ingroup cpp_kodi_gui_windows_window_callbacks | ||
| 757 | /// @brief Get context menu buttons for list entry. | ||
| 758 | /// | ||
| 759 | /// @param[in] itemNumber Selected list item entry | ||
| 760 | /// @param[in] buttons List where context menus becomes added with his | ||
| 761 | /// identifier and name | ||
| 762 | /// | ||
| 763 | virtual void GetContextButtons(int itemNumber, | ||
| 764 | std::vector<std::pair<unsigned int, std::string>>& buttons) | ||
| 765 | { | ||
| 766 | } | ||
| 767 | //---------------------------------------------------------------------------- | ||
| 768 | |||
| 769 | //============================================================================ | ||
| 770 | /// @ingroup cpp_kodi_gui_windows_window_callbacks | ||
| 771 | /// @brief Called after selection in context menu. | ||
| 772 | /// | ||
| 773 | /// @param[in] itemNumber Selected list item entry | ||
| 774 | /// @param[in] button The pressed button id | ||
| 775 | /// @return true if handled, otherwise false | ||
| 776 | /// | ||
| 777 | virtual bool OnContextButton(int itemNumber, unsigned int button) { return false; } | ||
| 778 | //---------------------------------------------------------------------------- | ||
| 779 | |||
| 780 | //============================================================================ | ||
| 781 | /// @ingroup cpp_kodi_gui_windows_window_callbacks | ||
| 782 | /// @brief **Set independent callbacks** | ||
| 783 | /// | ||
| 784 | /// If the class is used independent (with "new CWindow") and | ||
| 785 | /// not as parent (with \"cCLASS_own : public @ref cpp_kodi_gui_windows_window "kodi::gui::CWindow"\") from own must be the | ||
| 786 | /// callback from Kodi to add-on overdriven with own functions! | ||
| 787 | /// | ||
| 788 | /// @param[in] cbhdl The pointer to own handle data structure / class | ||
| 789 | /// @param[in] CBOnInit Own defined window init function | ||
| 790 | /// @param[in] CBOnFocus Own defined focus function | ||
| 791 | /// @param[in] CBOnClick Own defined click function | ||
| 792 | /// @param[in] CBOnAction Own defined action function | ||
| 793 | /// @param[in] CBGetContextButtons [opt] To get context menu entries for | ||
| 794 | /// lists function | ||
| 795 | /// @param[in] CBOnContextButton [opt] Used context menu entry function | ||
| 796 | /// | ||
| 797 | /// | ||
| 798 | ///---------------------------------------------------------------------------- | ||
| 799 | /// | ||
| 800 | /// **Example:** | ||
| 801 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 802 | /// ... | ||
| 803 | /// | ||
| 804 | /// bool OnInit(kodi::gui::ClientHandle cbhdl) | ||
| 805 | /// { | ||
| 806 | /// ... | ||
| 807 | /// return true; | ||
| 808 | /// } | ||
| 809 | /// | ||
| 810 | /// bool OnFocus(kodi::gui::ClientHandle cbhdl, int controlId) | ||
| 811 | /// { | ||
| 812 | /// ... | ||
| 813 | /// return true; | ||
| 814 | /// } | ||
| 815 | /// | ||
| 816 | /// bool OnClick(kodi::gui::ClientHandle cbhdl, int controlId) | ||
| 817 | /// { | ||
| 818 | /// ... | ||
| 819 | /// return true; | ||
| 820 | /// } | ||
| 821 | /// | ||
| 822 | /// bool OnAction(kodi::gui::ClientHandle cbhdl, ADDON_ACTION actionId) | ||
| 823 | /// { | ||
| 824 | /// ... | ||
| 825 | /// return true; | ||
| 826 | /// } | ||
| 827 | /// | ||
| 828 | /// ... | ||
| 829 | /// // Somewhere where you create the window | ||
| 830 | /// CWindow myWindow = new CWindow; | ||
| 831 | /// myWindow->SetIndependentCallbacks(myWindow, OnInit, OnFocus, OnClick, OnAction); | ||
| 832 | /// ... | ||
| 833 | /// ~~~~~~~~~~~~~ | ||
| 834 | /// | ||
| 835 | void SetIndependentCallbacks(kodi::gui::ClientHandle cbhdl, | ||
| 836 | bool (*CBOnInit)(kodi::gui::ClientHandle cbhdl), | ||
| 837 | bool (*CBOnFocus)(kodi::gui::ClientHandle cbhdl, int controlId), | ||
| 838 | bool (*CBOnClick)(kodi::gui::ClientHandle cbhdl, int controlId), | ||
| 839 | bool (*CBOnAction)(kodi::gui::ClientHandle cbhdl, | ||
| 840 | ADDON_ACTION actionId), | ||
| 841 | void (*CBGetContextButtons)(kodi::gui::ClientHandle cbhdl, | ||
| 842 | int itemNumber, | ||
| 843 | gui_context_menu_pair* buttons, | ||
| 844 | unsigned int* size) = nullptr, | ||
| 845 | bool (*CBOnContextButton)(kodi::gui::ClientHandle cbhdl, | ||
| 846 | int itemNumber, | ||
| 847 | unsigned int button) = nullptr) | ||
| 848 | { | ||
| 849 | if (!cbhdl || !CBOnInit || !CBOnFocus || !CBOnClick || !CBOnAction) | ||
| 850 | { | ||
| 851 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CWindow::%s called with nullptr !!!", __FUNCTION__); | ||
| 852 | return; | ||
| 853 | } | ||
| 854 | |||
| 855 | m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, cbhdl, | ||
| 856 | CBOnInit, CBOnFocus, CBOnClick, CBOnAction, | ||
| 857 | CBGetContextButtons, CBOnContextButton); | ||
| 858 | } | ||
| 859 | //---------------------------------------------------------------------------- | ||
| 860 | /// @} | ||
| 861 | |||
| 862 | private: | ||
| 863 | static bool CBOnInit(KODI_GUI_CLIENT_HANDLE cbhdl) | ||
| 864 | { | ||
| 865 | return static_cast<CWindow*>(cbhdl)->OnInit(); | ||
| 866 | } | ||
| 867 | |||
| 868 | static bool CBOnFocus(KODI_GUI_CLIENT_HANDLE cbhdl, int controlId) | ||
| 869 | { | ||
| 870 | return static_cast<CWindow*>(cbhdl)->OnFocus(controlId); | ||
| 871 | } | ||
| 872 | |||
| 873 | static bool CBOnClick(KODI_GUI_CLIENT_HANDLE cbhdl, int controlId) | ||
| 874 | { | ||
| 875 | return static_cast<CWindow*>(cbhdl)->OnClick(controlId); | ||
| 876 | } | ||
| 877 | |||
| 878 | static bool CBOnAction(KODI_GUI_CLIENT_HANDLE cbhdl, ADDON_ACTION actionId) | ||
| 879 | { | ||
| 880 | return static_cast<CWindow*>(cbhdl)->OnAction(actionId); | ||
| 881 | } | ||
| 882 | |||
| 883 | static void CBGetContextButtons(KODI_GUI_CLIENT_HANDLE cbhdl, | ||
| 884 | int itemNumber, | ||
| 885 | gui_context_menu_pair* buttons, | ||
| 886 | unsigned int* size) | ||
| 887 | { | ||
| 888 | std::vector<std::pair<unsigned int, std::string>> buttonList; | ||
| 889 | static_cast<CWindow*>(cbhdl)->GetContextButtons(itemNumber, buttonList); | ||
| 890 | if (!buttonList.empty()) | ||
| 891 | { | ||
| 892 | unsigned int presentSize = static_cast<unsigned int>(buttonList.size()); | ||
| 893 | if (presentSize > *size) | ||
| 894 | kodi::Log(ADDON_LOG_WARNING, "GetContextButtons: More as allowed '%i' entries present!", | ||
| 895 | *size); | ||
| 896 | else | ||
| 897 | *size = presentSize; | ||
| 898 | for (unsigned int i = 0; i < *size; ++i) | ||
| 899 | { | ||
| 900 | buttons[i].id = buttonList[i].first; | ||
| 901 | strncpy(buttons[i].name, buttonList[i].second.c_str(), ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH); | ||
| 902 | } | ||
| 903 | } | ||
| 904 | } | ||
| 905 | |||
| 906 | static bool CBOnContextButton(KODI_GUI_CLIENT_HANDLE cbhdl, int itemNumber, unsigned int button) | ||
| 907 | { | ||
| 908 | return static_cast<CWindow*>(cbhdl)->OnContextButton(itemNumber, button); | ||
| 909 | } | ||
| 910 | }; | ||
| 911 | |||
| 912 | } /* namespace gui */ | ||
| 913 | } /* namespace kodi */ | ||
| 914 | |||
| 915 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h index 081ab06..873a549 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h | |||
| @@ -8,9 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../../AddonBase.h" | 11 | #include "../../c-api/gui/controls/button.h" |
| 12 | #include "../Window.h" | 12 | #include "../Window.h" |
| 13 | 13 | ||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 14 | namespace kodi | 16 | namespace kodi |
| 15 | { | 17 | { |
| 16 | namespace gui | 18 | namespace gui |
| @@ -18,35 +20,33 @@ namespace gui | |||
| 18 | namespace controls | 20 | namespace controls |
| 19 | { | 21 | { |
| 20 | 22 | ||
| 21 | //============================================================================ | 23 | //============================================================================== |
| 22 | /// | 24 | /// @defgroup cpp_kodi_gui_windows_controls_CButton Control Button |
| 23 | /// \defgroup cpp_kodi_gui_controls_CButton Control Button | 25 | /// @ingroup cpp_kodi_gui_windows_controls |
| 24 | /// \ingroup cpp_kodi_gui | 26 | /// @brief @cpp_class{ kodi::gui::controls::CButton } |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CButton } | 27 | /// **Standard push button control for window**\n |
| 26 | /// **Standard push button control for window** | 28 | /// The button control is used for creating push buttons in Kodi. |
| 27 | /// | 29 | /// |
| 28 | /// The button control is used for creating push buttons in Kodi. You can | 30 | /// You can choose the position, size, and look of the button, as well as |
| 29 | /// choose the position, size, and look of the button, as well as choosing | 31 | /// choosing what action(s) should be performed when pushed. |
| 30 | /// what action(s) should be performed when pushed. | ||
| 31 | /// | 32 | /// |
| 32 | /// It has the header \ref Button.h "#include <kodi/gui/controls/Button.h>" | 33 | /// It has the header @ref Button.h "#include <kodi/gui/controls/Button.h>" |
| 33 | /// be included to enjoy it. | 34 | /// be included to enjoy it. |
| 34 | /// | 35 | /// |
| 35 | /// Here you find the needed skin part for a \ref skin_Button_control "button control" | 36 | /// Here you find the needed skin part for a @ref skin_Button_control "button control" |
| 36 | /// | 37 | /// |
| 37 | /// @note The call of the control is only possible from the corresponding | 38 | /// @note The call of the control is only possible from the corresponding |
| 38 | /// window as its class and identification number is required. | 39 | /// window as its class and identification number is required. |
| 39 | /// | 40 | /// |
| 40 | class ATTRIBUTE_HIDDEN CButton : public CAddonGUIControlBase | 41 | class ATTRIBUTE_HIDDEN CButton : public CAddonGUIControlBase |
| 41 | { | 42 | { |
| 42 | public: | 43 | public: |
| 43 | //========================================================================== | 44 | //============================================================================ |
| 44 | /// | 45 | /// @ingroup cpp_kodi_gui_windows_controls_CButton |
| 45 | /// @ingroup cpp_kodi_gui_control_CButton | 46 | /// @brief Construct a new control. |
| 46 | /// @brief Construct a new control | ||
| 47 | /// | 47 | /// |
| 48 | /// @param[in] window related window control class | 48 | /// @param[in] window Related window control class |
| 49 | /// @param[in] controlId Used skin xml control id | 49 | /// @param[in] controlId Used skin xml control id |
| 50 | /// | 50 | /// |
| 51 | CButton(CWindow* window, int controlId) : CAddonGUIControlBase(window) | 51 | CButton(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 52 | { | 52 | { |
| @@ -55,64 +55,59 @@ public: | |||
| 55 | if (!m_controlHandle) | 55 | if (!m_controlHandle) |
| 56 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CButton can't create control class from Kodi !!!"); | 56 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CButton can't create control class from Kodi !!!"); |
| 57 | } | 57 | } |
| 58 | //-------------------------------------------------------------------------- | 58 | //---------------------------------------------------------------------------- |
| 59 | 59 | ||
| 60 | //========================================================================== | 60 | //============================================================================ |
| 61 | /// | 61 | /// @ingroup cpp_kodi_gui_windows_controls_CButton |
| 62 | /// @ingroup cpp_kodi_gui_control_CButton | 62 | /// @brief Destructor. |
| 63 | /// @brief Destructor | ||
| 64 | /// | 63 | /// |
| 65 | ~CButton() override = default; | 64 | ~CButton() override = default; |
| 66 | //-------------------------------------------------------------------------- | 65 | //---------------------------------------------------------------------------- |
| 67 | 66 | ||
| 68 | //========================================================================== | 67 | //============================================================================ |
| 69 | /// | 68 | /// @ingroup cpp_kodi_gui_windows_controls_CButton |
| 70 | /// @ingroup cpp_kodi_gui_control_CButton | 69 | /// @brief Set the control on window to visible. |
| 71 | /// @brief Set the control on window to visible | ||
| 72 | /// | 70 | /// |
| 73 | /// @param[in] visible If true visible, otherwise hidden | 71 | /// @param[in] visible If true visible, otherwise hidden |
| 74 | /// | 72 | /// |
| 75 | void SetVisible(bool visible) | 73 | void SetVisible(bool visible) |
| 76 | { | 74 | { |
| 77 | m_interface->kodi_gui->control_button->set_visible(m_interface->kodiBase, m_controlHandle, | 75 | m_interface->kodi_gui->control_button->set_visible(m_interface->kodiBase, m_controlHandle, |
| 78 | visible); | 76 | visible); |
| 79 | } | 77 | } |
| 80 | //-------------------------------------------------------------------------- | 78 | //---------------------------------------------------------------------------- |
| 81 | 79 | ||
| 82 | //========================================================================== | 80 | //============================================================================ |
| 83 | /// | 81 | /// @ingroup cpp_kodi_gui_windows_controls_CButton |
| 84 | /// @ingroup cpp_kodi_gui_control_CButton | 82 | /// @brief Set's the control's enabled/disabled state. |
| 85 | /// @brief Set's the control's enabled/disabled state | ||
| 86 | /// | 83 | /// |
| 87 | /// @param[in] enabled If true enabled, otherwise disabled | 84 | /// @param[in] enabled If true enabled, otherwise disabled |
| 88 | /// | 85 | /// |
| 89 | void SetEnabled(bool enabled) | 86 | void SetEnabled(bool enabled) |
| 90 | { | 87 | { |
| 91 | m_interface->kodi_gui->control_button->set_enabled(m_interface->kodiBase, m_controlHandle, | 88 | m_interface->kodi_gui->control_button->set_enabled(m_interface->kodiBase, m_controlHandle, |
| 92 | enabled); | 89 | enabled); |
| 93 | } | 90 | } |
| 94 | //-------------------------------------------------------------------------- | 91 | //---------------------------------------------------------------------------- |
| 95 | 92 | ||
| 96 | //========================================================================== | 93 | //============================================================================ |
| 94 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 95 | /// @brief To set the text string on button. | ||
| 97 | /// | 96 | /// |
| 98 | /// @ingroup cpp_kodi_gui_control_CButton | 97 | /// @param[in] label Text to show |
| 99 | /// @brief To set the text string on button | ||
| 100 | /// | ||
| 101 | /// @param[in] label Text to show | ||
| 102 | /// | 98 | /// |
| 103 | void SetLabel(const std::string& label) | 99 | void SetLabel(const std::string& label) |
| 104 | { | 100 | { |
| 105 | m_interface->kodi_gui->control_button->set_label(m_interface->kodiBase, m_controlHandle, | 101 | m_interface->kodi_gui->control_button->set_label(m_interface->kodiBase, m_controlHandle, |
| 106 | label.c_str()); | 102 | label.c_str()); |
| 107 | } | 103 | } |
| 108 | //-------------------------------------------------------------------------- | 104 | //---------------------------------------------------------------------------- |
| 109 | 105 | ||
| 110 | //========================================================================== | 106 | //============================================================================ |
| 111 | /// | 107 | /// @ingroup cpp_kodi_gui_windows_controls_CButton |
| 112 | /// @ingroup cpp_kodi_gui_control_CButton | 108 | /// @brief Get the used text from button. |
| 113 | /// @brief Get the used text from button | ||
| 114 | /// | 109 | /// |
| 115 | /// @return Text shown | 110 | /// @return Text shown |
| 116 | /// | 111 | /// |
| 117 | std::string GetLabel() const | 112 | std::string GetLabel() const |
| 118 | { | 113 | { |
| @@ -127,28 +122,26 @@ public: | |||
| 127 | } | 122 | } |
| 128 | return label; | 123 | return label; |
| 129 | } | 124 | } |
| 130 | //-------------------------------------------------------------------------- | 125 | //---------------------------------------------------------------------------- |
| 131 | 126 | ||
| 132 | //========================================================================== | 127 | //============================================================================ |
| 133 | /// | 128 | /// @ingroup cpp_kodi_gui_windows_controls_CButton |
| 134 | /// @ingroup cpp_kodi_gui_control_CButton | 129 | /// @brief If two labels are used for button becomes it set with them. |
| 135 | /// @brief If two labels are used for button becomes it set with them | ||
| 136 | /// | 130 | /// |
| 137 | /// @param[in] label Text for second label | 131 | /// @param[in] label Text for second label |
| 138 | /// | 132 | /// |
| 139 | void SetLabel2(const std::string& label) | 133 | void SetLabel2(const std::string& label) |
| 140 | { | 134 | { |
| 141 | m_interface->kodi_gui->control_button->set_label2(m_interface->kodiBase, m_controlHandle, | 135 | m_interface->kodi_gui->control_button->set_label2(m_interface->kodiBase, m_controlHandle, |
| 142 | label.c_str()); | 136 | label.c_str()); |
| 143 | } | 137 | } |
| 144 | //-------------------------------------------------------------------------- | 138 | //---------------------------------------------------------------------------- |
| 145 | 139 | ||
| 146 | //========================================================================== | 140 | //============================================================================ |
| 141 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 142 | /// @brief Get the second label if present. | ||
| 147 | /// | 143 | /// |
| 148 | /// @ingroup cpp_kodi_gui_control_CButton | 144 | /// @return Second label |
| 149 | /// @brief Get the second label if present | ||
| 150 | /// | ||
| 151 | /// @return Second label | ||
| 152 | /// | 145 | /// |
| 153 | std::string GetLabel2() const | 146 | std::string GetLabel2() const |
| 154 | { | 147 | { |
| @@ -163,9 +156,11 @@ public: | |||
| 163 | } | 156 | } |
| 164 | return label; | 157 | return label; |
| 165 | } | 158 | } |
| 166 | //-------------------------------------------------------------------------- | 159 | //---------------------------------------------------------------------------- |
| 167 | }; | 160 | }; |
| 168 | 161 | ||
| 169 | } /* namespace controls */ | 162 | } /* namespace controls */ |
| 170 | } /* namespace gui */ | 163 | } /* namespace gui */ |
| 171 | } /* namespace kodi */ | 164 | } /* namespace kodi */ |
| 165 | |||
| 166 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/CMakeLists.txt index c7cc1dd..3fdab01 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/CMakeLists.txt +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/CMakeLists.txt | |||
| @@ -12,5 +12,5 @@ set(HEADERS Button.h | |||
| 12 | TextBox.h) | 12 | TextBox.h) |
| 13 | 13 | ||
| 14 | if(NOT ENABLE_STATIC_LIBS) | 14 | if(NOT ENABLE_STATIC_LIBS) |
| 15 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_gui_controls) | 15 | core_add_library(addons_kodi-dev-kit_include_kodi_gui_controls) |
| 16 | endif() | 16 | endif() |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h index 99c01de..00c6231 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h | |||
| @@ -8,9 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../../AddonBase.h" | 11 | #include "../../c-api/gui/controls/edit.h" |
| 12 | #include "../Window.h" | 12 | #include "../Window.h" |
| 13 | 13 | ||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 14 | namespace kodi | 16 | namespace kodi |
| 15 | { | 17 | { |
| 16 | namespace gui | 18 | namespace gui |
| @@ -18,93 +20,43 @@ namespace gui | |||
| 18 | namespace controls | 20 | namespace controls |
| 19 | { | 21 | { |
| 20 | 22 | ||
| 21 | //============================================================================ | 23 | //============================================================================== |
| 22 | /// | 24 | /// @defgroup cpp_kodi_gui_windows_controls_CEdit Control Edit |
| 23 | /// \defgroup cpp_kodi_gui_controls_CEdit Control Edit | 25 | /// @ingroup cpp_kodi_gui_windows_controls |
| 24 | /// \ingroup cpp_kodi_gui | 26 | /// @brief @cpp_class{ kodi::gui::controls::CEdit } |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CEdit } | 27 | /// **Editable window text control used as an input control for the osd keyboard |
| 26 | /// **Editable window text control used as an input control for the osd keyboard | 28 | /// and other input fields**\n |
| 27 | /// and other input fields** | 29 | /// The edit control allows a user to input text in Kodi. |
| 28 | /// | 30 | /// |
| 29 | /// The edit control allows a user to input text in Kodi. You can choose the | 31 | /// You can choose the font, size, colour, location and header of the text to be |
| 30 | /// font, size, colour, location and header of the text to be displayed. | 32 | /// displayed. |
| 31 | /// | 33 | /// |
| 32 | /// It has the header \ref Edit.h "#include <kodi/gui/controls/Edit.h>" | 34 | /// It has the header @ref Edit.h "#include <kodi/gui/controls/Edit.h>" |
| 33 | /// be included to enjoy it. | 35 | /// be included to enjoy it. |
| 34 | /// | 36 | /// |
| 35 | /// Here you find the needed skin part for a \ref skin_Edit_control | 37 | /// Here you find the needed skin partfor a @ref skin_Edit_control "edit control". |
| 36 | /// "edit control". | 38 | /// |
| 37 | /// | 39 | /// @note The call of the control is only possible from the corresponding |
| 38 | /// @note The call of the control is only possible from the corresponding | 40 | /// window as its class and identification number is required. |
| 39 | /// window as its class and identification number is required. | ||
| 40 | /// | ||
| 41 | |||
| 42 | //============================================================================ | ||
| 43 | // see gui/definition.h for use of group "cpp_kodi_gui_controls_CEdit_Defs" | ||
| 44 | /// | ||
| 45 | /// \defgroup cpp_kodi_gui_controls_CEdit_Defs Definitions, structures and enumerators | ||
| 46 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 47 | /// @brief **Library definition values** | ||
| 48 | /// | ||
| 49 | |||
| 50 | } /* namespace controls */ | ||
| 51 | } /* namespace gui */ | ||
| 52 | } /* namespace kodi */ | ||
| 53 | |||
| 54 | //============================================================================ | ||
| 55 | /// | 41 | /// |
| 56 | /// \ingroup cpp_kodi_gui_controls_CEdit_Defs | ||
| 57 | /// @{ | ||
| 58 | /// @anchor AddonGUIInputType | ||
| 59 | /// @brief Text input types used on kodi::gui::controls::CEdit | ||
| 60 | enum AddonGUIInputType | ||
| 61 | { | ||
| 62 | /// Text inside edit control only readable | ||
| 63 | ADDON_INPUT_TYPE_READONLY = -1, | ||
| 64 | /// Normal text entries | ||
| 65 | ADDON_INPUT_TYPE_TEXT = 0, | ||
| 66 | /// To use on edit control only numeric numbers | ||
| 67 | ADDON_INPUT_TYPE_NUMBER, | ||
| 68 | /// To insert seconds | ||
| 69 | ADDON_INPUT_TYPE_SECONDS, | ||
| 70 | /// To insert time | ||
| 71 | ADDON_INPUT_TYPE_TIME, | ||
| 72 | /// To insert a date | ||
| 73 | ADDON_INPUT_TYPE_DATE, | ||
| 74 | /// Used for write in IP addresses | ||
| 75 | ADDON_INPUT_TYPE_IPADDRESS, | ||
| 76 | /// Text field used as password entry field with not visible text | ||
| 77 | ADDON_INPUT_TYPE_PASSWORD, | ||
| 78 | /// Text field used as password entry field with not visible text but | ||
| 79 | /// returned as MD5 value | ||
| 80 | ADDON_INPUT_TYPE_PASSWORD_MD5, | ||
| 81 | /// Use text field for search purpose | ||
| 82 | ADDON_INPUT_TYPE_SEARCH, | ||
| 83 | /// Text field as filter | ||
| 84 | ADDON_INPUT_TYPE_FILTER, | ||
| 85 | /// | ||
| 86 | ADDON_INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW | ||
| 87 | }; | ||
| 88 | /// @} | ||
| 89 | //---------------------------------------------------------------------------- | ||
| 90 | 42 | ||
| 91 | namespace kodi | 43 | //============================================================================== |
| 92 | { | 44 | // see gui/definition.h for use of group "cpp_kodi_gui_windows_controls_CEdit_Defs" |
| 93 | namespace gui | 45 | /// |
| 94 | { | 46 | /// @defgroup cpp_kodi_gui_windows_controls_CEdit_Defs Definitions, structures and enumerators |
| 95 | namespace controls | 47 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit |
| 96 | { | 48 | /// @brief **Library definition values** |
| 49 | /// | ||
| 97 | 50 | ||
| 98 | class ATTRIBUTE_HIDDEN CEdit : public CAddonGUIControlBase | 51 | class ATTRIBUTE_HIDDEN CEdit : public CAddonGUIControlBase |
| 99 | { | 52 | { |
| 100 | public: | 53 | public: |
| 101 | //========================================================================== | 54 | //============================================================================ |
| 102 | /// | 55 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit |
| 103 | /// \ingroup cpp_kodi_gui_controls_CEdit | 56 | /// @brief Construct a new control. |
| 104 | /// @brief Construct a new control | ||
| 105 | /// | 57 | /// |
| 106 | /// @param[in] window related window control class | 58 | /// @param[in] window Related window control class |
| 107 | /// @param[in] controlId Used skin xml control id | 59 | /// @param[in] controlId Used skin xml control id |
| 108 | /// | 60 | /// |
| 109 | CEdit(CWindow* window, int controlId) : CAddonGUIControlBase(window) | 61 | CEdit(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 110 | { | 62 | { |
| @@ -114,64 +66,59 @@ public: | |||
| 114 | kodi::Log(ADDON_LOG_FATAL, | 66 | kodi::Log(ADDON_LOG_FATAL, |
| 115 | "kodi::gui::control::CEdit can't create control class from Kodi !!!"); | 67 | "kodi::gui::control::CEdit can't create control class from Kodi !!!"); |
| 116 | } | 68 | } |
| 117 | //-------------------------------------------------------------------------- | 69 | //---------------------------------------------------------------------------- |
| 118 | 70 | ||
| 119 | //========================================================================== | 71 | //============================================================================ |
| 120 | /// | 72 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit |
| 121 | /// \ingroup cpp_kodi_gui_controls_CEdit | 73 | /// @brief Destructor. |
| 122 | /// @brief Destructor | ||
| 123 | /// | 74 | /// |
| 124 | ~CEdit() override = default; | 75 | ~CEdit() override = default; |
| 125 | //-------------------------------------------------------------------------- | 76 | //---------------------------------------------------------------------------- |
| 126 | 77 | ||
| 127 | //========================================================================== | 78 | //============================================================================ |
| 128 | /// | 79 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit |
| 129 | /// \ingroup cpp_kodi_gui_controls_CEdit | 80 | /// @brief Set the control on window to visible. |
| 130 | /// @brief Set the control on window to visible | ||
| 131 | /// | 81 | /// |
| 132 | /// @param[in] visible If true visible, otherwise hidden | 82 | /// @param[in] visible If true visible, otherwise hidden |
| 133 | /// | 83 | /// |
| 134 | void SetVisible(bool visible) | 84 | void SetVisible(bool visible) |
| 135 | { | 85 | { |
| 136 | m_interface->kodi_gui->control_edit->set_visible(m_interface->kodiBase, m_controlHandle, | 86 | m_interface->kodi_gui->control_edit->set_visible(m_interface->kodiBase, m_controlHandle, |
| 137 | visible); | 87 | visible); |
| 138 | } | 88 | } |
| 139 | //-------------------------------------------------------------------------- | 89 | //---------------------------------------------------------------------------- |
| 140 | 90 | ||
| 141 | //========================================================================== | 91 | //============================================================================ |
| 142 | /// | 92 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit |
| 143 | /// \ingroup cpp_kodi_gui_controls_CEdit | 93 | /// @brief Set's the control's enabled/disabled state. |
| 144 | /// @brief Set's the control's enabled/disabled state | ||
| 145 | /// | 94 | /// |
| 146 | /// @param[in] enabled If true enabled, otherwise disabled | 95 | /// @param[in] enabled If true enabled, otherwise disabled |
| 147 | /// | 96 | /// |
| 148 | void SetEnabled(bool enabled) | 97 | void SetEnabled(bool enabled) |
| 149 | { | 98 | { |
| 150 | m_interface->kodi_gui->control_edit->set_enabled(m_interface->kodiBase, m_controlHandle, | 99 | m_interface->kodi_gui->control_edit->set_enabled(m_interface->kodiBase, m_controlHandle, |
| 151 | enabled); | 100 | enabled); |
| 152 | } | 101 | } |
| 153 | //-------------------------------------------------------------------------- | 102 | //---------------------------------------------------------------------------- |
| 154 | 103 | ||
| 155 | //========================================================================== | 104 | //============================================================================ |
| 156 | /// | 105 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit |
| 157 | /// \ingroup cpp_kodi_gui_controls_CEdit | 106 | /// @brief To set the text string on edit control. |
| 158 | /// @brief To set the text string on edit control | ||
| 159 | /// | 107 | /// |
| 160 | /// @param[in] label Text to show | 108 | /// @param[in] label Text to show |
| 161 | /// | 109 | /// |
| 162 | void SetLabel(const std::string& label) | 110 | void SetLabel(const std::string& label) |
| 163 | { | 111 | { |
| 164 | m_interface->kodi_gui->control_edit->set_label(m_interface->kodiBase, m_controlHandle, | 112 | m_interface->kodi_gui->control_edit->set_label(m_interface->kodiBase, m_controlHandle, |
| 165 | label.c_str()); | 113 | label.c_str()); |
| 166 | } | 114 | } |
| 167 | //-------------------------------------------------------------------------- | 115 | //---------------------------------------------------------------------------- |
| 168 | 116 | ||
| 169 | //========================================================================== | 117 | //============================================================================ |
| 170 | /// | 118 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit |
| 171 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 172 | /// @brief Returns the text heading for this edit control. | 119 | /// @brief Returns the text heading for this edit control. |
| 173 | /// | 120 | /// |
| 174 | /// @return Heading text | 121 | /// @return Heading text |
| 175 | /// | 122 | /// |
| 176 | std::string GetLabel() const | 123 | std::string GetLabel() const |
| 177 | { | 124 | { |
| @@ -186,11 +133,10 @@ public: | |||
| 186 | } | 133 | } |
| 187 | return label; | 134 | return label; |
| 188 | } | 135 | } |
| 189 | //-------------------------------------------------------------------------- | 136 | //---------------------------------------------------------------------------- |
| 190 | 137 | ||
| 191 | //========================================================================== | 138 | //============================================================================ |
| 192 | /// | 139 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit |
| 193 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 194 | /// @brief Set's text heading for this edit control. | 140 | /// @brief Set's text heading for this edit control. |
| 195 | /// | 141 | /// |
| 196 | /// @param[in] text string or unicode - text string. | 142 | /// @param[in] text string or unicode - text string. |
| @@ -200,14 +146,13 @@ public: | |||
| 200 | m_interface->kodi_gui->control_edit->set_text(m_interface->kodiBase, m_controlHandle, | 146 | m_interface->kodi_gui->control_edit->set_text(m_interface->kodiBase, m_controlHandle, |
| 201 | text.c_str()); | 147 | text.c_str()); |
| 202 | } | 148 | } |
| 203 | //-------------------------------------------------------------------------- | 149 | //---------------------------------------------------------------------------- |
| 204 | 150 | ||
| 205 | //========================================================================== | 151 | //============================================================================ |
| 206 | /// | 152 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit |
| 207 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 208 | /// @brief Returns the text value for this edit control. | 153 | /// @brief Returns the text value for this edit control. |
| 209 | /// | 154 | /// |
| 210 | /// @return Text value of control | 155 | /// @return Text value of control |
| 211 | /// | 156 | /// |
| 212 | std::string GetText() const | 157 | std::string GetText() const |
| 213 | { | 158 | { |
| @@ -222,54 +167,51 @@ public: | |||
| 222 | } | 167 | } |
| 223 | return text; | 168 | return text; |
| 224 | } | 169 | } |
| 225 | //-------------------------------------------------------------------------- | 170 | //---------------------------------------------------------------------------- |
| 226 | 171 | ||
| 227 | //========================================================================== | 172 | //============================================================================ |
| 228 | /// | 173 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit |
| 229 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 230 | /// @brief Set the cursor position on text. | 174 | /// @brief Set the cursor position on text. |
| 231 | /// | 175 | /// |
| 232 | /// @param[in] iPosition The position to set | 176 | /// @param[in] position The position to set |
| 233 | /// | 177 | /// |
| 234 | void SetCursorPosition(unsigned int iPosition) | 178 | void SetCursorPosition(unsigned int position) |
| 235 | { | 179 | { |
| 236 | m_interface->kodi_gui->control_edit->set_cursor_position(m_interface->kodiBase, m_controlHandle, | 180 | m_interface->kodi_gui->control_edit->set_cursor_position(m_interface->kodiBase, m_controlHandle, |
| 237 | iPosition); | 181 | position); |
| 238 | } | 182 | } |
| 239 | //-------------------------------------------------------------------------- | 183 | //---------------------------------------------------------------------------- |
| 240 | 184 | ||
| 241 | //========================================================================== | 185 | //============================================================================ |
| 242 | /// | 186 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit |
| 243 | /// \ingroup cpp_kodi_gui_controls_CEdit | 187 | /// @brief To get current cursor position on text field. |
| 244 | /// @brief To get current cursor position on text field | ||
| 245 | /// | 188 | /// |
| 246 | /// @return The current cursor position | 189 | /// @return The current cursor position |
| 247 | /// | 190 | /// |
| 248 | unsigned int GetCursorPosition() | 191 | unsigned int GetCursorPosition() |
| 249 | { | 192 | { |
| 250 | return m_interface->kodi_gui->control_edit->get_cursor_position(m_interface->kodiBase, | 193 | return m_interface->kodi_gui->control_edit->get_cursor_position(m_interface->kodiBase, |
| 251 | m_controlHandle); | 194 | m_controlHandle); |
| 252 | } | 195 | } |
| 253 | //-------------------------------------------------------------------------- | 196 | //---------------------------------------------------------------------------- |
| 254 | 197 | ||
| 255 | //========================================================================== | 198 | //============================================================================ |
| 256 | /// | 199 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit |
| 257 | /// \ingroup cpp_kodi_gui_controls_CEdit | 200 | /// @brief To set field input type which are defined on @ref AddonGUIInputType. |
| 258 | /// @brief To set field input type which are defined on \ref AddonGUIInputType | ||
| 259 | /// | 201 | /// |
| 260 | /// @param[in] type The \ref AddonGUIInputType "Add-on input type" | 202 | /// @param[in] type The @ref AddonGUIInputType "Add-on input type" to use |
| 261 | /// to use | 203 | /// @param[in] heading The heading text for related keyboard dialog |
| 262 | /// @param[in] heading The heading text for related keyboard | ||
| 263 | /// dialog | ||
| 264 | /// | 204 | /// |
| 265 | void SetInputType(AddonGUIInputType type, const std::string& heading) | 205 | void SetInputType(AddonGUIInputType type, const std::string& heading) |
| 266 | { | 206 | { |
| 267 | m_interface->kodi_gui->control_edit->set_input_type(m_interface->kodiBase, m_controlHandle, | 207 | m_interface->kodi_gui->control_edit->set_input_type(m_interface->kodiBase, m_controlHandle, |
| 268 | static_cast<int>(type), heading.c_str()); | 208 | static_cast<int>(type), heading.c_str()); |
| 269 | } | 209 | } |
| 270 | //-------------------------------------------------------------------------- | 210 | //---------------------------------------------------------------------------- |
| 271 | }; | 211 | }; |
| 272 | 212 | ||
| 273 | } /* namespace controls */ | 213 | } /* namespace controls */ |
| 274 | } /* namespace gui */ | 214 | } /* namespace gui */ |
| 275 | } /* namespace kodi */ | 215 | } /* namespace kodi */ |
| 216 | |||
| 217 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/FadeLabel.h index 02c843f..01847fb 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/FadeLabel.h | |||
| @@ -8,9 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../../AddonBase.h" | 11 | #include "../../c-api/gui/controls/fade_label.h" |
| 12 | #include "../Window.h" | 12 | #include "../Window.h" |
| 13 | 13 | ||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 14 | namespace kodi | 16 | namespace kodi |
| 15 | { | 17 | { |
| 16 | namespace gui | 18 | namespace gui |
| @@ -18,40 +20,38 @@ namespace gui | |||
| 18 | namespace controls | 20 | namespace controls |
| 19 | { | 21 | { |
| 20 | 22 | ||
| 21 | //============================================================================ | 23 | //============================================================================== |
| 22 | /// | 24 | /// @defgroup cpp_kodi_gui_windows_controls_CFadeLabel Control Fade Label |
| 23 | /// \defgroup cpp_kodi_gui_controls_CFadeLabel Control Fade Label | 25 | /// @ingroup cpp_kodi_gui_windows_controls |
| 24 | /// \ingroup cpp_kodi_gui | 26 | /// @brief @cpp_class{ kodi::gui::controls::CFadeLabel } |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CFadeLabel } | ||
| 26 | /// **Window control used to show multiple pieces of text in the same position, | 27 | /// **Window control used to show multiple pieces of text in the same position, |
| 27 | /// by fading from one to the other** | 28 | /// by fading from one to the other**\n |
| 29 | /// The fade label control is used for displaying multiple pieces of text in | ||
| 30 | /// the same space in Kodi. | ||
| 28 | /// | 31 | /// |
| 29 | /// The fade label control is used for displaying multiple pieces of text in | 32 | /// You can choose the font, size, colour, location and contents of the text to |
| 30 | /// the same space in Kodi. You can choose the font, size, colour, location | 33 | /// be displayed. The first piece of information to display fades in over 50 |
| 31 | /// and contents of the text to be displayed. The first piece of information | 34 | /// frames, then scrolls off to the left. Once it is finished scrolling off |
| 32 | /// to display fades in over 50 frames, then scrolls off to the left. Once it | 35 | /// screen, the second piece of information fades in and the process repeats. |
| 33 | /// is finished scrolling off screen, the second piece of information fades | 36 | /// A fade label control is not supported in a list container. |
| 34 | /// in and the process repeats. A fade label control is not supported in a | ||
| 35 | /// list container. | ||
| 36 | /// | 37 | /// |
| 37 | /// It has the header \ref FadeLabel.h "#include <kodi/gui/controls/FadeLabel.h>" | 38 | /// It has the header @ref FadeLabel.h "#include <kodi/gui/controls/FadeLabel.h>" |
| 38 | /// be included to enjoy it. | 39 | /// be included to enjoy it. |
| 39 | /// | 40 | /// |
| 40 | /// Here you find the needed skin part for a \ref Fade_Label_Control "fade label control" | 41 | /// Here you find the needed skin part for a @ref Fade_Label_Control "fade label control". |
| 41 | /// | 42 | /// |
| 42 | /// @note The call of the control is only possible from the corresponding | 43 | /// @note The call of the control is only possible from the corresponding |
| 43 | /// window as its class and identification number is required. | 44 | /// window as its class and identification number is required. |
| 44 | /// | 45 | /// |
| 45 | class ATTRIBUTE_HIDDEN CFadeLabel : public CAddonGUIControlBase | 46 | class ATTRIBUTE_HIDDEN CFadeLabel : public CAddonGUIControlBase |
| 46 | { | 47 | { |
| 47 | public: | 48 | public: |
| 48 | //========================================================================== | 49 | //============================================================================ |
| 49 | /// | 50 | /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel |
| 50 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | ||
| 51 | /// @brief Construct a new control. | 51 | /// @brief Construct a new control. |
| 52 | /// | 52 | /// |
| 53 | /// @param[in] window related window control class | 53 | /// @param[in] window Related window control class |
| 54 | /// @param[in] controlId Used skin xml control id | 54 | /// @param[in] controlId Used skin xml control id |
| 55 | /// | 55 | /// |
| 56 | CFadeLabel(CWindow* window, int controlId) : CAddonGUIControlBase(window) | 56 | CFadeLabel(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 57 | { | 57 | { |
| @@ -61,50 +61,46 @@ public: | |||
| 61 | kodi::Log(ADDON_LOG_FATAL, | 61 | kodi::Log(ADDON_LOG_FATAL, |
| 62 | "kodi::gui::controls::CFadeLabel can't create control class from Kodi !!!"); | 62 | "kodi::gui::controls::CFadeLabel can't create control class from Kodi !!!"); |
| 63 | } | 63 | } |
| 64 | //-------------------------------------------------------------------------- | 64 | //---------------------------------------------------------------------------- |
| 65 | 65 | ||
| 66 | //========================================================================== | 66 | //============================================================================ |
| 67 | /// | 67 | /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel |
| 68 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | ||
| 69 | /// @brief Destructor. | 68 | /// @brief Destructor. |
| 70 | /// | 69 | /// |
| 71 | ~CFadeLabel() override = default; | 70 | ~CFadeLabel() override = default; |
| 72 | //-------------------------------------------------------------------------- | 71 | //---------------------------------------------------------------------------- |
| 73 | 72 | ||
| 74 | //========================================================================== | 73 | //============================================================================ |
| 75 | /// | 74 | /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel |
| 76 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | ||
| 77 | /// @brief Set the control on window to visible. | 75 | /// @brief Set the control on window to visible. |
| 78 | /// | 76 | /// |
| 79 | /// @param[in] visible If true visible, otherwise hidden | 77 | /// @param[in] visible If true visible, otherwise hidden |
| 80 | /// | 78 | /// |
| 81 | void SetVisible(bool visible) | 79 | void SetVisible(bool visible) |
| 82 | { | 80 | { |
| 83 | m_interface->kodi_gui->control_fade_label->set_visible(m_interface->kodiBase, m_controlHandle, | 81 | m_interface->kodi_gui->control_fade_label->set_visible(m_interface->kodiBase, m_controlHandle, |
| 84 | visible); | 82 | visible); |
| 85 | } | 83 | } |
| 86 | //-------------------------------------------------------------------------- | 84 | //---------------------------------------------------------------------------- |
| 87 | 85 | ||
| 88 | //========================================================================== | 86 | //============================================================================ |
| 89 | /// | 87 | /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel |
| 90 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | ||
| 91 | /// @brief To add additional text string on fade label. | 88 | /// @brief To add additional text string on fade label. |
| 92 | /// | 89 | /// |
| 93 | /// @param[in] label Text to show | 90 | /// @param[in] label Text to show |
| 94 | /// | 91 | /// |
| 95 | void AddLabel(const std::string& label) | 92 | void AddLabel(const std::string& label) |
| 96 | { | 93 | { |
| 97 | m_interface->kodi_gui->control_fade_label->add_label(m_interface->kodiBase, m_controlHandle, | 94 | m_interface->kodi_gui->control_fade_label->add_label(m_interface->kodiBase, m_controlHandle, |
| 98 | label.c_str()); | 95 | label.c_str()); |
| 99 | } | 96 | } |
| 100 | //-------------------------------------------------------------------------- | 97 | //---------------------------------------------------------------------------- |
| 101 | 98 | ||
| 102 | //========================================================================== | 99 | //============================================================================ |
| 103 | /// | 100 | /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel |
| 104 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | 101 | /// @brief Get the used text from button. |
| 105 | /// @brief Get the used text from button | ||
| 106 | /// | 102 | /// |
| 107 | /// @return Text shown | 103 | /// @return Text shown |
| 108 | /// | 104 | /// |
| 109 | std::string GetLabel() const | 105 | std::string GetLabel() const |
| 110 | { | 106 | { |
| @@ -119,35 +115,34 @@ public: | |||
| 119 | } | 115 | } |
| 120 | return label; | 116 | return label; |
| 121 | } | 117 | } |
| 122 | //-------------------------------------------------------------------------- | 118 | //---------------------------------------------------------------------------- |
| 123 | 119 | ||
| 124 | //========================================================================== | 120 | //============================================================================ |
| 125 | /// | 121 | /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel |
| 126 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | 122 | /// @brief To enable or disable scrolling on fade label. |
| 127 | /// @brief To enable or disable scrolling on fade label | ||
| 128 | /// | 123 | /// |
| 129 | /// @param[in] scroll To enable scrolling set to true, otherwise is | 124 | /// @param[in] scroll To enable scrolling set to true, otherwise is disabled |
| 130 | /// disabled | ||
| 131 | /// | 125 | /// |
| 132 | void SetScrolling(bool scroll) | 126 | void SetScrolling(bool scroll) |
| 133 | { | 127 | { |
| 134 | m_interface->kodi_gui->control_fade_label->set_scrolling(m_interface->kodiBase, m_controlHandle, | 128 | m_interface->kodi_gui->control_fade_label->set_scrolling(m_interface->kodiBase, m_controlHandle, |
| 135 | scroll); | 129 | scroll); |
| 136 | } | 130 | } |
| 137 | //-------------------------------------------------------------------------- | 131 | //---------------------------------------------------------------------------- |
| 138 | 132 | ||
| 139 | //========================================================================== | 133 | //============================================================================ |
| 140 | /// | 134 | /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel |
| 141 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | ||
| 142 | /// @brief To reset al inserted labels. | 135 | /// @brief To reset al inserted labels. |
| 143 | /// | 136 | /// |
| 144 | void Reset() | 137 | void Reset() |
| 145 | { | 138 | { |
| 146 | m_interface->kodi_gui->control_fade_label->reset(m_interface->kodiBase, m_controlHandle); | 139 | m_interface->kodi_gui->control_fade_label->reset(m_interface->kodiBase, m_controlHandle); |
| 147 | } | 140 | } |
| 148 | //-------------------------------------------------------------------------- | 141 | //---------------------------------------------------------------------------- |
| 149 | }; | 142 | }; |
| 150 | 143 | ||
| 151 | } /* namespace controls */ | 144 | } /* namespace controls */ |
| 152 | } /* namespace gui */ | 145 | } /* namespace gui */ |
| 153 | } /* namespace kodi */ | 146 | } /* namespace kodi */ |
| 147 | |||
| 148 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Image.h index b4d092f..9dc493e 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Image.h | |||
| @@ -8,9 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../../AddonBase.h" | 11 | #include "../../c-api/gui/controls/image.h" |
| 12 | #include "../Window.h" | 12 | #include "../Window.h" |
| 13 | 13 | ||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 14 | namespace kodi | 16 | namespace kodi |
| 15 | { | 17 | { |
| 16 | namespace gui | 18 | namespace gui |
| @@ -19,33 +21,30 @@ namespace controls | |||
| 19 | { | 21 | { |
| 20 | 22 | ||
| 21 | //============================================================================ | 23 | //============================================================================ |
| 22 | /// | 24 | /// @defgroup cpp_kodi_gui_windows_controls_CImage Control Image |
| 23 | /// \defgroup cpp_kodi_gui_controls_CImage Control Image | 25 | /// @ingroup cpp_kodi_gui_windows_controls |
| 24 | /// \ingroup cpp_kodi_gui | 26 | /// @brief @cpp_class{ kodi::gui::controls::CImage } |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CImage } | 27 | /// **Window control used to show an image.**\n |
| 26 | /// **Window control used to show an image.** | 28 | /// The image control is used for displaying images in Kodi. You can choose |
| 27 | /// | ||
| 28 | /// The image control is used for displaying images in Kodi. You can choose | ||
| 29 | /// the position, size, transparency and contents of the image to be displayed. | 29 | /// the position, size, transparency and contents of the image to be displayed. |
| 30 | /// | 30 | /// |
| 31 | /// It has the header \ref Image.h "#include <kodi/gui/controls/Image.h>" | 31 | /// It has the header @ref Image.h "#include <kodi/gui/controls/Image.h>" |
| 32 | /// be included to enjoy it. | 32 | /// be included to enjoy it. |
| 33 | /// | 33 | /// |
| 34 | /// Here you find the needed skin part for a \ref Image_Control "image control" | 34 | /// Here you find the needed skin part for a @ref Image_Control "image control". |
| 35 | /// | 35 | /// |
| 36 | /// @note The call of the control is only possible from the corresponding | 36 | /// @note The call of the control is only possible from the corresponding |
| 37 | /// window as its class and identification number is required. | 37 | /// window as its class and identification number is required. |
| 38 | /// | 38 | /// |
| 39 | class ATTRIBUTE_HIDDEN CImage : public CAddonGUIControlBase | 39 | class ATTRIBUTE_HIDDEN CImage : public CAddonGUIControlBase |
| 40 | { | 40 | { |
| 41 | public: | 41 | public: |
| 42 | //========================================================================== | 42 | //========================================================================== |
| 43 | /// @ingroup cpp_kodi_gui_windows_controls_CImage | ||
| 44 | /// @brief Construct a new control. | ||
| 43 | /// | 45 | /// |
| 44 | /// \ingroup cpp_kodi_gui_controls_CImage | 46 | /// @param[in] window Related window control class |
| 45 | /// @brief Construct a new control | 47 | /// @param[in] controlId Used skin xml control id |
| 46 | /// | ||
| 47 | /// @param[in] window related window control class | ||
| 48 | /// @param[in] controlId Used skin xml control id | ||
| 49 | /// | 48 | /// |
| 50 | CImage(CWindow* window, int controlId) : CAddonGUIControlBase(window) | 49 | CImage(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 51 | { | 50 | { |
| @@ -58,19 +57,17 @@ public: | |||
| 58 | //-------------------------------------------------------------------------- | 57 | //-------------------------------------------------------------------------- |
| 59 | 58 | ||
| 60 | //========================================================================== | 59 | //========================================================================== |
| 61 | /// | 60 | /// @ingroup cpp_kodi_gui_windows_controls_CImage |
| 62 | /// \ingroup cpp_kodi_gui_controls_CImage | 61 | /// @brief Destructor. |
| 63 | /// @brief Destructor | ||
| 64 | /// | 62 | /// |
| 65 | ~CImage() override = default; | 63 | ~CImage() override = default; |
| 66 | //-------------------------------------------------------------------------- | 64 | //-------------------------------------------------------------------------- |
| 67 | 65 | ||
| 68 | //========================================================================== | 66 | //========================================================================== |
| 67 | /// @ingroup cpp_kodi_gui_windows_controls_CImage | ||
| 68 | /// @brief Set the control on window to visible. | ||
| 69 | /// | 69 | /// |
| 70 | /// \ingroup cpp_kodi_gui_controls_CImage | 70 | /// @param[in] visible If true visible, otherwise hidden |
| 71 | /// @brief Set the control on window to visible | ||
| 72 | /// | ||
| 73 | /// @param[in] visible If true visible, otherwise hidden | ||
| 74 | /// | 71 | /// |
| 75 | void SetVisible(bool visible) | 72 | void SetVisible(bool visible) |
| 76 | { | 73 | { |
| @@ -80,14 +77,12 @@ public: | |||
| 80 | //-------------------------------------------------------------------------- | 77 | //-------------------------------------------------------------------------- |
| 81 | 78 | ||
| 82 | //========================================================================== | 79 | //========================================================================== |
| 83 | /// | 80 | /// @ingroup cpp_kodi_gui_windows_controls_CImage |
| 84 | /// \ingroup cpp_kodi_gui_controls_CImage | ||
| 85 | /// @brief To set the filename used on image control. | 81 | /// @brief To set the filename used on image control. |
| 86 | /// | 82 | /// |
| 87 | /// @param[in] filename Image file to use | 83 | /// @param[in] filename Image file to use |
| 88 | /// @param[in] useCache To define storage of image, default is | 84 | /// @param[in] useCache To define storage of image, default is in cache, if |
| 89 | /// in cache, if false becomes it loaded | 85 | /// false becomes it loaded always on changes again |
| 90 | /// always on changes again | ||
| 91 | /// | 86 | /// |
| 92 | void SetFileName(const std::string& filename, bool useCache = true) | 87 | void SetFileName(const std::string& filename, bool useCache = true) |
| 93 | { | 88 | { |
| @@ -97,11 +92,10 @@ public: | |||
| 97 | //-------------------------------------------------------------------------- | 92 | //-------------------------------------------------------------------------- |
| 98 | 93 | ||
| 99 | //========================================================================== | 94 | //========================================================================== |
| 100 | /// | 95 | /// @ingroup cpp_kodi_gui_windows_controls_CImage |
| 101 | /// \ingroup cpp_kodi_gui_controls_CImage | ||
| 102 | /// @brief To set set the diffuse color on image. | 96 | /// @brief To set set the diffuse color on image. |
| 103 | /// | 97 | /// |
| 104 | /// @param[in] colorDiffuse Color to use for diffuse | 98 | /// @param[in] colorDiffuse Color to use for diffuse |
| 105 | /// | 99 | /// |
| 106 | void SetColorDiffuse(uint32_t colorDiffuse) | 100 | void SetColorDiffuse(uint32_t colorDiffuse) |
| 107 | { | 101 | { |
| @@ -114,3 +108,5 @@ public: | |||
| 114 | } /* namespace controls */ | 108 | } /* namespace controls */ |
| 115 | } /* namespace gui */ | 109 | } /* namespace gui */ |
| 116 | } /* namespace kodi */ | 110 | } /* namespace kodi */ |
| 111 | |||
| 112 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Label.h index 82604bd..d10b85f 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Label.h | |||
| @@ -8,9 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../../AddonBase.h" | 11 | #include "../../c-api/gui/controls/label.h" |
| 12 | #include "../Window.h" | 12 | #include "../Window.h" |
| 13 | 13 | ||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 14 | namespace kodi | 16 | namespace kodi |
| 15 | { | 17 | { |
| 16 | namespace gui | 18 | namespace gui |
| @@ -18,34 +20,31 @@ namespace gui | |||
| 18 | namespace controls | 20 | namespace controls |
| 19 | { | 21 | { |
| 20 | 22 | ||
| 21 | //============================================================================ | 23 | //============================================================================== |
| 22 | /// | 24 | /// @defgroup cpp_kodi_gui_windows_controls_CLabel Control Label |
| 23 | /// \defgroup cpp_kodi_gui_controls_CLabel Control Label | 25 | /// @ingroup cpp_kodi_gui_windows_controls |
| 24 | /// \ingroup cpp_kodi_gui | 26 | /// @brief @cpp_class{ kodi::gui::controls::CLabel } |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CLabel } | 27 | /// **Window control used to show some lines of text**\n |
| 26 | /// **Window control used to show some lines of text.** | 28 | /// The label control is used for displaying text in Kodi. You can choose |
| 27 | /// | ||
| 28 | /// The label control is used for displaying text in Kodi. You can choose | ||
| 29 | /// the font, size, colour, location and contents of the text to be displayed. | 29 | /// the font, size, colour, location and contents of the text to be displayed. |
| 30 | /// | 30 | /// |
| 31 | /// It has the header \ref Label.h "#include <kodi/gui/controls/Label.h>" | 31 | /// It has the header @ref Label.h "#include <kodi/gui/controls/Label.h>" |
| 32 | /// be included to enjoy it. | 32 | /// be included to enjoy it. |
| 33 | /// | 33 | /// |
| 34 | /// Here you find the needed skin part for a \ref Label_Control "label control" | 34 | /// Here you find the needed skin part for a @ref Label_Control "label control". |
| 35 | /// | 35 | /// |
| 36 | /// @note The call of the control is only possible from the corresponding | 36 | /// @note The call of the control is only possible from the corresponding |
| 37 | /// window as its class and identification number is required. | 37 | /// window as its class and identification number is required. |
| 38 | /// | 38 | /// |
| 39 | class ATTRIBUTE_HIDDEN CLabel : public CAddonGUIControlBase | 39 | class ATTRIBUTE_HIDDEN CLabel : public CAddonGUIControlBase |
| 40 | { | 40 | { |
| 41 | public: | 41 | public: |
| 42 | //========================================================================== | 42 | //============================================================================ |
| 43 | /// @ingroup cpp_kodi_gui_windows_controls_CLabel | ||
| 44 | /// @brief Construct a new control. | ||
| 43 | /// | 45 | /// |
| 44 | /// \ingroup cpp_kodi_gui_controls_CLabel | 46 | /// @param[in] window Related window control class |
| 45 | /// @brief Construct a new control | 47 | /// @param[in] controlId Used skin xml control id |
| 46 | /// | ||
| 47 | /// @param[in] window related window control class | ||
| 48 | /// @param[in] controlId Used skin xml control id | ||
| 49 | /// | 48 | /// |
| 50 | CLabel(CWindow* window, int controlId) : CAddonGUIControlBase(window) | 49 | CLabel(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 51 | { | 50 | { |
| @@ -55,50 +54,46 @@ public: | |||
| 55 | kodi::Log(ADDON_LOG_FATAL, | 54 | kodi::Log(ADDON_LOG_FATAL, |
| 56 | "kodi::gui::controls::CLabel can't create control class from Kodi !!!"); | 55 | "kodi::gui::controls::CLabel can't create control class from Kodi !!!"); |
| 57 | } | 56 | } |
| 58 | //-------------------------------------------------------------------------- | 57 | //---------------------------------------------------------------------------- |
| 59 | 58 | ||
| 60 | //========================================================================== | 59 | //============================================================================ |
| 61 | /// | 60 | /// @ingroup cpp_kodi_gui_windows_controls_CLabel |
| 62 | /// \ingroup cpp_kodi_gui_controls_CLabel | 61 | /// @brief Destructor. |
| 63 | /// @brief Destructor | ||
| 64 | /// | 62 | /// |
| 65 | ~CLabel() override = default; | 63 | ~CLabel() override = default; |
| 66 | //-------------------------------------------------------------------------- | 64 | //---------------------------------------------------------------------------- |
| 67 | 65 | ||
| 68 | //========================================================================== | 66 | //============================================================================ |
| 67 | /// @ingroup cpp_kodi_gui_windows_controls_CLabel | ||
| 68 | /// @brief Set the control on window to visible. | ||
| 69 | /// | 69 | /// |
| 70 | /// \ingroup cpp_kodi_gui_controls_CLabel | 70 | /// @param[in] visible If true visible, otherwise hidden |
| 71 | /// @brief Set the control on window to visible | ||
| 72 | /// | ||
| 73 | /// @param[in] visible If true visible, otherwise hidden | ||
| 74 | /// | 71 | /// |
| 75 | void SetVisible(bool visible) | 72 | void SetVisible(bool visible) |
| 76 | { | 73 | { |
| 77 | m_interface->kodi_gui->control_label->set_visible(m_interface->kodiBase, m_controlHandle, | 74 | m_interface->kodi_gui->control_label->set_visible(m_interface->kodiBase, m_controlHandle, |
| 78 | visible); | 75 | visible); |
| 79 | } | 76 | } |
| 80 | //-------------------------------------------------------------------------- | 77 | //---------------------------------------------------------------------------- |
| 81 | 78 | ||
| 82 | //========================================================================== | 79 | //============================================================================ |
| 83 | /// | 80 | /// @ingroup cpp_kodi_gui_windows_controls_CLabel |
| 84 | /// \ingroup cpp_kodi_gui_controls_CLabel | 81 | /// @brief To set the text string on label. |
| 85 | /// @brief To set the text string on label | ||
| 86 | /// | 82 | /// |
| 87 | /// @param[in] text Text to show | 83 | /// @param[in] text Text to show |
| 88 | /// | 84 | /// |
| 89 | void SetLabel(const std::string& text) | 85 | void SetLabel(const std::string& text) |
| 90 | { | 86 | { |
| 91 | m_interface->kodi_gui->control_label->set_label(m_interface->kodiBase, m_controlHandle, | 87 | m_interface->kodi_gui->control_label->set_label(m_interface->kodiBase, m_controlHandle, |
| 92 | text.c_str()); | 88 | text.c_str()); |
| 93 | } | 89 | } |
| 94 | //-------------------------------------------------------------------------- | 90 | //---------------------------------------------------------------------------- |
| 95 | 91 | ||
| 96 | //========================================================================== | 92 | //============================================================================ |
| 93 | /// @ingroup cpp_kodi_gui_windows_controls_CLabel | ||
| 94 | /// @brief Get the used text from control. | ||
| 97 | /// | 95 | /// |
| 98 | /// \ingroup cpp_kodi_gui_controls_CLabel | 96 | /// @return Used text on label control |
| 99 | /// @brief Get the used text from control | ||
| 100 | /// | ||
| 101 | /// @return Used text on label control | ||
| 102 | /// | 97 | /// |
| 103 | std::string GetLabel() const | 98 | std::string GetLabel() const |
| 104 | { | 99 | { |
| @@ -113,9 +108,11 @@ public: | |||
| 113 | } | 108 | } |
| 114 | return label; | 109 | return label; |
| 115 | } | 110 | } |
| 116 | //-------------------------------------------------------------------------- | 111 | //---------------------------------------------------------------------------- |
| 117 | }; | 112 | }; |
| 118 | 113 | ||
| 119 | } /* namespace controls */ | 114 | } /* namespace controls */ |
| 120 | } /* namespace gui */ | 115 | } /* namespace gui */ |
| 121 | } /* namespace kodi */ | 116 | } /* namespace kodi */ |
| 117 | |||
| 118 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Progress.h index 8cb582b..83b16aa 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Progress.h | |||
| @@ -8,9 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../../AddonBase.h" | 11 | #include "../../c-api/gui/controls/progress.h" |
| 12 | #include "../Window.h" | 12 | #include "../Window.h" |
| 13 | 13 | ||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 14 | namespace kodi | 16 | namespace kodi |
| 15 | { | 17 | { |
| 16 | namespace gui | 18 | namespace gui |
| @@ -18,21 +20,20 @@ namespace gui | |||
| 18 | namespace controls | 20 | namespace controls |
| 19 | { | 21 | { |
| 20 | 22 | ||
| 21 | //============================================================================ | 23 | //============================================================================== |
| 22 | /// | 24 | /// @defgroup cpp_kodi_gui_windows_controls_CProgress Control Progress |
| 23 | /// \defgroup cpp_kodi_gui_controls_CProgress Control Progress | 25 | /// @ingroup cpp_kodi_gui_windows_controls |
| 24 | /// \ingroup cpp_kodi_gui | 26 | /// @brief @cpp_class{ kodi::gui::controls::CProgress } |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CProgress } | 27 | /// **Window control to show the progress of a particular operation**\n |
| 26 | /// **Window control to show the progress of a particular operation** | ||
| 27 | /// | ||
| 28 | /// The progress control is used to show the progress of an item that may take | 28 | /// The progress control is used to show the progress of an item that may take |
| 29 | /// a long time, or to show how far through a movie you are. You can choose | 29 | /// a long time, or to show how far through a movie you are. |
| 30 | /// the position, size, and look of the progress control. | ||
| 31 | /// | 30 | /// |
| 32 | /// It has the header \ref Progress.h "#include <kodi/gui/controls/Progress.h>" | 31 | /// You can choose the position, size, and look of the progress control. |
| 32 | /// | ||
| 33 | /// It has the header @ref Progress.h "#include <kodi/gui/controls/Progress.h>" | ||
| 33 | /// be included to enjoy it. | 34 | /// be included to enjoy it. |
| 34 | /// | 35 | /// |
| 35 | /// Here you find the needed skin part for a \ref Progress_Control "progress control" | 36 | /// Here you find the needed skin part for a @ref Progress_Control "progress control". |
| 36 | /// | 37 | /// |
| 37 | /// @note The call of the control is only possible from the corresponding | 38 | /// @note The call of the control is only possible from the corresponding |
| 38 | /// window as its class and identification number is required. | 39 | /// window as its class and identification number is required. |
| @@ -40,13 +41,12 @@ namespace controls | |||
| 40 | class ATTRIBUTE_HIDDEN CProgress : public CAddonGUIControlBase | 41 | class ATTRIBUTE_HIDDEN CProgress : public CAddonGUIControlBase |
| 41 | { | 42 | { |
| 42 | public: | 43 | public: |
| 43 | //========================================================================== | 44 | //============================================================================ |
| 44 | /// | 45 | /// @ingroup cpp_kodi_gui_windows_controls_CProgress |
| 45 | /// \ingroup cpp_kodi_gui_controls_CProgress | 46 | /// @brief Construct a new control. |
| 46 | /// @brief Construct a new control | ||
| 47 | /// | 47 | /// |
| 48 | /// @param[in] window related window control class | 48 | /// @param[in] window Related window control class |
| 49 | /// @param[in] controlId Used skin xml control id | 49 | /// @param[in] controlId Used skin xml control id |
| 50 | /// | 50 | /// |
| 51 | CProgress(CWindow* window, int controlId) : CAddonGUIControlBase(window) | 51 | CProgress(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 52 | { | 52 | { |
| @@ -56,59 +56,57 @@ public: | |||
| 56 | kodi::Log(ADDON_LOG_FATAL, | 56 | kodi::Log(ADDON_LOG_FATAL, |
| 57 | "kodi::gui::controls::CProgress can't create control class from Kodi !!!"); | 57 | "kodi::gui::controls::CProgress can't create control class from Kodi !!!"); |
| 58 | } | 58 | } |
| 59 | //-------------------------------------------------------------------------- | 59 | //---------------------------------------------------------------------------- |
| 60 | 60 | ||
| 61 | //========================================================================== | 61 | //============================================================================ |
| 62 | /// | 62 | /// @ingroup cpp_kodi_gui_windows_controls_CProgress |
| 63 | /// \ingroup cpp_kodi_gui_controls_CProgress | 63 | /// @brief Destructor. |
| 64 | /// @brief Destructor | ||
| 65 | /// | 64 | /// |
| 66 | ~CProgress() override = default; | 65 | ~CProgress() override = default; |
| 67 | //-------------------------------------------------------------------------- | 66 | //---------------------------------------------------------------------------- |
| 68 | 67 | ||
| 69 | //========================================================================== | 68 | //============================================================================ |
| 70 | /// | 69 | /// @ingroup cpp_kodi_gui_windows_controls_CProgress |
| 71 | /// \ingroup cpp_kodi_gui_controls_CProgress | 70 | /// @brief Set the control on window to visible. |
| 72 | /// @brief Set the control on window to visible | ||
| 73 | /// | 71 | /// |
| 74 | /// @param[in] visible If true visible, otherwise hidden | 72 | /// @param[in] visible If true visible, otherwise hidden |
| 75 | /// | 73 | /// |
| 76 | void SetVisible(bool visible) | 74 | void SetVisible(bool visible) |
| 77 | { | 75 | { |
| 78 | m_interface->kodi_gui->control_progress->set_visible(m_interface->kodiBase, m_controlHandle, | 76 | m_interface->kodi_gui->control_progress->set_visible(m_interface->kodiBase, m_controlHandle, |
| 79 | visible); | 77 | visible); |
| 80 | } | 78 | } |
| 81 | //-------------------------------------------------------------------------- | 79 | //---------------------------------------------------------------------------- |
| 82 | 80 | ||
| 83 | //========================================================================== | 81 | //============================================================================ |
| 84 | /// | 82 | /// @ingroup cpp_kodi_gui_windows_controls_CProgress |
| 85 | /// \ingroup cpp_kodi_gui_controls_CProgress | 83 | /// @brief To set Percent position of control. |
| 86 | /// @brief To set Percent position of control | ||
| 87 | /// | 84 | /// |
| 88 | /// @param[in] percent The percent position to use | 85 | /// @param[in] percent The percent position to use |
| 89 | /// | 86 | /// |
| 90 | void SetPercentage(float percent) | 87 | void SetPercentage(float percent) |
| 91 | { | 88 | { |
| 92 | m_interface->kodi_gui->control_progress->set_percentage(m_interface->kodiBase, m_controlHandle, | 89 | m_interface->kodi_gui->control_progress->set_percentage(m_interface->kodiBase, m_controlHandle, |
| 93 | percent); | 90 | percent); |
| 94 | } | 91 | } |
| 95 | //-------------------------------------------------------------------------- | 92 | //---------------------------------------------------------------------------- |
| 96 | 93 | ||
| 97 | //========================================================================== | 94 | //============================================================================ |
| 95 | /// @ingroup cpp_kodi_gui_windows_controls_CProgress | ||
| 96 | /// @brief Get the active percent position of progress bar. | ||
| 98 | /// | 97 | /// |
| 99 | /// \ingroup cpp_kodi_gui_controls_CProgress | 98 | /// @return Progress position as percent |
| 100 | /// @brief Get the active percent position of progress bar | ||
| 101 | /// | ||
| 102 | /// @return Progress position as percent | ||
| 103 | /// | 99 | /// |
| 104 | float GetPercentage() const | 100 | float GetPercentage() const |
| 105 | { | 101 | { |
| 106 | return m_interface->kodi_gui->control_progress->get_percentage(m_interface->kodiBase, | 102 | return m_interface->kodi_gui->control_progress->get_percentage(m_interface->kodiBase, |
| 107 | m_controlHandle); | 103 | m_controlHandle); |
| 108 | } | 104 | } |
| 109 | //-------------------------------------------------------------------------- | 105 | //---------------------------------------------------------------------------- |
| 110 | }; | 106 | }; |
| 111 | 107 | ||
| 112 | } /* namespace controls */ | 108 | } /* namespace controls */ |
| 113 | } /* namespace gui */ | 109 | } /* namespace gui */ |
| 114 | } /* namespace kodi */ | 110 | } /* namespace kodi */ |
| 111 | |||
| 112 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h index 305195d..3b6a23c 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h | |||
| @@ -8,9 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../../AddonBase.h" | 11 | #include "../../c-api/gui/controls/radio_button.h" |
| 12 | #include "../Window.h" | 12 | #include "../Window.h" |
| 13 | 13 | ||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 14 | namespace kodi | 16 | namespace kodi |
| 15 | { | 17 | { |
| 16 | namespace gui | 18 | namespace gui |
| @@ -18,36 +20,87 @@ namespace gui | |||
| 18 | namespace controls | 20 | namespace controls |
| 19 | { | 21 | { |
| 20 | 22 | ||
| 21 | //============================================================================ | 23 | //============================================================================== |
| 22 | /// | 24 | /// @defgroup cpp_kodi_gui_windows_controls_CRadioButton Control Radio Button |
| 23 | /// \defgroup cpp_kodi_gui_controls_CRadioButton Control Radio Button | 25 | /// @ingroup cpp_kodi_gui_windows_controls |
| 24 | /// \ingroup cpp_kodi_gui | 26 | /// @brief @cpp_class{ kodi::gui::controls::CRadioButton } |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CRadioButton } | 27 | /// **Window control for a radio button (as used for on/off settings)**\n |
| 26 | /// **Window control for a radio button (as used for on/off settings)** | 28 | /// The radio button control is used for creating push button on/off settings |
| 29 | /// in Kodi. | ||
| 27 | /// | 30 | /// |
| 28 | /// The radio button control is used for creating push button on/off settings | 31 | /// You can choose the position, size, and look of the button. When the user |
| 29 | /// in Kodi. You can choose the position, size, and look of the button. When | 32 | /// clicks on the radio button, the state will change, toggling the extra |
| 30 | /// the user clicks on the radio button, the state will change, toggling the | 33 | /// textures (textureradioon and textureradiooff). Used for settings |
| 31 | /// extra textures (textureradioon and textureradiooff). Used for settings | ||
| 32 | /// controls. | 34 | /// controls. |
| 33 | /// | 35 | /// |
| 34 | /// It has the header \ref RadioButton.h "#include <kodi/gui/controls/RadioButton.h>" | 36 | /// It has the header @ref RadioButton.h "#include <kodi/gui/controls/RadioButton.h>" |
| 35 | /// be included to enjoy it. | 37 | /// be included to enjoy it. |
| 36 | /// | 38 | /// |
| 37 | /// Here you find the needed skin part for a \ref Radio_button_control "radio button control" | 39 | /// Here you find the needed skin part for a @ref Radio_button_control "radio button control". |
| 38 | /// | 40 | /// |
| 39 | /// @note The call of the control is only possible from the corresponding | 41 | /// @note The call of the control is only possible from the corresponding |
| 40 | /// window as its class and identification number is required. | 42 | /// window as its class and identification number is required. |
| 41 | /// | 43 | /// |
| 44 | /// | ||
| 45 | /// -------------------------------------------------------------------------- | ||
| 46 | /// **Example:** | ||
| 47 | /// ~~~~~~~~~~~~cpp | ||
| 48 | /// #include <kodi/gui/Window.h> | ||
| 49 | /// | ||
| 50 | /// #define MY_RADIO_BUTTON_CONTROL 1 | ||
| 51 | /// | ||
| 52 | /// class CMyWindow : public kodi::gui::CWindow | ||
| 53 | /// { | ||
| 54 | /// public: | ||
| 55 | /// CMyWindow() | ||
| 56 | /// | ||
| 57 | /// void ShowWindow(); | ||
| 58 | /// | ||
| 59 | /// bool OnInit() override; | ||
| 60 | /// bool OnClick(int controlId) override; | ||
| 61 | /// | ||
| 62 | /// private: | ||
| 63 | /// kodi::gui::controls::CSpin m_myRadioButtonControl; | ||
| 64 | /// }; | ||
| 65 | /// | ||
| 66 | /// CMyWindow::CMyWindow() | ||
| 67 | /// : kodi::gui::CWindow("my_skin.xml", "skin.estuary", true, false), | ||
| 68 | /// m_myRadioButtonControl(this, MY_RADIO_BUTTON_CONTROL) | ||
| 69 | /// { | ||
| 70 | /// } | ||
| 71 | /// | ||
| 72 | /// void CMyWindow::ShowWindow() | ||
| 73 | /// { | ||
| 74 | /// kodi::gui::CWindow::DoModal(); | ||
| 75 | /// } | ||
| 76 | /// | ||
| 77 | /// bool CMyWindow::OnInit() | ||
| 78 | /// { | ||
| 79 | /// m_myRadioButtonControl.SetSelected(false); // can also on skin set to default | ||
| 80 | /// return true; | ||
| 81 | /// } | ||
| 82 | /// | ||
| 83 | /// bool CMyWindow::OnClick(int controlId) | ||
| 84 | /// { | ||
| 85 | /// if (controlId == MY_RADIO_BUTTON_CONTROL) | ||
| 86 | /// { | ||
| 87 | /// bool selected = m_myRadioButtonControl.IsSelected(); | ||
| 88 | /// ... | ||
| 89 | /// } | ||
| 90 | /// return true; | ||
| 91 | /// } | ||
| 92 | /// return false; | ||
| 93 | /// } | ||
| 94 | /// ~~~~~~~~~~~~ | ||
| 95 | /// | ||
| 42 | class ATTRIBUTE_HIDDEN CRadioButton : public CAddonGUIControlBase | 96 | class ATTRIBUTE_HIDDEN CRadioButton : public CAddonGUIControlBase |
| 43 | { | 97 | { |
| 44 | public: | 98 | public: |
| 45 | //========================================================================== | 99 | //============================================================================ |
| 46 | /// | 100 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton |
| 47 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | 101 | /// @brief Construct a new control. |
| 48 | /// @brief Construct a new control | ||
| 49 | /// | 102 | /// |
| 50 | /// @param[in] window related window control class | 103 | /// @param[in] window Related window control class |
| 51 | /// @param[in] controlId Used skin xml control id | 104 | /// @param[in] controlId Used skin xml control id |
| 52 | /// | 105 | /// |
| 53 | CRadioButton(CWindow* window, int controlId) : CAddonGUIControlBase(window) | 106 | CRadioButton(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| @@ -58,64 +111,59 @@ public: | |||
| 58 | kodi::Log(ADDON_LOG_FATAL, | 111 | kodi::Log(ADDON_LOG_FATAL, |
| 59 | "kodi::gui::controls::CRadioButton can't create control class from Kodi !!!"); | 112 | "kodi::gui::controls::CRadioButton can't create control class from Kodi !!!"); |
| 60 | } | 113 | } |
| 61 | //-------------------------------------------------------------------------- | 114 | //---------------------------------------------------------------------------- |
| 62 | 115 | ||
| 63 | //========================================================================== | 116 | //============================================================================ |
| 64 | /// | 117 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton |
| 65 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | 118 | /// @brief Destructor. |
| 66 | /// @brief Destructor | ||
| 67 | /// | 119 | /// |
| 68 | ~CRadioButton() override = default; | 120 | ~CRadioButton() override = default; |
| 69 | //-------------------------------------------------------------------------- | 121 | //---------------------------------------------------------------------------- |
| 70 | 122 | ||
| 71 | //========================================================================== | 123 | //============================================================================ |
| 72 | /// | 124 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton. |
| 73 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | 125 | /// @brief Set the control on window to visible. |
| 74 | /// @brief Set the control on window to visible | ||
| 75 | /// | 126 | /// |
| 76 | /// @param[in] visible If true visible, otherwise hidden | 127 | /// @param[in] visible If true visible, otherwise hidden |
| 77 | /// | 128 | /// |
| 78 | void SetVisible(bool visible) | 129 | void SetVisible(bool visible) |
| 79 | { | 130 | { |
| 80 | m_interface->kodi_gui->control_radio_button->set_visible(m_interface->kodiBase, m_controlHandle, | 131 | m_interface->kodi_gui->control_radio_button->set_visible(m_interface->kodiBase, m_controlHandle, |
| 81 | visible); | 132 | visible); |
| 82 | } | 133 | } |
| 83 | //-------------------------------------------------------------------------- | 134 | //---------------------------------------------------------------------------- |
| 84 | 135 | ||
| 85 | //========================================================================== | 136 | //============================================================================ |
| 86 | /// | 137 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton |
| 87 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | 138 | /// @brief Set's the control's enabled/disabled state. |
| 88 | /// @brief Set's the control's enabled/disabled state | ||
| 89 | /// | 139 | /// |
| 90 | /// @param[in] enabled If true enabled, otherwise disabled | 140 | /// @param[in] enabled If true enabled, otherwise disabled |
| 91 | /// | 141 | /// |
| 92 | void SetEnabled(bool enabled) | 142 | void SetEnabled(bool enabled) |
| 93 | { | 143 | { |
| 94 | m_interface->kodi_gui->control_radio_button->set_enabled(m_interface->kodiBase, m_controlHandle, | 144 | m_interface->kodi_gui->control_radio_button->set_enabled(m_interface->kodiBase, m_controlHandle, |
| 95 | enabled); | 145 | enabled); |
| 96 | } | 146 | } |
| 97 | //-------------------------------------------------------------------------- | 147 | //---------------------------------------------------------------------------- |
| 98 | 148 | ||
| 99 | //========================================================================== | 149 | //============================================================================ |
| 150 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 151 | /// @brief To set the text string on radio button. | ||
| 100 | /// | 152 | /// |
| 101 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | 153 | /// @param[in] label Text to show |
| 102 | /// @brief To set the text string on radio button | ||
| 103 | /// | ||
| 104 | /// @param[in] label Text to show | ||
| 105 | /// | 154 | /// |
| 106 | void SetLabel(const std::string& label) | 155 | void SetLabel(const std::string& label) |
| 107 | { | 156 | { |
| 108 | m_interface->kodi_gui->control_radio_button->set_label(m_interface->kodiBase, m_controlHandle, | 157 | m_interface->kodi_gui->control_radio_button->set_label(m_interface->kodiBase, m_controlHandle, |
| 109 | label.c_str()); | 158 | label.c_str()); |
| 110 | } | 159 | } |
| 111 | //-------------------------------------------------------------------------- | 160 | //---------------------------------------------------------------------------- |
| 112 | 161 | ||
| 113 | //========================================================================== | 162 | //============================================================================ |
| 114 | /// | 163 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton |
| 115 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | 164 | /// @brief Get the used text from control. |
| 116 | /// @brief Get the used text from control | ||
| 117 | /// | 165 | /// |
| 118 | /// @return Text shown | 166 | /// @return Text shown |
| 119 | /// | 167 | /// |
| 120 | std::string GetLabel() const | 168 | std::string GetLabel() const |
| 121 | { | 169 | { |
| @@ -130,38 +178,37 @@ public: | |||
| 130 | } | 178 | } |
| 131 | return label; | 179 | return label; |
| 132 | } | 180 | } |
| 133 | //-------------------------------------------------------------------------- | 181 | //---------------------------------------------------------------------------- |
| 134 | 182 | ||
| 135 | //========================================================================== | 183 | //============================================================================ |
| 136 | /// | 184 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton |
| 137 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | 185 | /// @brief To set radio button condition to on or off. |
| 138 | /// @brief To set radio button condition to on or off | ||
| 139 | /// | 186 | /// |
| 140 | /// @param[in] selected true set radio button to selection on, otherwise | 187 | /// @param[in] selected true set radio button to selection on, otherwise off |
| 141 | /// off | ||
| 142 | /// | 188 | /// |
| 143 | void SetSelected(bool selected) | 189 | void SetSelected(bool selected) |
| 144 | { | 190 | { |
| 145 | m_interface->kodi_gui->control_radio_button->set_selected(m_interface->kodiBase, | 191 | m_interface->kodi_gui->control_radio_button->set_selected(m_interface->kodiBase, |
| 146 | m_controlHandle, selected); | 192 | m_controlHandle, selected); |
| 147 | } | 193 | } |
| 148 | //-------------------------------------------------------------------------- | 194 | //---------------------------------------------------------------------------- |
| 149 | 195 | ||
| 150 | //========================================================================== | 196 | //============================================================================ |
| 197 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 198 | /// @brief Get the current selected condition of radio button. | ||
| 151 | /// | 199 | /// |
| 152 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | 200 | /// @return Selected condition |
| 153 | /// @brief Get the current selected condition of radio button | ||
| 154 | /// | ||
| 155 | /// @return Selected condition | ||
| 156 | /// | 201 | /// |
| 157 | bool IsSelected() const | 202 | bool IsSelected() const |
| 158 | { | 203 | { |
| 159 | return m_interface->kodi_gui->control_radio_button->is_selected(m_interface->kodiBase, | 204 | return m_interface->kodi_gui->control_radio_button->is_selected(m_interface->kodiBase, |
| 160 | m_controlHandle); | 205 | m_controlHandle); |
| 161 | } | 206 | } |
| 162 | //-------------------------------------------------------------------------- | 207 | //---------------------------------------------------------------------------- |
| 163 | }; | 208 | }; |
| 164 | 209 | ||
| 165 | } /* namespace controls */ | 210 | } /* namespace controls */ |
| 166 | } /* namespace gui */ | 211 | } /* namespace gui */ |
| 167 | } /* namespace kodi */ | 212 | } /* namespace kodi */ |
| 213 | |||
| 214 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Rendering.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Rendering.h new file mode 100644 index 0000000..7f5feef --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Rendering.h | |||
| @@ -0,0 +1,217 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../c-api/gui/controls/rendering.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | #include "../renderHelper.h" | ||
| 14 | |||
| 15 | #ifdef __cplusplus | ||
| 16 | |||
| 17 | namespace kodi | ||
| 18 | { | ||
| 19 | namespace gui | ||
| 20 | { | ||
| 21 | namespace controls | ||
| 22 | { | ||
| 23 | |||
| 24 | //============================================================================ | ||
| 25 | /// @defgroup cpp_kodi_gui_windows_controls_CRendering Control Rendering | ||
| 26 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 27 | /// @brief @cpp_class{ kodi::gui::controls::CRendering } | ||
| 28 | /// **Window control for rendering own parts**\n | ||
| 29 | /// This rendering control is used when own parts are needed. | ||
| 30 | /// | ||
| 31 | /// You have the control over them to render direct OpenGL or DirectX content | ||
| 32 | /// to the screen set by the size of them. | ||
| 33 | /// | ||
| 34 | /// Alternative can be the virtual functions from t his been ignored if the | ||
| 35 | /// callbacks are defined by the @ref CRendering_SetIndependentCallbacks | ||
| 36 | /// function and class is used as single and not as a parent class. | ||
| 37 | /// | ||
| 38 | /// It has the header @ref Rendering.h "#include <kodi/gui/controls/Rendering.h>" | ||
| 39 | /// be included to enjoy it. | ||
| 40 | /// | ||
| 41 | /// Here you find the needed skin part for a @ref Addon_Rendering_control "rendering control". | ||
| 42 | /// | ||
| 43 | /// @note The call of the control is only possible from the corresponding | ||
| 44 | /// window as its class and identification number is required. | ||
| 45 | /// | ||
| 46 | class ATTRIBUTE_HIDDEN CRendering : public CAddonGUIControlBase | ||
| 47 | { | ||
| 48 | public: | ||
| 49 | //========================================================================== | ||
| 50 | /// @ingroup cpp_kodi_gui_windows_controls_CRendering | ||
| 51 | /// @brief Construct a new control. | ||
| 52 | /// | ||
| 53 | /// @param[in] window Related window control class | ||
| 54 | /// @param[in] controlId Used skin xml control id | ||
| 55 | /// | ||
| 56 | CRendering(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 57 | { | ||
| 58 | m_controlHandle = m_interface->kodi_gui->window->get_control_render_addon( | ||
| 59 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 60 | if (m_controlHandle) | ||
| 61 | m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, | ||
| 62 | m_controlHandle, this, OnCreateCB, | ||
| 63 | OnRenderCB, OnStopCB, OnDirtyCB); | ||
| 64 | else | ||
| 65 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::%s can't create control class from Kodi !!!", | ||
| 66 | __FUNCTION__); | ||
| 67 | } | ||
| 68 | //-------------------------------------------------------------------------- | ||
| 69 | |||
| 70 | //========================================================================== | ||
| 71 | /// @ingroup cpp_kodi_gui_windows_controls_CRendering | ||
| 72 | /// @brief Destructor. | ||
| 73 | /// | ||
| 74 | ~CRendering() override | ||
| 75 | { | ||
| 76 | m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 77 | } | ||
| 78 | //-------------------------------------------------------------------------- | ||
| 79 | |||
| 80 | //========================================================================== | ||
| 81 | /// @ingroup cpp_kodi_gui_windows_controls_CRendering | ||
| 82 | /// @brief To create rendering control on Add-on. | ||
| 83 | /// | ||
| 84 | /// Function creates the needed rendering control for Kodi which becomes | ||
| 85 | /// handled and processed from Add-on | ||
| 86 | /// | ||
| 87 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 88 | /// for calls from add-on to this function. | ||
| 89 | /// | ||
| 90 | /// @param[in] x Horizontal position | ||
| 91 | /// @param[in] y Vertical position | ||
| 92 | /// @param[in] w Width of control | ||
| 93 | /// @param[in] h Height of control | ||
| 94 | /// @param[in] device The device to use. For OpenGL is empty on Direct X is | ||
| 95 | /// the needed device send. | ||
| 96 | /// @return Add-on needs to return true if successed, otherwise false. | ||
| 97 | /// | ||
| 98 | /// @note The @ref kodi::HardwareContext is basically a simple pointer which | ||
| 99 | /// has to be changed to the desired format at the corresponding places using | ||
| 100 | /// <b>`static_cast<...>(...)`</b>. | ||
| 101 | /// | ||
| 102 | virtual bool Create(int x, int y, int w, int h, kodi::HardwareContext device) { return false; } | ||
| 103 | //-------------------------------------------------------------------------- | ||
| 104 | |||
| 105 | //========================================================================== | ||
| 106 | /// @ingroup cpp_kodi_gui_windows_controls_CRendering | ||
| 107 | /// @brief Render process call from Kodi. | ||
| 108 | /// | ||
| 109 | /// @note This is callback function from Kodi to Add-on and not to use for | ||
| 110 | /// calls from add-on to this function. | ||
| 111 | /// | ||
| 112 | virtual void Render() {} | ||
| 113 | //-------------------------------------------------------------------------- | ||
| 114 | |||
| 115 | //========================================================================== | ||
| 116 | /// @ingroup cpp_kodi_gui_windows_controls_CRendering | ||
| 117 | /// @brief Call from Kodi to stop rendering process. | ||
| 118 | /// | ||
| 119 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 120 | /// for calls from add-on to this function. | ||
| 121 | /// | ||
| 122 | virtual void Stop() {} | ||
| 123 | //-------------------------------------------------------------------------- | ||
| 124 | |||
| 125 | //========================================================================== | ||
| 126 | /// @ingroup cpp_kodi_gui_windows_controls_CRendering | ||
| 127 | /// @brief Call from Kodi where add-on becomes asked about dirty rendering | ||
| 128 | /// region. | ||
| 129 | /// | ||
| 130 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 131 | /// for calls from add-on to this function. | ||
| 132 | /// | ||
| 133 | /// @return True if a render region is dirty and need rendering. | ||
| 134 | /// | ||
| 135 | virtual bool Dirty() { return false; } | ||
| 136 | //-------------------------------------------------------------------------- | ||
| 137 | |||
| 138 | //========================================================================== | ||
| 139 | /// @ingroup cpp_kodi_gui_windows_controls_CRendering | ||
| 140 | /// @anchor CRendering_SetIndependentCallbacks | ||
| 141 | /// @brief If the class is used independent (with "new CRendering") | ||
| 142 | /// and not as parent (with "cCLASS_own : CRendering") from own must | ||
| 143 | /// be the callback from Kodi to add-on overdriven with own functions! | ||
| 144 | /// | ||
| 145 | /// @param[in] cbhdl Addon related class point where becomes given as value on | ||
| 146 | /// related functions. | ||
| 147 | /// @param[in] CBCreate External creation function pointer, see also @ref Create | ||
| 148 | /// about related values | ||
| 149 | /// @param[in] CBRender External render function pointer, see also @ref Render | ||
| 150 | /// about related values | ||
| 151 | /// @param[in] CBStop External stop function pointer, see also @ref Stop | ||
| 152 | /// about related values | ||
| 153 | /// @param[in] CBDirty External dirty function pointer, see also @ref Dirty | ||
| 154 | /// about related values | ||
| 155 | /// | ||
| 156 | void SetIndependentCallbacks(kodi::gui::ClientHandle cbhdl, | ||
| 157 | bool (*CBCreate)(kodi::gui::ClientHandle cbhdl, | ||
| 158 | int x, | ||
| 159 | int y, | ||
| 160 | int w, | ||
| 161 | int h, | ||
| 162 | kodi::HardwareContext device), | ||
| 163 | void (*CBRender)(kodi::gui::ClientHandle cbhdl), | ||
| 164 | void (*CBStop)(kodi::gui::ClientHandle cbhdl), | ||
| 165 | bool (*CBDirty)(kodi::gui::ClientHandle cbhdl)) | ||
| 166 | { | ||
| 167 | if (!cbhdl || !CBCreate || !CBRender || !CBStop || !CBDirty) | ||
| 168 | { | ||
| 169 | kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__); | ||
| 170 | return; | ||
| 171 | } | ||
| 172 | |||
| 173 | m_interface->kodi_gui->control_rendering->set_callbacks( | ||
| 174 | m_interface->kodiBase, m_controlHandle, cbhdl, CBCreate, CBRender, CBStop, CBDirty); | ||
| 175 | } | ||
| 176 | //-------------------------------------------------------------------------- | ||
| 177 | |||
| 178 | private: | ||
| 179 | /* | ||
| 180 | * Defined callback functions from Kodi to add-on, for use in parent / child system | ||
| 181 | * (is private)! | ||
| 182 | */ | ||
| 183 | static bool OnCreateCB( | ||
| 184 | KODI_GUI_CLIENT_HANDLE cbhdl, int x, int y, int w, int h, ADDON_HARDWARE_CONTEXT device) | ||
| 185 | { | ||
| 186 | static_cast<CRendering*>(cbhdl)->m_renderHelper = kodi::gui::GetRenderHelper(); | ||
| 187 | return static_cast<CRendering*>(cbhdl)->Create(x, y, w, h, device); | ||
| 188 | } | ||
| 189 | |||
| 190 | static void OnRenderCB(KODI_GUI_CLIENT_HANDLE cbhdl) | ||
| 191 | { | ||
| 192 | if (!static_cast<CRendering*>(cbhdl)->m_renderHelper) | ||
| 193 | return; | ||
| 194 | static_cast<CRendering*>(cbhdl)->m_renderHelper->Begin(); | ||
| 195 | static_cast<CRendering*>(cbhdl)->Render(); | ||
| 196 | static_cast<CRendering*>(cbhdl)->m_renderHelper->End(); | ||
| 197 | } | ||
| 198 | |||
| 199 | static void OnStopCB(KODI_GUI_CLIENT_HANDLE cbhdl) | ||
| 200 | { | ||
| 201 | static_cast<CRendering*>(cbhdl)->Stop(); | ||
| 202 | static_cast<CRendering*>(cbhdl)->m_renderHelper = nullptr; | ||
| 203 | } | ||
| 204 | |||
| 205 | static bool OnDirtyCB(KODI_GUI_CLIENT_HANDLE cbhdl) | ||
| 206 | { | ||
| 207 | return static_cast<CRendering*>(cbhdl)->Dirty(); | ||
| 208 | } | ||
| 209 | |||
| 210 | std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper; | ||
| 211 | }; | ||
| 212 | |||
| 213 | } /* namespace controls */ | ||
| 214 | } /* namespace gui */ | ||
| 215 | } /* namespace kodi */ | ||
| 216 | |||
| 217 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/SettingsSlider.h index 76a02aa..5557fc4 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/SettingsSlider.h | |||
| @@ -8,9 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../../AddonBase.h" | 11 | #include "../../c-api/gui/controls/settings_slider.h" |
| 12 | #include "../Window.h" | 12 | #include "../Window.h" |
| 13 | 13 | ||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 14 | namespace kodi | 16 | namespace kodi |
| 15 | { | 17 | { |
| 16 | namespace gui | 18 | namespace gui |
| @@ -18,37 +20,36 @@ namespace gui | |||
| 18 | namespace controls | 20 | namespace controls |
| 19 | { | 21 | { |
| 20 | 22 | ||
| 21 | //============================================================================ | 23 | //============================================================================== |
| 22 | /// | 24 | /// @defgroup cpp_kodi_gui_windows_controls_CSettingsSlider Control Settings Slider |
| 23 | /// \defgroup cpp_kodi_gui_controls_CSettingsSlider Control Settings Slider | 25 | /// @ingroup cpp_kodi_gui_windows_controls |
| 24 | /// \ingroup cpp_kodi_gui | 26 | /// @brief @cpp_class{ kodi::gui::controls::CSettingsSlider } |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CSettingsSlider } | 27 | /// **Window control for moveable slider with text name**\n |
| 26 | /// **Window control for moveable slider with text name** | 28 | /// The settings slider control is used in the settings screens for when an |
| 29 | /// option is best specified on a sliding scale. | ||
| 27 | /// | 30 | /// |
| 28 | /// The settings slider control is used in the settings screens for when an | 31 | /// You can choose the position, size, and look of the slider control. It is |
| 29 | /// option is best specified on a sliding scale. You can choose the position, | 32 | /// basically a cross between the button control and a slider control. It has a |
| 30 | /// size, and look of the slider control. It is basically a cross between the | 33 | /// label and focus and non focus textures, as well as a slider control on the |
| 31 | /// button control and a slider control. It has a label and focus and non | 34 | /// right. |
| 32 | /// focus textures, as well as a slider control on the right. | ||
| 33 | /// | 35 | /// |
| 34 | /// It has the header \ref SettingsSlider.h "#include <kodi/gui/controls/SettingsSlider.h>" | 36 | /// It has the header @ref SettingsSlider.h "#include <kodi/gui/controls/SettingsSlider.h>" |
| 35 | /// be included to enjoy it. | 37 | /// be included to enjoy it. |
| 36 | /// | 38 | /// |
| 37 | /// Here you find the needed skin part for a \ref Settings_Slider_Control "settings slider control" | 39 | /// Here you find the needed skin part for a @ref Settings_Slider_Control "settings slider control". |
| 38 | /// | 40 | /// |
| 39 | /// @note The call of the control is only possible from the corresponding | 41 | /// @note The call of the control is only possible from the corresponding |
| 40 | /// window as its class and identification number is required. | 42 | /// window as its class and identification number is required. |
| 41 | /// | 43 | /// |
| 42 | class ATTRIBUTE_HIDDEN CSettingsSlider : public CAddonGUIControlBase | 44 | class ATTRIBUTE_HIDDEN CSettingsSlider : public CAddonGUIControlBase |
| 43 | { | 45 | { |
| 44 | public: | 46 | public: |
| 45 | //========================================================================== | 47 | //============================================================================ |
| 46 | /// | 48 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 47 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 49 | /// @brief Construct a new control. |
| 48 | /// @brief Construct a new control | ||
| 49 | /// | 50 | /// |
| 50 | /// @param[in] window related window control class | 51 | /// @param[in] window Related window control class |
| 51 | /// @param[in] controlId Used skin xml control id | 52 | /// @param[in] controlId Used skin xml control id |
| 52 | /// | 53 | /// |
| 53 | CSettingsSlider(CWindow* window, int controlId) : CAddonGUIControlBase(window) | 54 | CSettingsSlider(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 54 | { | 55 | { |
| @@ -58,74 +59,68 @@ public: | |||
| 58 | kodi::Log(ADDON_LOG_FATAL, | 59 | kodi::Log(ADDON_LOG_FATAL, |
| 59 | "kodi::gui::controls::CSettingsSlider can't create control class from Kodi !!!"); | 60 | "kodi::gui::controls::CSettingsSlider can't create control class from Kodi !!!"); |
| 60 | } | 61 | } |
| 61 | //-------------------------------------------------------------------------- | 62 | //---------------------------------------------------------------------------- |
| 62 | 63 | ||
| 63 | //========================================================================== | 64 | //============================================================================ |
| 64 | /// | 65 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 65 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 66 | /// @brief Destructor. |
| 66 | /// @brief Destructor | ||
| 67 | /// | 67 | /// |
| 68 | ~CSettingsSlider() override = default; | 68 | ~CSettingsSlider() override = default; |
| 69 | //-------------------------------------------------------------------------- | 69 | //---------------------------------------------------------------------------- |
| 70 | 70 | ||
| 71 | //========================================================================== | 71 | //============================================================================ |
| 72 | /// | 72 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 73 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 73 | /// @brief Set the control on window to visible. |
| 74 | /// @brief Set the control on window to visible | ||
| 75 | /// | 74 | /// |
| 76 | /// @param[in] visible If true visible, otherwise hidden | 75 | /// @param[in] visible If true visible, otherwise hidden |
| 77 | /// | 76 | /// |
| 78 | void SetVisible(bool visible) | 77 | void SetVisible(bool visible) |
| 79 | { | 78 | { |
| 80 | m_interface->kodi_gui->control_settings_slider->set_visible(m_interface->kodiBase, | 79 | m_interface->kodi_gui->control_settings_slider->set_visible(m_interface->kodiBase, |
| 81 | m_controlHandle, visible); | 80 | m_controlHandle, visible); |
| 82 | } | 81 | } |
| 83 | //-------------------------------------------------------------------------- | 82 | //---------------------------------------------------------------------------- |
| 84 | 83 | ||
| 85 | //========================================================================== | 84 | //============================================================================ |
| 85 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 86 | /// @brief Set's the control's enabled/disabled state. | ||
| 86 | /// | 87 | /// |
| 87 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 88 | /// @param[in] enabled If true enabled, otherwise disabled |
| 88 | /// @brief Set's the control's enabled/disabled state | ||
| 89 | /// | ||
| 90 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 91 | /// | 89 | /// |
| 92 | void SetEnabled(bool enabled) | 90 | void SetEnabled(bool enabled) |
| 93 | { | 91 | { |
| 94 | m_interface->kodi_gui->control_settings_slider->set_enabled(m_interface->kodiBase, | 92 | m_interface->kodi_gui->control_settings_slider->set_enabled(m_interface->kodiBase, |
| 95 | m_controlHandle, enabled); | 93 | m_controlHandle, enabled); |
| 96 | } | 94 | } |
| 97 | //-------------------------------------------------------------------------- | 95 | //---------------------------------------------------------------------------- |
| 98 | 96 | ||
| 99 | //========================================================================== | 97 | //============================================================================ |
| 100 | /// | 98 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 101 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 99 | /// @brief To set the text string on settings slider. |
| 102 | /// @brief To set the text string on settings slider | ||
| 103 | /// | 100 | /// |
| 104 | /// @param[in] text Text to show | 101 | /// @param[in] text Text to show |
| 105 | /// | 102 | /// |
| 106 | void SetText(const std::string& text) | 103 | void SetText(const std::string& text) |
| 107 | { | 104 | { |
| 108 | m_interface->kodi_gui->control_settings_slider->set_text(m_interface->kodiBase, m_controlHandle, | 105 | m_interface->kodi_gui->control_settings_slider->set_text(m_interface->kodiBase, m_controlHandle, |
| 109 | text.c_str()); | 106 | text.c_str()); |
| 110 | } | 107 | } |
| 111 | //-------------------------------------------------------------------------- | 108 | //---------------------------------------------------------------------------- |
| 112 | 109 | ||
| 113 | //========================================================================== | 110 | //============================================================================ |
| 114 | /// | 111 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 115 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 112 | /// @brief To reset slider on defaults. |
| 116 | /// @brief To reset slider on defaults | ||
| 117 | /// | 113 | /// |
| 118 | void Reset() | 114 | void Reset() |
| 119 | { | 115 | { |
| 120 | m_interface->kodi_gui->control_settings_slider->reset(m_interface->kodiBase, m_controlHandle); | 116 | m_interface->kodi_gui->control_settings_slider->reset(m_interface->kodiBase, m_controlHandle); |
| 121 | } | 117 | } |
| 122 | //-------------------------------------------------------------------------- | 118 | //---------------------------------------------------------------------------- |
| 123 | 119 | ||
| 124 | //========================================================================== | 120 | //============================================================================ |
| 125 | /// | 121 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 126 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 127 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | 122 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider |
| 128 | /// start and e.g. +10 is the from here defined position where it reach the | 123 | /// start and e.g. +10 is the from here defined position where it reach the |
| 129 | /// end. | 124 | /// end. |
| 130 | /// | 125 | /// |
| 131 | /// Ad default is the range from 0 to 100. | 126 | /// Ad default is the range from 0 to 100. |
| @@ -133,11 +128,11 @@ public: | |||
| 133 | /// The integer interval is as default 1 and can be changed with | 128 | /// The integer interval is as default 1 and can be changed with |
| 134 | /// @ref SetIntInterval. | 129 | /// @ref SetIntInterval. |
| 135 | /// | 130 | /// |
| 136 | /// @param[in] start Integer start value | 131 | /// @param[in] start Integer start value |
| 137 | /// @param[in] end Integer end value | 132 | /// @param[in] end Integer end value |
| 138 | /// | 133 | /// |
| 139 | /// @note Percent, floating point or integer are alone possible. Combining | 134 | /// @note Percent, floating point or integer are alone possible. Combining |
| 140 | /// these different values can be not together and can, therefore, only | 135 | /// these different values can be not together and can, therefore, only |
| 141 | /// one each can be used. | 136 | /// one each can be used. |
| 142 | /// | 137 | /// |
| 143 | void SetIntRange(int start, int end) | 138 | void SetIntRange(int start, int end) |
| @@ -145,18 +140,17 @@ public: | |||
| 145 | m_interface->kodi_gui->control_settings_slider->set_int_range(m_interface->kodiBase, | 140 | m_interface->kodi_gui->control_settings_slider->set_int_range(m_interface->kodiBase, |
| 146 | m_controlHandle, start, end); | 141 | m_controlHandle, start, end); |
| 147 | } | 142 | } |
| 148 | //-------------------------------------------------------------------------- | 143 | //---------------------------------------------------------------------------- |
| 149 | 144 | ||
| 150 | //========================================================================== | 145 | //============================================================================ |
| 151 | /// | 146 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 152 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 147 | /// @brief Set the slider position with the given integer value. The Range |
| 153 | /// @brief Set the slider position with the given integer value. The Range | 148 | /// must be defined with a call from @ref SetIntRange before. |
| 154 | /// must be defined with a call from \ref SetIntRange before. | ||
| 155 | /// | 149 | /// |
| 156 | /// @param[in] value Position in range to set with integer | 150 | /// @param[in] value Position in range to set with integer |
| 157 | /// | 151 | /// |
| 158 | /// @note Percent, floating point or integer are alone possible. Combining | 152 | /// @note Percent, floating point or integer are alone possible. Combining |
| 159 | /// these different values can be not together and can, therefore, only | 153 | /// these different values can be not together and can, therefore, only |
| 160 | /// one each can be used. | 154 | /// one each can be used. |
| 161 | /// | 155 | /// |
| 162 | void SetIntValue(int value) | 156 | void SetIntValue(int value) |
| @@ -164,17 +158,16 @@ public: | |||
| 164 | m_interface->kodi_gui->control_settings_slider->set_int_value(m_interface->kodiBase, | 158 | m_interface->kodi_gui->control_settings_slider->set_int_value(m_interface->kodiBase, |
| 165 | m_controlHandle, value); | 159 | m_controlHandle, value); |
| 166 | } | 160 | } |
| 167 | //-------------------------------------------------------------------------- | 161 | //---------------------------------------------------------------------------- |
| 168 | 162 | ||
| 169 | //========================================================================== | 163 | //============================================================================ |
| 170 | /// | 164 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 171 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 172 | /// @brief To get the current position as integer value. | 165 | /// @brief To get the current position as integer value. |
| 173 | /// | 166 | /// |
| 174 | /// @return The position as integer | 167 | /// @return The position as integer |
| 175 | /// | 168 | /// |
| 176 | /// @note Percent, floating point or integer are alone possible. Combining | 169 | /// @note Percent, floating point or integer are alone possible. Combining |
| 177 | /// these different values can be not together and can, therefore, only | 170 | /// these different values can be not together and can, therefore, only |
| 178 | /// one each can be used. | 171 | /// one each can be used. |
| 179 | /// | 172 | /// |
| 180 | int GetIntValue() const | 173 | int GetIntValue() const |
| @@ -182,19 +175,18 @@ public: | |||
| 182 | return m_interface->kodi_gui->control_settings_slider->get_int_value(m_interface->kodiBase, | 175 | return m_interface->kodi_gui->control_settings_slider->get_int_value(m_interface->kodiBase, |
| 183 | m_controlHandle); | 176 | m_controlHandle); |
| 184 | } | 177 | } |
| 185 | //-------------------------------------------------------------------------- | 178 | //---------------------------------------------------------------------------- |
| 186 | 179 | ||
| 187 | //========================================================================== | 180 | //============================================================================ |
| 188 | /// | 181 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 189 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 182 | /// @brief To set the interval steps of slider, as default is it 1. If it |
| 190 | /// @brief To set the interval steps of slider, as default is it 1. If it | 183 | /// becomes changed with this function will a step of the user with the |
| 191 | /// becomes changed with this function will a step of the user with the | ||
| 192 | /// value fixed here be executed. | 184 | /// value fixed here be executed. |
| 193 | /// | 185 | /// |
| 194 | /// @param[in] interval Intervall step to set. | 186 | /// @param[in] interval Intervall step to set. |
| 195 | /// | 187 | /// |
| 196 | /// @note Percent, floating point or integer are alone possible. Combining | 188 | /// @note Percent, floating point or integer are alone possible. Combining |
| 197 | /// these different values can be not together and can, therefore, only | 189 | /// these different values can be not together and can, therefore, only |
| 198 | /// one each can be used. | 190 | /// one each can be used. |
| 199 | /// | 191 | /// |
| 200 | void SetIntInterval(int interval) | 192 | void SetIntInterval(int interval) |
| @@ -202,17 +194,16 @@ public: | |||
| 202 | m_interface->kodi_gui->control_settings_slider->set_int_interval(m_interface->kodiBase, | 194 | m_interface->kodi_gui->control_settings_slider->set_int_interval(m_interface->kodiBase, |
| 203 | m_controlHandle, interval); | 195 | m_controlHandle, interval); |
| 204 | } | 196 | } |
| 205 | //-------------------------------------------------------------------------- | 197 | //---------------------------------------------------------------------------- |
| 206 | 198 | ||
| 207 | //========================================================================== | 199 | //============================================================================ |
| 208 | /// | 200 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 209 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 210 | /// @brief Sets the percent of the slider. | 201 | /// @brief Sets the percent of the slider. |
| 211 | /// | 202 | /// |
| 212 | /// @param[in] percent float - Percent value of slide | 203 | /// @param[in] percent float - Percent value of slide |
| 213 | /// | 204 | /// |
| 214 | /// @note Percent, floating point or integer are alone possible. Combining | 205 | /// @note Percent, floating point or integer are alone possible. Combining |
| 215 | /// these different values can be not together and can, therefore, only | 206 | /// these different values can be not together and can, therefore, only |
| 216 | /// one each can be used. | 207 | /// one each can be used. |
| 217 | /// | 208 | /// |
| 218 | void SetPercentage(float percent) | 209 | void SetPercentage(float percent) |
| @@ -220,17 +211,16 @@ public: | |||
| 220 | m_interface->kodi_gui->control_settings_slider->set_percentage(m_interface->kodiBase, | 211 | m_interface->kodi_gui->control_settings_slider->set_percentage(m_interface->kodiBase, |
| 221 | m_controlHandle, percent); | 212 | m_controlHandle, percent); |
| 222 | } | 213 | } |
| 223 | //-------------------------------------------------------------------------- | 214 | //---------------------------------------------------------------------------- |
| 224 | 215 | ||
| 225 | //========================================================================== | 216 | //============================================================================ |
| 226 | /// | 217 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 227 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 228 | /// @brief Returns a float of the percent of the slider. | 218 | /// @brief Returns a float of the percent of the slider. |
| 229 | /// | 219 | /// |
| 230 | /// @return float - Percent of slider | 220 | /// @return float - Percent of slider |
| 231 | /// | 221 | /// |
| 232 | /// @note Percent, floating point or integer are alone possible. Combining | 222 | /// @note Percent, floating point or integer are alone possible. Combining |
| 233 | /// these different values can be not together and can, therefore, only | 223 | /// these different values can be not together and can, therefore, only |
| 234 | /// one each can be used. | 224 | /// one each can be used. |
| 235 | /// | 225 | /// |
| 236 | float GetPercentage() const | 226 | float GetPercentage() const |
| @@ -238,13 +228,12 @@ public: | |||
| 238 | return m_interface->kodi_gui->control_settings_slider->get_percentage(m_interface->kodiBase, | 228 | return m_interface->kodi_gui->control_settings_slider->get_percentage(m_interface->kodiBase, |
| 239 | m_controlHandle); | 229 | m_controlHandle); |
| 240 | } | 230 | } |
| 241 | //-------------------------------------------------------------------------- | 231 | //---------------------------------------------------------------------------- |
| 242 | 232 | ||
| 243 | //========================================================================== | 233 | //============================================================================ |
| 244 | /// | 234 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 245 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 246 | /// @brief To set the the range as float of slider, e.g. -25.0 is the slider | 235 | /// @brief To set the the range as float of slider, e.g. -25.0 is the slider |
| 247 | /// start and e.g. +25.0 is the from here defined position where it reach | 236 | /// start and e.g. +25.0 is the from here defined position where it reach |
| 248 | /// the end. | 237 | /// the end. |
| 249 | /// | 238 | /// |
| 250 | /// As default is the range 0.0 to 1.0. | 239 | /// As default is the range 0.0 to 1.0. |
| @@ -252,11 +241,11 @@ public: | |||
| 252 | /// The float interval is as default 0.1 and can be changed with | 241 | /// The float interval is as default 0.1 and can be changed with |
| 253 | /// @ref SetFloatInterval. | 242 | /// @ref SetFloatInterval. |
| 254 | /// | 243 | /// |
| 255 | /// @param[in] start Integer start value | 244 | /// @param[in] start Integer start value |
| 256 | /// @param[in] end Integer end value | 245 | /// @param[in] end Integer end value |
| 257 | /// | 246 | /// |
| 258 | /// @note Percent, floating point or integer are alone possible. Combining | 247 | /// @note Percent, floating point or integer are alone possible. Combining |
| 259 | /// these different values can be not together and can, therefore, only | 248 | /// these different values can be not together and can, therefore, only |
| 260 | /// one each can be used. | 249 | /// one each can be used. |
| 261 | /// | 250 | /// |
| 262 | void SetFloatRange(float start, float end) | 251 | void SetFloatRange(float start, float end) |
| @@ -264,19 +253,18 @@ public: | |||
| 264 | m_interface->kodi_gui->control_settings_slider->set_float_range(m_interface->kodiBase, | 253 | m_interface->kodi_gui->control_settings_slider->set_float_range(m_interface->kodiBase, |
| 265 | m_controlHandle, start, end); | 254 | m_controlHandle, start, end); |
| 266 | } | 255 | } |
| 267 | //-------------------------------------------------------------------------- | 256 | //---------------------------------------------------------------------------- |
| 268 | 257 | ||
| 269 | //========================================================================== | 258 | //============================================================================ |
| 270 | /// | 259 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 271 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 260 | /// @brief Set the slider position with the given float value. The Range can |
| 272 | /// @brief Set the slider position with the given float value. The Range | 261 | /// be defined with a call from @ref SetIntRange before, as default it |
| 273 | /// can be defined with a call from \ref SetIntRange before, as default it | ||
| 274 | /// is 0.0 to 1.0. | 262 | /// is 0.0 to 1.0. |
| 275 | /// | 263 | /// |
| 276 | /// @param[in] value Position in range to set with float | 264 | /// @param[in] value Position in range to set with float |
| 277 | /// | 265 | /// |
| 278 | /// @note Percent, floating point or integer are alone possible. Combining | 266 | /// @note Percent, floating point or integer are alone possible. Combining |
| 279 | /// these different values can be not together and can, therefore, only | 267 | /// these different values can be not together and can, therefore, only |
| 280 | /// one each can be used. | 268 | /// one each can be used. |
| 281 | /// | 269 | /// |
| 282 | void SetFloatValue(float value) | 270 | void SetFloatValue(float value) |
| @@ -284,33 +272,31 @@ public: | |||
| 284 | m_interface->kodi_gui->control_settings_slider->set_float_value(m_interface->kodiBase, | 272 | m_interface->kodi_gui->control_settings_slider->set_float_value(m_interface->kodiBase, |
| 285 | m_controlHandle, value); | 273 | m_controlHandle, value); |
| 286 | } | 274 | } |
| 287 | //-------------------------------------------------------------------------- | 275 | //---------------------------------------------------------------------------- |
| 288 | 276 | ||
| 289 | //========================================================================== | 277 | //============================================================================ |
| 290 | /// | 278 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 291 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 292 | /// @brief To get the current position as float value. | 279 | /// @brief To get the current position as float value. |
| 293 | /// | 280 | /// |
| 294 | /// @return The position as float | 281 | /// @return The position as float |
| 295 | /// | 282 | /// |
| 296 | float GetFloatValue() const | 283 | float GetFloatValue() const |
| 297 | { | 284 | { |
| 298 | return m_interface->kodi_gui->control_settings_slider->get_float_value(m_interface->kodiBase, | 285 | return m_interface->kodi_gui->control_settings_slider->get_float_value(m_interface->kodiBase, |
| 299 | m_controlHandle); | 286 | m_controlHandle); |
| 300 | } | 287 | } |
| 301 | //-------------------------------------------------------------------------- | 288 | //---------------------------------------------------------------------------- |
| 302 | 289 | ||
| 303 | //========================================================================== | 290 | //============================================================================ |
| 304 | /// | 291 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider |
| 305 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 292 | /// @brief To set the interval steps of slider, as default is it 0.1 If it |
| 306 | /// @brief To set the interval steps of slider, as default is it 0.1 If it | ||
| 307 | /// becomes changed with this function will a step of the user with the | 293 | /// becomes changed with this function will a step of the user with the |
| 308 | /// value fixed here be executed. | 294 | /// value fixed here be executed. |
| 309 | /// | 295 | /// |
| 310 | /// @param[in] interval Intervall step to set. | 296 | /// @param[in] interval Intervall step to set. |
| 311 | /// | 297 | /// |
| 312 | /// @note Percent, floating point or integer are alone possible. Combining | 298 | /// @note Percent, floating point or integer are alone possible. Combining |
| 313 | /// these different values can be not together and can, therefore, only | 299 | /// these different values can be not together and can, therefore, only |
| 314 | /// one each can be used. | 300 | /// one each can be used. |
| 315 | /// | 301 | /// |
| 316 | void SetFloatInterval(float interval) | 302 | void SetFloatInterval(float interval) |
| @@ -318,9 +304,11 @@ public: | |||
| 318 | m_interface->kodi_gui->control_settings_slider->set_float_interval(m_interface->kodiBase, | 304 | m_interface->kodi_gui->control_settings_slider->set_float_interval(m_interface->kodiBase, |
| 319 | m_controlHandle, interval); | 305 | m_controlHandle, interval); |
| 320 | } | 306 | } |
| 321 | //-------------------------------------------------------------------------- | 307 | //---------------------------------------------------------------------------- |
| 322 | }; | 308 | }; |
| 323 | 309 | ||
| 324 | } /* namespace controls */ | 310 | } /* namespace controls */ |
| 325 | } /* namespace gui */ | 311 | } /* namespace gui */ |
| 326 | } /* namespace kodi */ | 312 | } /* namespace kodi */ |
| 313 | |||
| 314 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h index 715cc7d..077def8 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h | |||
| @@ -8,9 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../../AddonBase.h" | 11 | #include "../../c-api/gui/controls/slider.h" |
| 12 | #include "../Window.h" | 12 | #include "../Window.h" |
| 13 | 13 | ||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 14 | namespace kodi | 16 | namespace kodi |
| 15 | { | 17 | { |
| 16 | namespace gui | 18 | namespace gui |
| @@ -18,35 +20,33 @@ namespace gui | |||
| 18 | namespace controls | 20 | namespace controls |
| 19 | { | 21 | { |
| 20 | 22 | ||
| 21 | //============================================================================ | 23 | //============================================================================== |
| 22 | /// | 24 | /// @defgroup cpp_kodi_gui_windows_controls_CSlider Control Slider |
| 23 | /// \defgroup cpp_kodi_gui_controls_CSlider Control Slider | 25 | /// @ingroup cpp_kodi_gui_windows_controls |
| 24 | /// \ingroup cpp_kodi_gui | 26 | /// @brief @cpp_class{ kodi::gui::controls::CSlider } |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CSlider } | 27 | /// **Window control for moveable slider**\n |
| 26 | /// **Window control for moveable slider** | 28 | /// The slider control is used for things where a sliding bar best represents |
| 29 | /// the operation at hand (such as a volume control or seek control). | ||
| 27 | /// | 30 | /// |
| 28 | /// The slider control is used for things where a sliding bar best represents | 31 | /// You can choose the position, size, and look of the slider control. |
| 29 | /// the operation at hand (such as a volume control or seek control). You can | ||
| 30 | /// choose the position, size, and look of the slider control. | ||
| 31 | /// | 32 | /// |
| 32 | /// It has the header \ref Slider.h "#include <kodi/gui/controls/Slider.h>" | 33 | /// It has the header @ref Slider.h "#include <kodi/gui/controls/Slider.h>" |
| 33 | /// be included to enjoy it. | 34 | /// be included to enjoy it. |
| 34 | /// | 35 | /// |
| 35 | /// Here you find the needed skin part for a \ref Slider_Control "slider control" | 36 | /// Here you find the needed skin part for a @ref Slider_Control "slider control". |
| 36 | /// | 37 | /// |
| 37 | /// @note The call of the control is only possible from the corresponding | 38 | /// @note The call of the control is only possible from the corresponding |
| 38 | /// window as its class and identification number is required. | 39 | /// window as its class and identification number is required. |
| 39 | /// | 40 | /// |
| 40 | class ATTRIBUTE_HIDDEN CSlider : public CAddonGUIControlBase | 41 | class ATTRIBUTE_HIDDEN CSlider : public CAddonGUIControlBase |
| 41 | { | 42 | { |
| 42 | public: | 43 | public: |
| 43 | //========================================================================== | 44 | //============================================================================ |
| 44 | /// | 45 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 45 | /// \ingroup cpp_kodi_gui_controls_CSlider | 46 | /// @brief Construct a new control. |
| 46 | /// @brief Construct a new control | ||
| 47 | /// | 47 | /// |
| 48 | /// @param[in] window related window control class | 48 | /// @param[in] window Related window control class |
| 49 | /// @param[in] controlId Used skin xml control id | 49 | /// @param[in] controlId Used skin xml control id |
| 50 | /// | 50 | /// |
| 51 | CSlider(CWindow* window, int controlId) : CAddonGUIControlBase(window) | 51 | CSlider(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 52 | { | 52 | { |
| @@ -56,61 +56,56 @@ public: | |||
| 56 | kodi::Log(ADDON_LOG_FATAL, | 56 | kodi::Log(ADDON_LOG_FATAL, |
| 57 | "kodi::gui::controls::CSlider can't create control class from Kodi !!!"); | 57 | "kodi::gui::controls::CSlider can't create control class from Kodi !!!"); |
| 58 | } | 58 | } |
| 59 | //-------------------------------------------------------------------------- | 59 | //---------------------------------------------------------------------------- |
| 60 | 60 | ||
| 61 | //========================================================================== | 61 | //============================================================================ |
| 62 | /// | 62 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 63 | /// \ingroup cpp_kodi_gui_controls_CSlider | 63 | /// @brief Destructor. |
| 64 | /// @brief Destructor | ||
| 65 | /// | 64 | /// |
| 66 | ~CSlider() override = default; | 65 | ~CSlider() override = default; |
| 67 | //-------------------------------------------------------------------------- | 66 | //---------------------------------------------------------------------------- |
| 68 | 67 | ||
| 69 | //========================================================================== | 68 | //============================================================================ |
| 70 | /// | 69 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 71 | /// \ingroup cpp_kodi_gui_controls_CSlider | 70 | /// @brief Set the control on window to visible. |
| 72 | /// @brief Set the control on window to visible | ||
| 73 | /// | 71 | /// |
| 74 | /// @param[in] visible If true visible, otherwise hidden | 72 | /// @param[in] visible If true visible, otherwise hidden |
| 75 | /// | 73 | /// |
| 76 | void SetVisible(bool visible) | 74 | void SetVisible(bool visible) |
| 77 | { | 75 | { |
| 78 | m_interface->kodi_gui->control_slider->set_visible(m_interface->kodiBase, m_controlHandle, | 76 | m_interface->kodi_gui->control_slider->set_visible(m_interface->kodiBase, m_controlHandle, |
| 79 | visible); | 77 | visible); |
| 80 | } | 78 | } |
| 81 | //-------------------------------------------------------------------------- | 79 | //---------------------------------------------------------------------------- |
| 82 | 80 | ||
| 83 | //========================================================================== | 81 | //============================================================================ |
| 82 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 83 | /// @brief Set's the control's enabled/disabled state. | ||
| 84 | /// | 84 | /// |
| 85 | /// \ingroup cpp_kodi_gui_controls_CSlider | 85 | /// @param[in] enabled If true enabled, otherwise disabled |
| 86 | /// @brief Set's the control's enabled/disabled state | ||
| 87 | /// | ||
| 88 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 89 | /// | 86 | /// |
| 90 | void SetEnabled(bool enabled) | 87 | void SetEnabled(bool enabled) |
| 91 | { | 88 | { |
| 92 | m_interface->kodi_gui->control_slider->set_enabled(m_interface->kodiBase, m_controlHandle, | 89 | m_interface->kodi_gui->control_slider->set_enabled(m_interface->kodiBase, m_controlHandle, |
| 93 | enabled); | 90 | enabled); |
| 94 | } | 91 | } |
| 95 | //-------------------------------------------------------------------------- | 92 | //---------------------------------------------------------------------------- |
| 96 | 93 | ||
| 97 | //========================================================================== | 94 | //============================================================================ |
| 98 | /// | 95 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 99 | /// \ingroup cpp_kodi_gui_controls_CSlider | 96 | /// @brief To reset slider on defaults. |
| 100 | /// @brief To reset slider on defaults | ||
| 101 | /// | 97 | /// |
| 102 | void Reset() | 98 | void Reset() |
| 103 | { | 99 | { |
| 104 | m_interface->kodi_gui->control_slider->reset(m_interface->kodiBase, m_controlHandle); | 100 | m_interface->kodi_gui->control_slider->reset(m_interface->kodiBase, m_controlHandle); |
| 105 | } | 101 | } |
| 106 | //-------------------------------------------------------------------------- | 102 | //---------------------------------------------------------------------------- |
| 107 | 103 | ||
| 108 | //========================================================================== | 104 | //============================================================================ |
| 109 | /// | 105 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 110 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 111 | /// @brief With GetDescription becomes a string value of position returned. | 106 | /// @brief With GetDescription becomes a string value of position returned. |
| 112 | /// | 107 | /// |
| 113 | /// @return Text string about current slider position | 108 | /// @return Text string about current slider position |
| 114 | /// | 109 | /// |
| 115 | /// The following are the text definition returned from this: | 110 | /// The following are the text definition returned from this: |
| 116 | /// | Value | Without range selection | With range selection | | 111 | /// | Value | Without range selection | With range selection | |
| @@ -132,13 +127,12 @@ public: | |||
| 132 | } | 127 | } |
| 133 | return text; | 128 | return text; |
| 134 | } | 129 | } |
| 135 | //-------------------------------------------------------------------------- | 130 | //---------------------------------------------------------------------------- |
| 136 | 131 | ||
| 137 | //========================================================================== | 132 | //============================================================================ |
| 138 | /// | 133 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 139 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 140 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | 134 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider |
| 141 | /// start and e.g. +10 is the from here defined position where it reach the | 135 | /// start and e.g. +10 is the from here defined position where it reach the |
| 142 | /// end. | 136 | /// end. |
| 143 | /// | 137 | /// |
| 144 | /// Ad default is the range from 0 to 100. | 138 | /// Ad default is the range from 0 to 100. |
| @@ -146,11 +140,11 @@ public: | |||
| 146 | /// The integer interval is as default 1 and can be changed with | 140 | /// The integer interval is as default 1 and can be changed with |
| 147 | /// @ref SetIntInterval. | 141 | /// @ref SetIntInterval. |
| 148 | /// | 142 | /// |
| 149 | /// @param[in] start Integer start value | 143 | /// @param[in] start Integer start value |
| 150 | /// @param[in] end Integer end value | 144 | /// @param[in] end Integer end value |
| 151 | /// | 145 | /// |
| 152 | /// @note Percent, floating point or integer are alone possible. Combining | 146 | /// @note Percent, floating point or integer are alone possible. Combining |
| 153 | /// these different values can be not together and can, therefore, only one | 147 | /// these different values can be not together and can, therefore, only one |
| 154 | /// each can be used. | 148 | /// each can be used. |
| 155 | /// | 149 | /// |
| 156 | void SetIntRange(int start, int end) | 150 | void SetIntRange(int start, int end) |
| @@ -158,18 +152,17 @@ public: | |||
| 158 | m_interface->kodi_gui->control_slider->set_int_range(m_interface->kodiBase, m_controlHandle, | 152 | m_interface->kodi_gui->control_slider->set_int_range(m_interface->kodiBase, m_controlHandle, |
| 159 | start, end); | 153 | start, end); |
| 160 | } | 154 | } |
| 161 | //-------------------------------------------------------------------------- | 155 | //---------------------------------------------------------------------------- |
| 162 | 156 | ||
| 163 | //========================================================================== | 157 | //============================================================================ |
| 164 | /// | 158 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 165 | /// \ingroup CSlider | 159 | /// @brief Set the slider position with the given integer value. The Range |
| 166 | /// @brief Set the slider position with the given integer value. The Range | 160 | /// must be defined with a call from @ref SetIntRange before. |
| 167 | /// must be defined with a call from \ref SetIntRange before. | ||
| 168 | /// | 161 | /// |
| 169 | /// @param[in] value Position in range to set with integer | 162 | /// @param[in] value Position in range to set with integer |
| 170 | /// | 163 | /// |
| 171 | /// @note Percent, floating point or integer are alone possible. Combining | 164 | /// @note Percent, floating point or integer are alone possible. Combining |
| 172 | /// these different values can be not together and can, therefore, only one | 165 | /// these different values can be not together and can, therefore, only one |
| 173 | /// each can be used. | 166 | /// each can be used. |
| 174 | /// | 167 | /// |
| 175 | void SetIntValue(int value) | 168 | void SetIntValue(int value) |
| @@ -177,17 +170,16 @@ public: | |||
| 177 | m_interface->kodi_gui->control_slider->set_int_value(m_interface->kodiBase, m_controlHandle, | 170 | m_interface->kodi_gui->control_slider->set_int_value(m_interface->kodiBase, m_controlHandle, |
| 178 | value); | 171 | value); |
| 179 | } | 172 | } |
| 180 | //-------------------------------------------------------------------------- | 173 | //---------------------------------------------------------------------------- |
| 181 | 174 | ||
| 182 | //========================================================================== | 175 | //============================================================================ |
| 183 | /// | 176 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 184 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 185 | /// @brief To get the current position as integer value. | 177 | /// @brief To get the current position as integer value. |
| 186 | /// | 178 | /// |
| 187 | /// @return The position as integer | 179 | /// @return The position as integer |
| 188 | /// | 180 | /// |
| 189 | /// @note Percent, floating point or integer are alone possible. Combining | 181 | /// @note Percent, floating point or integer are alone possible. Combining |
| 190 | /// these different values can be not together and can, therefore, only | 182 | /// these different values can be not together and can, therefore, only |
| 191 | /// one each can be used. | 183 | /// one each can be used. |
| 192 | /// | 184 | /// |
| 193 | int GetIntValue() const | 185 | int GetIntValue() const |
| @@ -195,19 +187,18 @@ public: | |||
| 195 | return m_interface->kodi_gui->control_slider->get_int_value(m_interface->kodiBase, | 187 | return m_interface->kodi_gui->control_slider->get_int_value(m_interface->kodiBase, |
| 196 | m_controlHandle); | 188 | m_controlHandle); |
| 197 | } | 189 | } |
| 198 | //-------------------------------------------------------------------------- | 190 | //---------------------------------------------------------------------------- |
| 199 | 191 | ||
| 200 | //========================================================================== | 192 | //============================================================================ |
| 201 | /// | 193 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 202 | /// \ingroup cpp_kodi_gui_controls_CSlider | 194 | /// @brief To set the interval steps of slider, as default is it 1. If it |
| 203 | /// @brief To set the interval steps of slider, as default is it 1. If it | 195 | /// becomes changed with this function will a step of the user with the |
| 204 | /// becomes changed with this function will a step of the user with the | ||
| 205 | /// value fixed here be executed. | 196 | /// value fixed here be executed. |
| 206 | /// | 197 | /// |
| 207 | /// @param[in] interval Intervall step to set. | 198 | /// @param[in] interval Intervall step to set. |
| 208 | /// | 199 | /// |
| 209 | /// @note Percent, floating point or integer are alone possible. Combining | 200 | /// @note Percent, floating point or integer are alone possible. Combining |
| 210 | /// these different values can be not together and can, therefore, only one | 201 | /// these different values can be not together and can, therefore, only one |
| 211 | /// each can be used. | 202 | /// each can be used. |
| 212 | /// | 203 | /// |
| 213 | void SetIntInterval(int interval) | 204 | void SetIntInterval(int interval) |
| @@ -215,17 +206,16 @@ public: | |||
| 215 | m_interface->kodi_gui->control_slider->set_int_interval(m_interface->kodiBase, m_controlHandle, | 206 | m_interface->kodi_gui->control_slider->set_int_interval(m_interface->kodiBase, m_controlHandle, |
| 216 | interval); | 207 | interval); |
| 217 | } | 208 | } |
| 218 | //-------------------------------------------------------------------------- | 209 | //---------------------------------------------------------------------------- |
| 219 | 210 | ||
| 220 | //========================================================================== | 211 | //============================================================================ |
| 221 | /// | 212 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 222 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 223 | /// @brief Sets the percent of the slider. | 213 | /// @brief Sets the percent of the slider. |
| 224 | /// | 214 | /// |
| 225 | /// @param[in] percent float - Percent value of slide | 215 | /// @param[in] percent float - Percent value of slide |
| 226 | /// | 216 | /// |
| 227 | /// @note Percent, floating point or integer are alone possible. Combining | 217 | /// @note Percent, floating point or integer are alone possible. Combining |
| 228 | /// these different values can be not together and can, therefore, only one | 218 | /// these different values can be not together and can, therefore, only one |
| 229 | /// each can be used. | 219 | /// each can be used. |
| 230 | /// | 220 | /// |
| 231 | void SetPercentage(float percent) | 221 | void SetPercentage(float percent) |
| @@ -233,17 +223,16 @@ public: | |||
| 233 | m_interface->kodi_gui->control_slider->set_percentage(m_interface->kodiBase, m_controlHandle, | 223 | m_interface->kodi_gui->control_slider->set_percentage(m_interface->kodiBase, m_controlHandle, |
| 234 | percent); | 224 | percent); |
| 235 | } | 225 | } |
| 236 | //-------------------------------------------------------------------------- | 226 | //---------------------------------------------------------------------------- |
| 237 | 227 | ||
| 238 | //========================================================================== | 228 | //============================================================================ |
| 239 | /// | 229 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 240 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 241 | /// @brief Returns a float of the percent of the slider. | 230 | /// @brief Returns a float of the percent of the slider. |
| 242 | /// | 231 | /// |
| 243 | /// @return float - Percent of slider | 232 | /// @return float - Percent of slider |
| 244 | /// | 233 | /// |
| 245 | /// @note Percent, floating point or integer are alone possible. Combining | 234 | /// @note Percent, floating point or integer are alone possible. Combining |
| 246 | /// these different values can be not together and can, therefore, only one | 235 | /// these different values can be not together and can, therefore, only one |
| 247 | /// each can be used. | 236 | /// each can be used. |
| 248 | /// | 237 | /// |
| 249 | float GetPercentage() const | 238 | float GetPercentage() const |
| @@ -251,13 +240,12 @@ public: | |||
| 251 | return m_interface->kodi_gui->control_slider->get_percentage(m_interface->kodiBase, | 240 | return m_interface->kodi_gui->control_slider->get_percentage(m_interface->kodiBase, |
| 252 | m_controlHandle); | 241 | m_controlHandle); |
| 253 | } | 242 | } |
| 254 | //-------------------------------------------------------------------------- | 243 | //---------------------------------------------------------------------------- |
| 255 | 244 | ||
| 256 | //========================================================================== | 245 | //============================================================================ |
| 257 | /// | 246 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 258 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 259 | /// @brief To set the the range as float of slider, e.g. -25.0 is the slider | 247 | /// @brief To set the the range as float of slider, e.g. -25.0 is the slider |
| 260 | /// start and e.g. +25.0 is the from here defined position where it reach | 248 | /// start and e.g. +25.0 is the from here defined position where it reach |
| 261 | /// the end. | 249 | /// the end. |
| 262 | /// | 250 | /// |
| 263 | /// As default is the range 0.0 to 1.0. | 251 | /// As default is the range 0.0 to 1.0. |
| @@ -265,11 +253,11 @@ public: | |||
| 265 | /// The float interval is as default 0.1 and can be changed with | 253 | /// The float interval is as default 0.1 and can be changed with |
| 266 | /// @ref SetFloatInterval. | 254 | /// @ref SetFloatInterval. |
| 267 | /// | 255 | /// |
| 268 | /// @param[in] start Integer start value | 256 | /// @param[in] start Integer start value |
| 269 | /// @param[in] end Integer end value | 257 | /// @param[in] end Integer end value |
| 270 | /// | 258 | /// |
| 271 | /// @note Percent, floating point or integer are alone possible. Combining | 259 | /// @note Percent, floating point or integer are alone possible. Combining |
| 272 | /// these different values can be not together and can, therefore, only | 260 | /// these different values can be not together and can, therefore, only |
| 273 | /// one each can be used. | 261 | /// one each can be used. |
| 274 | /// | 262 | /// |
| 275 | void SetFloatRange(float start, float end) | 263 | void SetFloatRange(float start, float end) |
| @@ -277,19 +265,18 @@ public: | |||
| 277 | m_interface->kodi_gui->control_slider->set_float_range(m_interface->kodiBase, m_controlHandle, | 265 | m_interface->kodi_gui->control_slider->set_float_range(m_interface->kodiBase, m_controlHandle, |
| 278 | start, end); | 266 | start, end); |
| 279 | } | 267 | } |
| 280 | //-------------------------------------------------------------------------- | 268 | //---------------------------------------------------------------------------- |
| 281 | 269 | ||
| 282 | //========================================================================== | 270 | //============================================================================ |
| 283 | /// | 271 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 284 | /// \ingroup cpp_kodi_gui_controls_CSlider | 272 | /// @brief Set the slider position with the given float value. The Range |
| 285 | /// @brief Set the slider position with the given float value. The Range | 273 | /// can be defined with a call from @ref SetIntRange before, as default it |
| 286 | /// can be defined with a call from \ref SetIntRange before, as default it | ||
| 287 | /// is 0.0 to 1.0. | 274 | /// is 0.0 to 1.0. |
| 288 | /// | 275 | /// |
| 289 | /// @param[in] value Position in range to set with float | 276 | /// @param[in] value Position in range to set with float |
| 290 | /// | 277 | /// |
| 291 | /// @note Percent, floating point or integer are alone possible. Combining | 278 | /// @note Percent, floating point or integer are alone possible. Combining |
| 292 | /// these different values can be not together and can, therefore, only one | 279 | /// these different values can be not together and can, therefore, only one |
| 293 | /// each can be used. | 280 | /// each can be used. |
| 294 | /// | 281 | /// |
| 295 | void SetFloatValue(float value) | 282 | void SetFloatValue(float value) |
| @@ -297,33 +284,31 @@ public: | |||
| 297 | m_interface->kodi_gui->control_slider->set_float_value(m_interface->kodiBase, m_controlHandle, | 284 | m_interface->kodi_gui->control_slider->set_float_value(m_interface->kodiBase, m_controlHandle, |
| 298 | value); | 285 | value); |
| 299 | } | 286 | } |
| 300 | //-------------------------------------------------------------------------- | 287 | //---------------------------------------------------------------------------- |
| 301 | 288 | ||
| 302 | //========================================================================== | 289 | //============================================================================ |
| 303 | /// | 290 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 304 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 305 | /// @brief To get the current position as float value. | 291 | /// @brief To get the current position as float value. |
| 306 | /// | 292 | /// |
| 307 | /// @return The position as float | 293 | /// @return The position as float |
| 308 | /// | 294 | /// |
| 309 | float GetFloatValue() const | 295 | float GetFloatValue() const |
| 310 | { | 296 | { |
| 311 | return m_interface->kodi_gui->control_slider->get_float_value(m_interface->kodiBase, | 297 | return m_interface->kodi_gui->control_slider->get_float_value(m_interface->kodiBase, |
| 312 | m_controlHandle); | 298 | m_controlHandle); |
| 313 | } | 299 | } |
| 314 | //-------------------------------------------------------------------------- | 300 | //---------------------------------------------------------------------------- |
| 315 | 301 | ||
| 316 | //========================================================================== | 302 | //============================================================================ |
| 317 | /// | 303 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider |
| 318 | /// \ingroup cpp_kodi_gui_controls_CSlider | 304 | /// @brief To set the interval steps of slider, as default is it 0.1 If it |
| 319 | /// @brief To set the interval steps of slider, as default is it 0.1 If it | 305 | /// becomes changed with this function will a step of the user with the |
| 320 | /// becomes changed with this function will a step of the user with the | ||
| 321 | /// value fixed here be executed. | 306 | /// value fixed here be executed. |
| 322 | /// | 307 | /// |
| 323 | /// @param[in] interval Intervall step to set. | 308 | /// @param[in] interval Intervall step to set. |
| 324 | /// | 309 | /// |
| 325 | /// @note Percent, floating point or integer are alone possible. Combining | 310 | /// @note Percent, floating point or integer are alone possible. Combining |
| 326 | /// these different values can be not together and can, therefore, only | 311 | /// these different values can be not together and can, therefore, only |
| 327 | /// one each can be used. | 312 | /// one each can be used. |
| 328 | /// | 313 | /// |
| 329 | void SetFloatInterval(float interval) | 314 | void SetFloatInterval(float interval) |
| @@ -331,9 +316,11 @@ public: | |||
| 331 | m_interface->kodi_gui->control_slider->set_float_interval(m_interface->kodiBase, | 316 | m_interface->kodi_gui->control_slider->set_float_interval(m_interface->kodiBase, |
| 332 | m_controlHandle, interval); | 317 | m_controlHandle, interval); |
| 333 | } | 318 | } |
| 334 | //-------------------------------------------------------------------------- | 319 | //---------------------------------------------------------------------------- |
| 335 | }; | 320 | }; |
| 336 | 321 | ||
| 337 | } /* namespace controls */ | 322 | } /* namespace controls */ |
| 338 | } /* namespace gui */ | 323 | } /* namespace gui */ |
| 339 | } /* namespace kodi */ | 324 | } /* namespace kodi */ |
| 325 | |||
| 326 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h new file mode 100644 index 0000000..6c55243 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h | |||
| @@ -0,0 +1,416 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../c-api/gui/controls/spin.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace controls | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CSpin Control Spin | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CSpin } | ||
| 27 | /// **Window control used for cycling up/down controls**\n | ||
| 28 | /// The settings spin control is used in the settings screens for when a list | ||
| 29 | /// of options can be chosen from using up/down arrows. | ||
| 30 | /// | ||
| 31 | /// You can choose the position, size, and look of the spin control. It is | ||
| 32 | /// basically a cross between the button control and a spin control. It has a | ||
| 33 | /// label and focus and non focus textures, as well as a spin control on the | ||
| 34 | /// right. | ||
| 35 | /// | ||
| 36 | /// It has the header @ref Spin.h "#include <kodi/gui/controls/Spin.h>" | ||
| 37 | /// be included to enjoy it. | ||
| 38 | /// | ||
| 39 | /// Here you find the needed skin part for a @ref Spin_Control "spin control". | ||
| 40 | /// | ||
| 41 | /// @note The call of the control is only possible from the corresponding | ||
| 42 | /// window as its class and identification number is required. | ||
| 43 | /// | ||
| 44 | /// -------------------------------------------------------------------------- | ||
| 45 | /// **Example:** | ||
| 46 | /// ~~~~~~~~~~~~cpp | ||
| 47 | /// #include <kodi/gui/Window.h> | ||
| 48 | /// | ||
| 49 | /// #define MY_SPIN_CONTROL 1 | ||
| 50 | /// | ||
| 51 | /// class CMyWindow : public kodi::gui::CWindow | ||
| 52 | /// { | ||
| 53 | /// public: | ||
| 54 | /// CMyWindow() | ||
| 55 | /// | ||
| 56 | /// void ShowWindow(); | ||
| 57 | /// | ||
| 58 | /// bool OnInit() override; | ||
| 59 | /// bool OnClick(int controlId) override; | ||
| 60 | /// | ||
| 61 | /// private: | ||
| 62 | /// kodi::gui::controls::CSpin m_mySpinControl; | ||
| 63 | /// }; | ||
| 64 | /// | ||
| 65 | /// CMyWindow::CMyWindow() | ||
| 66 | /// : kodi::gui::CWindow("my_skin.xml", "skin.estuary", true, false), | ||
| 67 | /// m_mySpinControl(this, MY_SPIN_CONTROL) | ||
| 68 | /// { | ||
| 69 | /// } | ||
| 70 | /// | ||
| 71 | /// void CMyWindow::ShowWindow() | ||
| 72 | /// { | ||
| 73 | /// kodi::gui::CWindow::DoModal(); | ||
| 74 | /// } | ||
| 75 | /// | ||
| 76 | /// bool CMyWindow::OnInit() | ||
| 77 | /// { | ||
| 78 | /// m_mySpinControl.SetType(kodi::gui::controls::ADDON_SPIN_CONTROL_TYPE_INT); | ||
| 79 | /// m_mySpinControl.SetIntRange(1, 80); | ||
| 80 | /// return true; | ||
| 81 | /// } | ||
| 82 | /// | ||
| 83 | /// bool CMyWindow::OnClick(int controlId) | ||
| 84 | /// { | ||
| 85 | /// if (controlId == MY_SPIN_CONTROL) | ||
| 86 | /// { | ||
| 87 | /// int value = m_mySpinControl.GetIntValue(); | ||
| 88 | /// ... | ||
| 89 | /// } | ||
| 90 | /// return true; | ||
| 91 | /// } | ||
| 92 | /// return false; | ||
| 93 | /// } | ||
| 94 | /// ~~~~~~~~~~~~ | ||
| 95 | /// | ||
| 96 | |||
| 97 | |||
| 98 | //============================================================================== | ||
| 99 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 100 | /// @anchor AddonGUISpinControlType | ||
| 101 | /// @brief The values here defines the used value format for steps on | ||
| 102 | /// spin control. | ||
| 103 | /// | ||
| 104 | typedef enum AddonGUISpinControlType | ||
| 105 | { | ||
| 106 | /// One spin step interpreted as integer | ||
| 107 | ADDON_SPIN_CONTROL_TYPE_INT = 1, | ||
| 108 | /// One spin step interpreted as floating point value | ||
| 109 | ADDON_SPIN_CONTROL_TYPE_FLOAT = 2, | ||
| 110 | /// One spin step interpreted as text string | ||
| 111 | ADDON_SPIN_CONTROL_TYPE_TEXT = 3, | ||
| 112 | /// One spin step interpreted as a page change value | ||
| 113 | ADDON_SPIN_CONTROL_TYPE_PAGE = 4 | ||
| 114 | } AddonGUISpinControlType; | ||
| 115 | //------------------------------------------------------------------------------ | ||
| 116 | |||
| 117 | class ATTRIBUTE_HIDDEN CSpin : public CAddonGUIControlBase | ||
| 118 | { | ||
| 119 | public: | ||
| 120 | //============================================================================ | ||
| 121 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 122 | /// @brief Construct a new control. | ||
| 123 | /// | ||
| 124 | /// @param[in] window Related window control class | ||
| 125 | /// @param[in] controlId Used skin xml control id | ||
| 126 | /// | ||
| 127 | CSpin(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 128 | { | ||
| 129 | m_controlHandle = m_interface->kodi_gui->window->get_control_spin( | ||
| 130 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 131 | if (!m_controlHandle) | ||
| 132 | kodi::Log(ADDON_LOG_FATAL, | ||
| 133 | "kodi::gui::controls::CSpin can't create control class from Kodi !!!"); | ||
| 134 | } | ||
| 135 | //---------------------------------------------------------------------------- | ||
| 136 | |||
| 137 | //============================================================================ | ||
| 138 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 139 | /// @brief Destructor. | ||
| 140 | /// | ||
| 141 | ~CSpin() override = default; | ||
| 142 | //---------------------------------------------------------------------------- | ||
| 143 | |||
| 144 | //============================================================================ | ||
| 145 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 146 | /// @brief Set the control on window to visible. | ||
| 147 | /// | ||
| 148 | /// @param[in] visible If true visible, otherwise hidden | ||
| 149 | /// | ||
| 150 | void SetVisible(bool visible) | ||
| 151 | { | ||
| 152 | m_interface->kodi_gui->control_spin->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 153 | visible); | ||
| 154 | } | ||
| 155 | //---------------------------------------------------------------------------- | ||
| 156 | |||
| 157 | //============================================================================ | ||
| 158 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 159 | /// @brief Set's the control's enabled/disabled state. | ||
| 160 | /// | ||
| 161 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 162 | /// | ||
| 163 | void SetEnabled(bool enabled) | ||
| 164 | { | ||
| 165 | m_interface->kodi_gui->control_spin->set_enabled(m_interface->kodiBase, m_controlHandle, | ||
| 166 | enabled); | ||
| 167 | } | ||
| 168 | //---------------------------------------------------------------------------- | ||
| 169 | |||
| 170 | //============================================================================ | ||
| 171 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 172 | /// @brief To set the text string on spin control. | ||
| 173 | /// | ||
| 174 | /// @param[in] text Text to show as name for spin | ||
| 175 | /// | ||
| 176 | void SetText(const std::string& text) | ||
| 177 | { | ||
| 178 | m_interface->kodi_gui->control_spin->set_text(m_interface->kodiBase, m_controlHandle, | ||
| 179 | text.c_str()); | ||
| 180 | } | ||
| 181 | //---------------------------------------------------------------------------- | ||
| 182 | |||
| 183 | //============================================================================ | ||
| 184 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 185 | /// @brief To reset spin control to defaults. | ||
| 186 | /// | ||
| 187 | void Reset() | ||
| 188 | { | ||
| 189 | m_interface->kodi_gui->control_spin->reset(m_interface->kodiBase, m_controlHandle); | ||
| 190 | } | ||
| 191 | //---------------------------------------------------------------------------- | ||
| 192 | |||
| 193 | //============================================================================ | ||
| 194 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 195 | /// @brief To set the with SpinControlType defined types of spin. | ||
| 196 | /// | ||
| 197 | /// @param[in] type The type to use | ||
| 198 | /// | ||
| 199 | /// @note See description of @ref AddonGUISpinControlType for available types. | ||
| 200 | /// | ||
| 201 | void SetType(AddonGUISpinControlType type) | ||
| 202 | { | ||
| 203 | m_interface->kodi_gui->control_spin->set_type(m_interface->kodiBase, m_controlHandle, | ||
| 204 | (int)type); | ||
| 205 | } | ||
| 206 | //---------------------------------------------------------------------------- | ||
| 207 | |||
| 208 | //============================================================================ | ||
| 209 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 210 | /// @brief To add a label entry in spin defined with a value as string. | ||
| 211 | /// | ||
| 212 | /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 213 | /// | ||
| 214 | /// @param[in] label Label string to view on skin | ||
| 215 | /// @param[in] value String value to use for selection of them | ||
| 216 | /// | ||
| 217 | void AddLabel(const std::string& label, const std::string& value) | ||
| 218 | { | ||
| 219 | m_interface->kodi_gui->control_spin->add_string_label(m_interface->kodiBase, m_controlHandle, | ||
| 220 | label.c_str(), value.c_str()); | ||
| 221 | } | ||
| 222 | //---------------------------------------------------------------------------- | ||
| 223 | |||
| 224 | //============================================================================ | ||
| 225 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 226 | /// @brief To add a label entry in spin defined with a value as integer. | ||
| 227 | /// | ||
| 228 | /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_INT to use this function. | ||
| 229 | /// | ||
| 230 | /// @param[in] label Label string to view on skin | ||
| 231 | /// @param[in] value Integer value to use for selection of them. | ||
| 232 | /// | ||
| 233 | void AddLabel(const std::string& label, int value) | ||
| 234 | { | ||
| 235 | m_interface->kodi_gui->control_spin->add_int_label(m_interface->kodiBase, m_controlHandle, | ||
| 236 | label.c_str(), value); | ||
| 237 | } | ||
| 238 | //---------------------------------------------------------------------------- | ||
| 239 | |||
| 240 | //============================================================================ | ||
| 241 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 242 | /// @brief To change the spin to position with them string as value. | ||
| 243 | /// | ||
| 244 | /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 245 | /// | ||
| 246 | /// @param[in] value String value to change to | ||
| 247 | /// | ||
| 248 | void SetStringValue(const std::string& value) | ||
| 249 | { | ||
| 250 | m_interface->kodi_gui->control_spin->set_string_value(m_interface->kodiBase, m_controlHandle, | ||
| 251 | value.c_str()); | ||
| 252 | } | ||
| 253 | //---------------------------------------------------------------------------- | ||
| 254 | |||
| 255 | //============================================================================ | ||
| 256 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 257 | /// @brief To get the current spin control position with text string value. | ||
| 258 | /// | ||
| 259 | /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 260 | /// | ||
| 261 | /// @return Currently selected string value | ||
| 262 | /// | ||
| 263 | std::string GetStringValue() const | ||
| 264 | { | ||
| 265 | std::string value; | ||
| 266 | char* ret = m_interface->kodi_gui->control_spin->get_string_value(m_interface->kodiBase, | ||
| 267 | m_controlHandle); | ||
| 268 | if (ret != nullptr) | ||
| 269 | { | ||
| 270 | if (std::strlen(ret)) | ||
| 271 | value = ret; | ||
| 272 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 273 | } | ||
| 274 | return value; | ||
| 275 | } | ||
| 276 | //---------------------------------------------------------------------------- | ||
| 277 | |||
| 278 | //============================================================================ | ||
| 279 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 280 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | ||
| 281 | /// start and e.g. +10 is the from here defined position where it reach the | ||
| 282 | /// end. | ||
| 283 | /// | ||
| 284 | /// Ad default is the range from 0 to 100. | ||
| 285 | /// | ||
| 286 | /// @param[in] start Integer start value | ||
| 287 | /// @param[in] end Integer end value | ||
| 288 | /// | ||
| 289 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 290 | /// these different values can be not together and can, therefore, only | ||
| 291 | /// one each can be used and must be defined with @ref SetType before. | ||
| 292 | /// | ||
| 293 | void SetIntRange(int start, int end) | ||
| 294 | { | ||
| 295 | m_interface->kodi_gui->control_spin->set_int_range(m_interface->kodiBase, m_controlHandle, | ||
| 296 | start, end); | ||
| 297 | } | ||
| 298 | //---------------------------------------------------------------------------- | ||
| 299 | |||
| 300 | //============================================================================ | ||
| 301 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 302 | /// @brief Set the slider position with the given integer value. The Range | ||
| 303 | /// must be defined with a call from @ref SetIntRange before. | ||
| 304 | /// | ||
| 305 | /// @param[in] value Position in range to set with integer | ||
| 306 | /// | ||
| 307 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 308 | /// these different values can be not together and can, therefore, only | ||
| 309 | /// one each can be used and must be defined with @ref SetType before. | ||
| 310 | /// | ||
| 311 | void SetIntValue(int value) | ||
| 312 | { | ||
| 313 | m_interface->kodi_gui->control_spin->set_int_value(m_interface->kodiBase, m_controlHandle, | ||
| 314 | value); | ||
| 315 | } | ||
| 316 | //---------------------------------------------------------------------------- | ||
| 317 | |||
| 318 | //============================================================================ | ||
| 319 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 320 | /// @brief To get the current position as integer value. | ||
| 321 | /// | ||
| 322 | /// @return The position as integer | ||
| 323 | /// | ||
| 324 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 325 | /// these different values can be not together and can, therefore, only | ||
| 326 | /// one each can be used and must be defined with @ref SetType before. | ||
| 327 | /// | ||
| 328 | int GetIntValue() const | ||
| 329 | { | ||
| 330 | return m_interface->kodi_gui->control_spin->get_int_value(m_interface->kodiBase, | ||
| 331 | m_controlHandle); | ||
| 332 | } | ||
| 333 | //---------------------------------------------------------------------------- | ||
| 334 | |||
| 335 | //============================================================================ | ||
| 336 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 337 | /// @brief To set the the range as float of spin, e.g. -25.0 is the spin | ||
| 338 | /// start and e.g. +25.0 is the from here defined position where it reach | ||
| 339 | /// the end. | ||
| 340 | /// | ||
| 341 | /// As default is the range 0.0 to 1.0. | ||
| 342 | /// | ||
| 343 | /// The float interval is as default 0.1 and can be changed with | ||
| 344 | /// @ref SetFloatInterval. | ||
| 345 | /// | ||
| 346 | /// @param[in] start Integer start value | ||
| 347 | /// @param[in] end Integer end value | ||
| 348 | /// | ||
| 349 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 350 | /// these different values can be not together and can, therefore, only | ||
| 351 | /// one each can be used and must be defined with @ref SetType before. | ||
| 352 | /// | ||
| 353 | void SetFloatRange(float start, float end) | ||
| 354 | { | ||
| 355 | m_interface->kodi_gui->control_spin->set_float_range(m_interface->kodiBase, m_controlHandle, | ||
| 356 | start, end); | ||
| 357 | } | ||
| 358 | //---------------------------------------------------------------------------- | ||
| 359 | |||
| 360 | //============================================================================ | ||
| 361 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 362 | /// @brief Set the spin position with the given float value. The Range | ||
| 363 | /// can be defined with a call from @ref SetIntRange before, as default it | ||
| 364 | /// is 0.0 to 1.0. | ||
| 365 | /// | ||
| 366 | /// @param[in] value Position in range to set with float | ||
| 367 | /// | ||
| 368 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 369 | /// these different values can be not together and can, therefore, only | ||
| 370 | /// one each can be used and must be defined with @ref SetType before. | ||
| 371 | /// | ||
| 372 | void SetFloatValue(float value) | ||
| 373 | { | ||
| 374 | m_interface->kodi_gui->control_spin->set_float_value(m_interface->kodiBase, m_controlHandle, | ||
| 375 | value); | ||
| 376 | } | ||
| 377 | //---------------------------------------------------------------------------- | ||
| 378 | |||
| 379 | //============================================================================ | ||
| 380 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 381 | /// @brief To get the current position as float value. | ||
| 382 | /// | ||
| 383 | /// @return The position as float | ||
| 384 | /// | ||
| 385 | float GetFloatValue() const | ||
| 386 | { | ||
| 387 | return m_interface->kodi_gui->control_spin->get_float_value(m_interface->kodiBase, | ||
| 388 | m_controlHandle); | ||
| 389 | } | ||
| 390 | //---------------------------------------------------------------------------- | ||
| 391 | |||
| 392 | //============================================================================ | ||
| 393 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 394 | /// @brief To set the interval steps of spin, as default is it 0.1 If it | ||
| 395 | /// becomes changed with this function will a step of the user with the | ||
| 396 | /// value fixed here be executed. | ||
| 397 | /// | ||
| 398 | /// @param[in] interval Intervall step to set. | ||
| 399 | /// | ||
| 400 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 401 | /// these different values can be not together and can, therefore, only | ||
| 402 | /// one each can be used and must be defined with @ref SetType before. | ||
| 403 | /// | ||
| 404 | void SetFloatInterval(float interval) | ||
| 405 | { | ||
| 406 | m_interface->kodi_gui->control_spin->set_float_interval(m_interface->kodiBase, m_controlHandle, | ||
| 407 | interval); | ||
| 408 | } | ||
| 409 | //---------------------------------------------------------------------------- | ||
| 410 | }; | ||
| 411 | |||
| 412 | } /* namespace controls */ | ||
| 413 | } /* namespace gui */ | ||
| 414 | } /* namespace kodi */ | ||
| 415 | |||
| 416 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/TextBox.h index b4e8ae0..2634568 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/TextBox.h | |||
| @@ -8,9 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../../AddonBase.h" | 11 | #include "../../c-api/gui/controls/text_box.h" |
| 12 | #include "../Window.h" | 12 | #include "../Window.h" |
| 13 | 13 | ||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 14 | namespace kodi | 16 | namespace kodi |
| 15 | { | 17 | { |
| 16 | namespace gui | 18 | namespace gui |
| @@ -19,34 +21,33 @@ namespace controls | |||
| 19 | { | 21 | { |
| 20 | 22 | ||
| 21 | //============================================================================ | 23 | //============================================================================ |
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CTextBox Control Text Box | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CTextBox } | ||
| 27 | /// **Used to show a multi-page piece of text**\n | ||
| 28 | /// The text box control can be used to display descriptions, help texts or | ||
| 29 | /// other larger texts. | ||
| 22 | /// | 30 | /// |
| 23 | /// \defgroup cpp_kodi_gui_controls_CTextBox Control Text Box | 31 | /// It corresponds to the representation which is also to be seen on the |
| 24 | /// \ingroup cpp_kodi_gui | 32 | /// @ref CDialogTextViewer. |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CTextBox } | ||
| 26 | /// **Used to show a multi-page piece of text** | ||
| 27 | /// | ||
| 28 | /// The text box control can be used to display descriptions, help texts or | ||
| 29 | /// other larger texts. It corresponds to the representation which is also to | ||
| 30 | /// be seen on the CDialogTextViewer. | ||
| 31 | /// | 33 | /// |
| 32 | /// It has the header \ref TextBox.h "#include <kodi/gui/controls/TextBox.h>" | 34 | /// It has the header @ref TextBox.h "#include <kodi/gui/controls/TextBox.h>" |
| 33 | /// be included to enjoy it. | 35 | /// be included to enjoy it. |
| 34 | /// | 36 | /// |
| 35 | /// Here you find the needed skin part for a \ref Text_Box "textbox control". | 37 | /// Here you find the needed skin part for a @ref Text_Box "textbox control". |
| 36 | /// | 38 | /// |
| 37 | /// @note The call of the control is only possible from the corresponding | 39 | /// @note The call of the control is only possible from the corresponding |
| 38 | /// window as its class and identification number is required. | 40 | /// window as its class and identification number is required. |
| 39 | /// | 41 | /// |
| 40 | class ATTRIBUTE_HIDDEN CTextBox : public CAddonGUIControlBase | 42 | class ATTRIBUTE_HIDDEN CTextBox : public CAddonGUIControlBase |
| 41 | { | 43 | { |
| 42 | public: | 44 | public: |
| 43 | //========================================================================== | 45 | //========================================================================== |
| 46 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox | ||
| 47 | /// @brief Construct a new control. | ||
| 44 | /// | 48 | /// |
| 45 | /// \ingroup cpp_kodi_gui_controls_CTextBox | 49 | /// @param[in] window related window control class |
| 46 | /// @brief Construct a new control | 50 | /// @param[in] controlId Used skin xml control id |
| 47 | /// | ||
| 48 | /// @param[in] window related window control class | ||
| 49 | /// @param[in] controlId Used skin xml control id | ||
| 50 | /// | 51 | /// |
| 51 | CTextBox(CWindow* window, int controlId) : CAddonGUIControlBase(window) | 52 | CTextBox(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 52 | { | 53 | { |
| @@ -59,19 +60,17 @@ public: | |||
| 59 | //-------------------------------------------------------------------------- | 60 | //-------------------------------------------------------------------------- |
| 60 | 61 | ||
| 61 | //========================================================================== | 62 | //========================================================================== |
| 62 | /// | 63 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox |
| 63 | /// \ingroup cpp_kodi_gui_controls_CTextBox | 64 | /// @brief Destructor. |
| 64 | /// @brief Destructor | ||
| 65 | /// | 65 | /// |
| 66 | ~CTextBox() override = default; | 66 | ~CTextBox() override = default; |
| 67 | //-------------------------------------------------------------------------- | 67 | //-------------------------------------------------------------------------- |
| 68 | 68 | ||
| 69 | //========================================================================== | 69 | //========================================================================== |
| 70 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox | ||
| 71 | /// @brief Set the control on window to visible. | ||
| 70 | /// | 72 | /// |
| 71 | /// \ingroup cpp_kodi_gui_controls_CTextBox | 73 | /// @param[in] visible If true visible, otherwise hidden |
| 72 | /// @brief Set the control on window to visible | ||
| 73 | /// | ||
| 74 | /// @param[in] visible If true visible, otherwise hidden | ||
| 75 | /// | 74 | /// |
| 76 | void SetVisible(bool visible) | 75 | void SetVisible(bool visible) |
| 77 | { | 76 | { |
| @@ -81,19 +80,17 @@ public: | |||
| 81 | //-------------------------------------------------------------------------- | 80 | //-------------------------------------------------------------------------- |
| 82 | 81 | ||
| 83 | //========================================================================== | 82 | //========================================================================== |
| 84 | /// | 83 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox |
| 85 | /// \ingroup cpp_kodi_gui_controls_CTextBox | 84 | /// @brief To reset box an remove all the text. |
| 86 | /// @brief To reset box an remove all the text | ||
| 87 | /// | 85 | /// |
| 88 | void Reset() { m_interface->kodi_gui->control_text_box->reset(m_controlHandle, m_controlHandle); } | 86 | void Reset() { m_interface->kodi_gui->control_text_box->reset(m_controlHandle, m_controlHandle); } |
| 89 | //-------------------------------------------------------------------------- | 87 | //-------------------------------------------------------------------------- |
| 90 | 88 | ||
| 91 | //========================================================================== | 89 | //========================================================================== |
| 90 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox | ||
| 91 | /// @brief To set the text on box. | ||
| 92 | /// | 92 | /// |
| 93 | /// \ingroup cpp_kodi_gui_controls_CTextBox | 93 | /// @param[in] text Text to show |
| 94 | /// @brief To set the text on box | ||
| 95 | /// | ||
| 96 | /// @param[in] text Text to show | ||
| 97 | /// | 94 | /// |
| 98 | void SetText(const std::string& text) | 95 | void SetText(const std::string& text) |
| 99 | { | 96 | { |
| @@ -103,11 +100,10 @@ public: | |||
| 103 | //-------------------------------------------------------------------------- | 100 | //-------------------------------------------------------------------------- |
| 104 | 101 | ||
| 105 | //========================================================================== | 102 | //========================================================================== |
| 103 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox | ||
| 104 | /// @brief Get the used text from control. | ||
| 106 | /// | 105 | /// |
| 107 | /// \ingroup cpp_kodi_gui_controls_CTextBox | 106 | /// @return Text shown |
| 108 | /// @brief Get the used text from control | ||
| 109 | /// | ||
| 110 | /// @return Text shown | ||
| 111 | /// | 107 | /// |
| 112 | std::string GetText() const | 108 | std::string GetText() const |
| 113 | { | 109 | { |
| @@ -125,11 +121,10 @@ public: | |||
| 125 | //-------------------------------------------------------------------------- | 121 | //-------------------------------------------------------------------------- |
| 126 | 122 | ||
| 127 | //========================================================================== | 123 | //========================================================================== |
| 124 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox | ||
| 125 | /// @brief To scroll text on other position. | ||
| 128 | /// | 126 | /// |
| 129 | /// \ingroup cpp_kodi_gui_controls_CTextBox | 127 | /// @param[in] position The line position to scroll to |
| 130 | /// @brief To scroll text on other position | ||
| 131 | /// | ||
| 132 | /// @param[in] position The line position to scroll to | ||
| 133 | /// | 128 | /// |
| 134 | void Scroll(unsigned int position) | 129 | void Scroll(unsigned int position) |
| 135 | { | 130 | { |
| @@ -139,8 +134,7 @@ public: | |||
| 139 | //-------------------------------------------------------------------------- | 134 | //-------------------------------------------------------------------------- |
| 140 | 135 | ||
| 141 | //========================================================================== | 136 | //========================================================================== |
| 142 | /// | 137 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox |
| 143 | /// \ingroup cpp_kodi_gui_controls_CTextBox | ||
| 144 | /// @brief To set automatic scrolling of textbox | 138 | /// @brief To set automatic scrolling of textbox |
| 145 | /// | 139 | /// |
| 146 | /// Specifies the timing and conditions of any autoscrolling this textbox | 140 | /// Specifies the timing and conditions of any autoscrolling this textbox |
| @@ -150,10 +144,10 @@ public: | |||
| 150 | /// time, fades out over 1 second, and repeats. It does not wrap or reset | 144 | /// time, fades out over 1 second, and repeats. It does not wrap or reset |
| 151 | /// to the top at the end of the scroll. | 145 | /// to the top at the end of the scroll. |
| 152 | /// | 146 | /// |
| 153 | /// @param[in] delay Content delay | 147 | /// @param[in] delay Content delay |
| 154 | /// @param[in] time One line per time interval | 148 | /// @param[in] time One line per time interval |
| 155 | /// @param[in] repeat Delays with given time, fades out over 1 | 149 | /// @param[in] repeat Delays with given time, fades out over 1 second, and |
| 156 | /// second, and repeats | 150 | /// repeats |
| 157 | /// | 151 | /// |
| 158 | void SetAutoScrolling(int delay, int time, int repeat) | 152 | void SetAutoScrolling(int delay, int time, int repeat) |
| 159 | { | 153 | { |
| @@ -166,3 +160,5 @@ public: | |||
| 166 | } /* namespace controls */ | 160 | } /* namespace controls */ |
| 167 | } /* namespace gui */ | 161 | } /* namespace gui */ |
| 168 | } /* namespace kodi */ | 162 | } /* namespace kodi */ |
| 163 | |||
| 164 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/CMakeLists.txt index 7227343..9aaee4f 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/CMakeLists.txt +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/CMakeLists.txt | |||
| @@ -10,5 +10,5 @@ set(HEADERS ContextMenu.h | |||
| 10 | YesNo.h) | 10 | YesNo.h) |
| 11 | 11 | ||
| 12 | if(NOT ENABLE_STATIC_LIBS) | 12 | if(NOT ENABLE_STATIC_LIBS) |
| 13 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_gui_dialogs) | 13 | core_add_library(addons_kodi-dev-kit_include_kodi_gui_dialogs) |
| 14 | endif() | 14 | endif() |
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/ContextMenu.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/ContextMenu.h new file mode 100644 index 0000000..b576b9a --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/ContextMenu.h | |||
| @@ -0,0 +1,186 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../AddonBase.h" | ||
| 12 | #include "../../c-api/gui/dialogs/context_menu.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace dialogs | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_dialogs_ContextMenu Dialog Context Menu | ||
| 25 | /// @ingroup cpp_kodi_gui_dialogs | ||
| 26 | /// @brief @cpp_namespace{ kodi::gui::dialogs::ContextMenu } | ||
| 27 | /// **Context menu dialog**@n | ||
| 28 | /// The function listed below permits the call of a dialogue as context menu to | ||
| 29 | /// select of an entry as a key | ||
| 30 | /// | ||
| 31 | /// It has the header @ref ContextMenu.h "#include <kodi/gui/dialogs/ContextMenu.h>" | ||
| 32 | /// be included to enjoy it. | ||
| 33 | /// | ||
| 34 | /// | ||
| 35 | namespace ContextMenu | ||
| 36 | { | ||
| 37 | //============================================================================== | ||
| 38 | /// @ingroup cpp_kodi_gui_dialogs_ContextMenu | ||
| 39 | /// @brief Show a context menu dialog about given parts. | ||
| 40 | /// | ||
| 41 | /// @param[in] heading Dialog heading name | ||
| 42 | /// @param[in] entries String list about entries | ||
| 43 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled | ||
| 44 | /// | ||
| 45 | /// | ||
| 46 | ///------------------------------------------------------------------------- | ||
| 47 | /// | ||
| 48 | /// **Example:** | ||
| 49 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 50 | /// #include <kodi/gui/dialogs/ContextMenu.h> | ||
| 51 | /// | ||
| 52 | /// const std::vector<std::string> entries | ||
| 53 | /// { | ||
| 54 | /// "Test 1", | ||
| 55 | /// "Test 2", | ||
| 56 | /// "Test 3", | ||
| 57 | /// "Test 4", | ||
| 58 | /// "Test 5" | ||
| 59 | /// }; | ||
| 60 | /// | ||
| 61 | /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries); | ||
| 62 | /// if (selected < 0) | ||
| 63 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 64 | /// else | ||
| 65 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 66 | /// ~~~~~~~~~~~~~ | ||
| 67 | /// | ||
| 68 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 69 | const std::vector<std::string>& entries) | ||
| 70 | { | ||
| 71 | using namespace ::kodi::addon; | ||
| 72 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 73 | const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char**))); | ||
| 74 | for (unsigned int i = 0; i < size; ++i) | ||
| 75 | { | ||
| 76 | cEntries[i] = entries[i].c_str(); | ||
| 77 | } | ||
| 78 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open( | ||
| 79 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 80 | free(cEntries); | ||
| 81 | return ret; | ||
| 82 | } | ||
| 83 | //------------------------------------------------------------------------------ | ||
| 84 | |||
| 85 | //============================================================================== | ||
| 86 | /// @ingroup cpp_kodi_gui_dialogs_ContextMenu | ||
| 87 | /// @brief Show a context menu dialog about given parts. | ||
| 88 | /// | ||
| 89 | /// @param[in] heading Dialog heading name | ||
| 90 | /// @param[in] entries String list about entries | ||
| 91 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled | ||
| 92 | /// | ||
| 93 | /// | ||
| 94 | ///------------------------------------------------------------------------- | ||
| 95 | /// | ||
| 96 | /// **Example:** | ||
| 97 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 98 | /// #include <kodi/gui/dialogs/ContextMenu.h> | ||
| 99 | /// | ||
| 100 | /// const std::vector<std::pair<std::string, std::string>> entries | ||
| 101 | /// { | ||
| 102 | /// { "ID 1", "Test 1" }, | ||
| 103 | /// { "ID 2", "Test 2" }, | ||
| 104 | /// { "ID 3", "Test 3" }, | ||
| 105 | /// { "ID 4", "Test 4" }, | ||
| 106 | /// { "ID 5", "Test 5" } | ||
| 107 | /// }; | ||
| 108 | /// | ||
| 109 | /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries); | ||
| 110 | /// if (selected < 0) | ||
| 111 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 112 | /// else | ||
| 113 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 114 | /// ~~~~~~~~~~~~~ | ||
| 115 | /// | ||
| 116 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 117 | const std::vector<std::pair<std::string, std::string>>& entries) | ||
| 118 | { | ||
| 119 | using namespace ::kodi::addon; | ||
| 120 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 121 | const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char**))); | ||
| 122 | for (unsigned int i = 0; i < size; ++i) | ||
| 123 | { | ||
| 124 | cEntries[i] = entries[i].second.c_str(); | ||
| 125 | } | ||
| 126 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open( | ||
| 127 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 128 | free(cEntries); | ||
| 129 | return ret; | ||
| 130 | } | ||
| 131 | //------------------------------------------------------------------------------ | ||
| 132 | |||
| 133 | //============================================================================== | ||
| 134 | /// @ingroup cpp_kodi_gui_dialogs_ContextMenu | ||
| 135 | /// @brief Show a context menu dialog about given parts. | ||
| 136 | /// | ||
| 137 | /// @param[in] heading Dialog heading name | ||
| 138 | /// @param[in] entries String list about entries | ||
| 139 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled | ||
| 140 | /// | ||
| 141 | /// | ||
| 142 | ///------------------------------------------------------------------------- | ||
| 143 | /// | ||
| 144 | /// **Example:** | ||
| 145 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 146 | /// #include <kodi/gui/dialogs/ContextMenu.h> | ||
| 147 | /// | ||
| 148 | /// const std::vector<std::pair<int, std::string>> entries | ||
| 149 | /// { | ||
| 150 | /// { 1, "Test 1" }, | ||
| 151 | /// { 2, "Test 2" }, | ||
| 152 | /// { 3, "Test 3" }, | ||
| 153 | /// { 4, "Test 4" }, | ||
| 154 | /// { 5, "Test 5" } | ||
| 155 | /// }; | ||
| 156 | /// | ||
| 157 | /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries); | ||
| 158 | /// if (selected < 0) | ||
| 159 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 160 | /// else | ||
| 161 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 162 | /// ~~~~~~~~~~~~~ | ||
| 163 | /// | ||
| 164 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 165 | const std::vector<std::pair<int, std::string>>& entries) | ||
| 166 | { | ||
| 167 | using namespace ::kodi::addon; | ||
| 168 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 169 | const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char**))); | ||
| 170 | for (unsigned int i = 0; i < size; ++i) | ||
| 171 | { | ||
| 172 | cEntries[i] = entries[i].second.c_str(); | ||
| 173 | } | ||
| 174 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open( | ||
| 175 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 176 | free(cEntries); | ||
| 177 | return ret; | ||
| 178 | } | ||
| 179 | //------------------------------------------------------------------------------ | ||
| 180 | }; // namespace ContextMenu | ||
| 181 | |||
| 182 | } /* namespace dialogs */ | ||
| 183 | } /* namespace gui */ | ||
| 184 | } /* namespace kodi */ | ||
| 185 | |||
| 186 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h index 5a49b70..c650483 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h | |||
| @@ -8,8 +8,10 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | 11 | #include "../../AddonBase.h" |
| 12 | #include "../../c-api/gui/dialogs/extended_progress.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 13 | 15 | ||
| 14 | namespace kodi | 16 | namespace kodi |
| 15 | { | 17 | { |
| @@ -18,14 +20,13 @@ namespace gui | |||
| 18 | namespace dialogs | 20 | namespace dialogs |
| 19 | { | 21 | { |
| 20 | 22 | ||
| 21 | //============================================================================ | 23 | //============================================================================== |
| 22 | /// | 24 | /// @defgroup cpp_kodi_gui_dialogs_CExtendedProgress Dialog Extended Progress |
| 23 | /// \defgroup cpp_kodi_gui_dialogs_CExtendedProgress Dialog Extended Progress | 25 | /// @ingroup cpp_kodi_gui_dialogs |
| 24 | /// \ingroup cpp_kodi_gui | 26 | /// @brief @cpp_class{ kodi::gui::dialogs::ExtendedProgress } |
| 25 | /// @brief \cpp_class{ kodi::gui::dialogs::ExtendedProgress } | ||
| 26 | /// **Progress dialog shown for background work** | 27 | /// **Progress dialog shown for background work** |
| 27 | /// | 28 | /// |
| 28 | /// The with \ref ExtendedProgress.h "#include <kodi/gui/dialogs/ExtendedProgress.h>" | 29 | /// The with @ref ExtendedProgress.h "#include <kodi/gui/dialogs/ExtendedProgress.h>" |
| 29 | /// given class are basically used to create Kodi's extended progress. | 30 | /// given class are basically used to create Kodi's extended progress. |
| 30 | /// | 31 | /// |
| 31 | /// | 32 | /// |
| @@ -57,12 +58,11 @@ namespace dialogs | |||
| 57 | class ATTRIBUTE_HIDDEN CExtendedProgress | 58 | class ATTRIBUTE_HIDDEN CExtendedProgress |
| 58 | { | 59 | { |
| 59 | public: | 60 | public: |
| 60 | //========================================================================== | 61 | //============================================================================ |
| 62 | /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 63 | /// Construct a new dialog. | ||
| 61 | /// | 64 | /// |
| 62 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 65 | /// @param[in] title [opt] Title string |
| 63 | /// Construct a new dialog | ||
| 64 | /// | ||
| 65 | /// @param[in] title Title string | ||
| 66 | /// | 66 | /// |
| 67 | explicit CExtendedProgress(const std::string& title = "") | 67 | explicit CExtendedProgress(const std::string& title = "") |
| 68 | { | 68 | { |
| @@ -73,12 +73,11 @@ public: | |||
| 73 | kodi::Log(ADDON_LOG_FATAL, | 73 | kodi::Log(ADDON_LOG_FATAL, |
| 74 | "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!"); | 74 | "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!"); |
| 75 | } | 75 | } |
| 76 | //-------------------------------------------------------------------------- | 76 | //---------------------------------------------------------------------------- |
| 77 | 77 | ||
| 78 | //========================================================================== | 78 | //============================================================================ |
| 79 | /// | 79 | /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 80 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 80 | /// Destructor. |
| 81 | /// Destructor | ||
| 82 | /// | 81 | /// |
| 83 | ~CExtendedProgress() | 82 | ~CExtendedProgress() |
| 84 | { | 83 | { |
| @@ -87,12 +86,11 @@ public: | |||
| 87 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog( | 86 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog( |
| 88 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | 87 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); |
| 89 | } | 88 | } |
| 90 | //-------------------------------------------------------------------------- | 89 | //---------------------------------------------------------------------------- |
| 91 | 90 | ||
| 92 | //========================================================================== | 91 | //============================================================================ |
| 93 | /// | 92 | /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 94 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 93 | /// @brief Get the used title. |
| 95 | /// @brief Get the used title | ||
| 96 | /// | 94 | /// |
| 97 | /// @return Title string | 95 | /// @return Title string |
| 98 | /// | 96 | /// |
| @@ -111,14 +109,13 @@ public: | |||
| 111 | } | 109 | } |
| 112 | return text; | 110 | return text; |
| 113 | } | 111 | } |
| 114 | //-------------------------------------------------------------------------- | 112 | //---------------------------------------------------------------------------- |
| 115 | 113 | ||
| 116 | //========================================================================== | 114 | //============================================================================ |
| 117 | /// | 115 | /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 118 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 116 | /// @brief To set the title of dialog. |
| 119 | /// @brief To set the title of dialog | ||
| 120 | /// | 117 | /// |
| 121 | /// @param[in] title Title string | 118 | /// @param[in] title Title string |
| 122 | /// | 119 | /// |
| 123 | void SetTitle(const std::string& title) | 120 | void SetTitle(const std::string& title) |
| 124 | { | 121 | { |
| @@ -126,12 +123,11 @@ public: | |||
| 126 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title( | 123 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title( |
| 127 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str()); | 124 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str()); |
| 128 | } | 125 | } |
| 129 | //-------------------------------------------------------------------------- | 126 | //---------------------------------------------------------------------------- |
| 130 | 127 | ||
| 131 | //========================================================================== | 128 | //============================================================================ |
| 132 | /// | 129 | /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 133 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 130 | /// @brief Get the used text information string. |
| 134 | /// @brief Get the used text information string | ||
| 135 | /// | 131 | /// |
| 136 | /// @return Text string | 132 | /// @return Text string |
| 137 | /// | 133 | /// |
| @@ -150,14 +146,13 @@ public: | |||
| 150 | } | 146 | } |
| 151 | return text; | 147 | return text; |
| 152 | } | 148 | } |
| 153 | //-------------------------------------------------------------------------- | 149 | //---------------------------------------------------------------------------- |
| 154 | 150 | ||
| 155 | //========================================================================== | 151 | //============================================================================ |
| 152 | /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 153 | /// @brief To set the used text information string. | ||
| 156 | /// | 154 | /// |
| 157 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 155 | /// @param[in] text Information text to set |
| 158 | /// @brief To set the used text information string | ||
| 159 | /// | ||
| 160 | /// @param[in] text information text to set | ||
| 161 | /// | 156 | /// |
| 162 | void SetText(const std::string& text) | 157 | void SetText(const std::string& text) |
| 163 | { | 158 | { |
| @@ -165,12 +160,11 @@ public: | |||
| 165 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text( | 160 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text( |
| 166 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str()); | 161 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str()); |
| 167 | } | 162 | } |
| 168 | //-------------------------------------------------------------------------- | 163 | //---------------------------------------------------------------------------- |
| 169 | 164 | ||
| 170 | //========================================================================== | 165 | //============================================================================ |
| 171 | /// | 166 | /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 172 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 167 | /// @brief To ask dialog is finished. |
| 173 | /// @brief To ask dialog is finished | ||
| 174 | /// | 168 | /// |
| 175 | /// @return True if on end | 169 | /// @return True if on end |
| 176 | /// | 170 | /// |
| @@ -180,12 +174,11 @@ public: | |||
| 180 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished( | 174 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished( |
| 181 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | 175 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); |
| 182 | } | 176 | } |
| 183 | //-------------------------------------------------------------------------- | 177 | //---------------------------------------------------------------------------- |
| 184 | 178 | ||
| 185 | //========================================================================== | 179 | //============================================================================ |
| 186 | /// | 180 | /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 187 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 181 | /// @brief Mark progress finished. |
| 188 | /// @brief Mark progress finished | ||
| 189 | /// | 182 | /// |
| 190 | void MarkFinished() | 183 | void MarkFinished() |
| 191 | { | 184 | { |
| @@ -193,12 +186,11 @@ public: | |||
| 193 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished( | 186 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished( |
| 194 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | 187 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); |
| 195 | } | 188 | } |
| 196 | //-------------------------------------------------------------------------- | 189 | //---------------------------------------------------------------------------- |
| 197 | 190 | ||
| 198 | //========================================================================== | 191 | //============================================================================ |
| 199 | /// | 192 | /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 200 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 193 | /// @brief Get the current progress position as percent. |
| 201 | /// @brief Get the current progress position as percent | ||
| 202 | /// | 194 | /// |
| 203 | /// @return Position | 195 | /// @return Position |
| 204 | /// | 196 | /// |
| @@ -208,14 +200,13 @@ public: | |||
| 208 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage( | 200 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage( |
| 209 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | 201 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); |
| 210 | } | 202 | } |
| 211 | //-------------------------------------------------------------------------- | 203 | //---------------------------------------------------------------------------- |
| 212 | 204 | ||
| 213 | //========================================================================== | 205 | //============================================================================ |
| 206 | /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 207 | /// @brief To set the current progress position as percent. | ||
| 214 | /// | 208 | /// |
| 215 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 209 | /// @param[in] percentage Position to use from 0.0 to 100.0 |
| 216 | /// @brief To set the current progress position as percent | ||
| 217 | /// | ||
| 218 | /// @param[in] percentage Position to use from 0.0 to 100.0 | ||
| 219 | /// | 210 | /// |
| 220 | void SetPercentage(float percentage) | 211 | void SetPercentage(float percentage) |
| 221 | { | 212 | { |
| @@ -223,15 +214,14 @@ public: | |||
| 223 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage( | 214 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage( |
| 224 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | 215 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); |
| 225 | } | 216 | } |
| 226 | //-------------------------------------------------------------------------- | 217 | //---------------------------------------------------------------------------- |
| 227 | 218 | ||
| 228 | //========================================================================== | 219 | //============================================================================ |
| 229 | /// | 220 | /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 230 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 221 | /// @brief To set progress position with predefined places. |
| 231 | /// @brief To set progress position with predefined places | ||
| 232 | /// | 222 | /// |
| 233 | /// @param[in] currentItem Place position to use | 223 | /// @param[in] currentItem Place position to use |
| 234 | /// @param[in] itemCount Amount of used places | 224 | /// @param[in] itemCount Amount of used places |
| 235 | /// | 225 | /// |
| 236 | void SetProgress(int currentItem, int itemCount) | 226 | void SetProgress(int currentItem, int itemCount) |
| 237 | { | 227 | { |
| @@ -239,12 +229,14 @@ public: | |||
| 239 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress( | 229 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress( |
| 240 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount); | 230 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount); |
| 241 | } | 231 | } |
| 242 | //-------------------------------------------------------------------------- | 232 | //---------------------------------------------------------------------------- |
| 243 | 233 | ||
| 244 | private: | 234 | private: |
| 245 | void* m_DialogHandle; | 235 | KODI_GUI_HANDLE m_DialogHandle; |
| 246 | }; | 236 | }; |
| 247 | 237 | ||
| 248 | } /* namespace dialogs */ | 238 | } /* namespace dialogs */ |
| 249 | } /* namespace gui */ | 239 | } /* namespace gui */ |
| 250 | } /* namespace kodi */ | 240 | } /* namespace kodi */ |
| 241 | |||
| 242 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/FileBrowser.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/FileBrowser.h new file mode 100644 index 0000000..244c76c --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/FileBrowser.h | |||
| @@ -0,0 +1,302 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../AddonBase.h" | ||
| 12 | #include "../../c-api/gui/dialogs/filebrowser.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace dialogs | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_dialogs_FileBrowser Dialog File Browser | ||
| 25 | /// @ingroup cpp_kodi_gui_dialogs | ||
| 26 | /// @brief @cpp_namespace{ kodi::gui::dialogs::FileBrowser } | ||
| 27 | /// **File browser dialog**\n | ||
| 28 | /// The functions listed below of the class "FileBrowser" offer the possibility | ||
| 29 | /// to select to a file by the user of the add-on. | ||
| 30 | /// | ||
| 31 | /// It allows all the options that are possible in Kodi itself and offers all | ||
| 32 | /// support file types. | ||
| 33 | /// | ||
| 34 | /// It has the header @ref FileBrowser.h "#include <kodi/gui/dialogs/FileBrowser.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | namespace FileBrowser | ||
| 38 | { | ||
| 39 | //============================================================================== | ||
| 40 | /// @ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 41 | /// @brief Directory selection dialog. | ||
| 42 | /// | ||
| 43 | /// @param[in] shares With Shares becomes the available start folders be set | ||
| 44 | /// @param[in] heading Dialog header name | ||
| 45 | /// @param[in,out] path As in the path to start and return value about | ||
| 46 | /// selected directory | ||
| 47 | /// @param[in] writeOnly [opt] If set only writeable folders are shown | ||
| 48 | /// @return False if selection becomes canceled | ||
| 49 | /// | ||
| 50 | /// **Example:** | ||
| 51 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 52 | /// #include <kodi/gui/dialogs/FileBrowser.h> | ||
| 53 | /// | ||
| 54 | /// // Example show directory selection dialog with on 'share' (first value) | ||
| 55 | /// // defined directory types. | ||
| 56 | /// // | ||
| 57 | /// // If this becomes leaved empty and 'directory' is empty goes it to the | ||
| 58 | /// // base path of the hard disk. | ||
| 59 | /// // | ||
| 60 | /// // Also can be with path written to 'directory' before the dialog forced | ||
| 61 | /// // to a start place. | ||
| 62 | /// std::string directory; | ||
| 63 | /// bool ret = kodi::gui::dialogs::FileBrowser::ShowAndGetDirectory("local|network|removable", | ||
| 64 | /// "Test directory selection", | ||
| 65 | /// directory, | ||
| 66 | /// false); | ||
| 67 | /// fprintf(stderr, "Selected directory is : %s and was %s\n", directory.c_str(), ret ? "OK" : "Canceled"); | ||
| 68 | /// ~~~~~~~~~~~~~ | ||
| 69 | /// | ||
| 70 | inline bool ATTRIBUTE_HIDDEN ShowAndGetDirectory(const std::string& shares, | ||
| 71 | const std::string& heading, | ||
| 72 | std::string& path, | ||
| 73 | bool writeOnly = false) | ||
| 74 | { | ||
| 75 | using namespace ::kodi::addon; | ||
| 76 | char* retString = nullptr; | ||
| 77 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_directory( | ||
| 78 | CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), path.c_str(), | ||
| 79 | &retString, writeOnly); | ||
| 80 | if (retString != nullptr) | ||
| 81 | { | ||
| 82 | if (std::strlen(retString)) | ||
| 83 | path = retString; | ||
| 84 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 85 | retString); | ||
| 86 | } | ||
| 87 | return ret; | ||
| 88 | } | ||
| 89 | //------------------------------------------------------------------------------ | ||
| 90 | |||
| 91 | //============================================================================== | ||
| 92 | /// @ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 93 | /// @brief File selection dialog. | ||
| 94 | /// | ||
| 95 | /// @param[in] shares With Shares becomes the available start folders be set. | ||
| 96 | /// @param[in] mask The mask to filter visible files, e.g. ".m3u|.pls|.b4s|.wpl" | ||
| 97 | /// @param[in] heading Dialog header name | ||
| 98 | /// @param[in,out] path As in the path to start and Return value about selected | ||
| 99 | /// file | ||
| 100 | /// @param[in] useThumbs [opt] If set show thumbs if possible on dialog | ||
| 101 | /// @param[in] useFileDirectories [opt] If set also packages (e.g. *.zip) are | ||
| 102 | /// handled as directories. | ||
| 103 | /// @return False if selection becomes canceled | ||
| 104 | /// | ||
| 105 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFile(const std::string& shares, | ||
| 106 | const std::string& mask, | ||
| 107 | const std::string& heading, | ||
| 108 | std::string& path, | ||
| 109 | bool useThumbs = false, | ||
| 110 | bool useFileDirectories = false) | ||
| 111 | { | ||
| 112 | using namespace ::kodi::addon; | ||
| 113 | char* retString = nullptr; | ||
| 114 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file( | ||
| 115 | CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), mask.c_str(), heading.c_str(), | ||
| 116 | path.c_str(), &retString, useThumbs, useFileDirectories); | ||
| 117 | if (retString != nullptr) | ||
| 118 | { | ||
| 119 | if (std::strlen(retString)) | ||
| 120 | path = retString; | ||
| 121 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 122 | retString); | ||
| 123 | } | ||
| 124 | return ret; | ||
| 125 | } | ||
| 126 | //------------------------------------------------------------------------------ | ||
| 127 | |||
| 128 | //============================================================================== | ||
| 129 | /// @ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 130 | /// @brief File selection from a directory. | ||
| 131 | /// | ||
| 132 | /// @param[in] directory The directory name where the dialog start, possible are | ||
| 133 | /// normal names and kodi's special names | ||
| 134 | /// @param[in] mask The mask to filter visible files, e.g. ".m3u|.pls|.b4s|.wpl" | ||
| 135 | /// @param[in] heading Dialog header name | ||
| 136 | /// @param[in,out] path As in the path to start and Return value about selected | ||
| 137 | /// file | ||
| 138 | /// @param[in] useThumbs [opt] If set show thumbs if possible on dialog | ||
| 139 | /// @param[in] useFileDirectories [opt] If set also packages (e.g. *.zip) are | ||
| 140 | /// handled as directories | ||
| 141 | /// @param[in] singleList [opt] | ||
| 142 | /// @return False if selection becomes canceled | ||
| 143 | /// | ||
| 144 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFileFromDir(const std::string& directory, | ||
| 145 | const std::string& mask, | ||
| 146 | const std::string& heading, | ||
| 147 | std::string& path, | ||
| 148 | bool useThumbs = false, | ||
| 149 | bool useFileDirectories = false, | ||
| 150 | bool singleList = false) | ||
| 151 | { | ||
| 152 | using namespace ::kodi::addon; | ||
| 153 | char* retString = nullptr; | ||
| 154 | bool ret = | ||
| 155 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_from_dir( | ||
| 156 | CAddonBase::m_interface->toKodi->kodiBase, directory.c_str(), mask.c_str(), | ||
| 157 | heading.c_str(), path.c_str(), &retString, useThumbs, useFileDirectories, singleList); | ||
| 158 | if (retString != nullptr) | ||
| 159 | { | ||
| 160 | if (std::strlen(retString)) | ||
| 161 | path = retString; | ||
| 162 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 163 | retString); | ||
| 164 | } | ||
| 165 | return ret; | ||
| 166 | } | ||
| 167 | //------------------------------------------------------------------------------ | ||
| 168 | |||
| 169 | //============================================================================== | ||
| 170 | /// @ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 171 | /// @brief File selection dialog to get several in to a list. | ||
| 172 | /// | ||
| 173 | /// @param[in] shares With Shares becomes the available start folders be set. | ||
| 174 | /// @param[in] mask The mask to filter visible files, e.g. ".m3u|.pls|.b4s|.wpl" | ||
| 175 | /// @param[in] heading Dialog header name | ||
| 176 | /// @param[out] fileList Return value about selected files | ||
| 177 | /// @param[in] useThumbs [opt] If set show thumbs if possible on dialog. | ||
| 178 | /// @param[in] useFileDirectories [opt] If set also packages (e.g. *.zip) are | ||
| 179 | /// handled as directories. | ||
| 180 | /// @return False if selection becomes canceled. | ||
| 181 | /// | ||
| 182 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFileList(const std::string& shares, | ||
| 183 | const std::string& mask, | ||
| 184 | const std::string& heading, | ||
| 185 | std::vector<std::string>& fileList, | ||
| 186 | bool useThumbs = false, | ||
| 187 | bool useFileDirectories = false) | ||
| 188 | { | ||
| 189 | using namespace ::kodi::addon; | ||
| 190 | char** list = nullptr; | ||
| 191 | unsigned int listSize = 0; | ||
| 192 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_list( | ||
| 193 | CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), mask.c_str(), heading.c_str(), | ||
| 194 | &list, &listSize, useThumbs, useFileDirectories); | ||
| 195 | if (ret) | ||
| 196 | { | ||
| 197 | for (unsigned int i = 0; i < listSize; ++i) | ||
| 198 | fileList.emplace_back(list[i]); | ||
| 199 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list( | ||
| 200 | CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); | ||
| 201 | } | ||
| 202 | return ret; | ||
| 203 | } | ||
| 204 | //------------------------------------------------------------------------------ | ||
| 205 | |||
| 206 | //============================================================================== | ||
| 207 | /// @ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 208 | /// @brief Source selection dialog. | ||
| 209 | /// | ||
| 210 | /// @param[in,out] path As in the path to start and Return value about selected | ||
| 211 | /// source | ||
| 212 | /// @param[in] allowNetworkShares Allow also access to network | ||
| 213 | /// @param[in] additionalShare [opt] With additionalShare becomes the available | ||
| 214 | /// start folders be set. | ||
| 215 | /// @param[in] type [opt] | ||
| 216 | /// @return False if selection becomes canceled | ||
| 217 | /// | ||
| 218 | inline bool ATTRIBUTE_HIDDEN ShowAndGetSource(std::string& path, | ||
| 219 | bool allowNetworkShares, | ||
| 220 | const std::string& additionalShare = "", | ||
| 221 | const std::string& type = "") | ||
| 222 | { | ||
| 223 | using namespace ::kodi::addon; | ||
| 224 | char* retString = nullptr; | ||
| 225 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_source( | ||
| 226 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), &retString, allowNetworkShares, | ||
| 227 | additionalShare.c_str(), type.c_str()); | ||
| 228 | if (retString != nullptr) | ||
| 229 | { | ||
| 230 | if (std::strlen(retString)) | ||
| 231 | path = retString; | ||
| 232 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 233 | retString); | ||
| 234 | } | ||
| 235 | return ret; | ||
| 236 | } | ||
| 237 | //------------------------------------------------------------------------------ | ||
| 238 | |||
| 239 | //============================================================================== | ||
| 240 | /// @ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 241 | /// @brief Image selection dialog. | ||
| 242 | /// | ||
| 243 | /// @param[in] shares With Shares becomes the available start folders be set | ||
| 244 | /// @param[in] heading Dialog header name | ||
| 245 | /// @param[out] path Return value about selected image | ||
| 246 | /// @return False if selection becomes canceled | ||
| 247 | /// | ||
| 248 | inline bool ATTRIBUTE_HIDDEN ShowAndGetImage(const std::string& shares, | ||
| 249 | const std::string& heading, | ||
| 250 | std::string& path) | ||
| 251 | { | ||
| 252 | using namespace ::kodi::addon; | ||
| 253 | char* retString = nullptr; | ||
| 254 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image( | ||
| 255 | CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), path.c_str(), | ||
| 256 | &retString); | ||
| 257 | if (retString != nullptr) | ||
| 258 | { | ||
| 259 | if (std::strlen(retString)) | ||
| 260 | path = retString; | ||
| 261 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 262 | retString); | ||
| 263 | } | ||
| 264 | return ret; | ||
| 265 | } | ||
| 266 | //------------------------------------------------------------------------------ | ||
| 267 | |||
| 268 | //============================================================================== | ||
| 269 | /// @ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 270 | /// @brief Image selection dialog to get several in to a list. | ||
| 271 | /// | ||
| 272 | /// @param[in] shares With Shares becomes the available start folders be set | ||
| 273 | /// @param[in] heading Dialog header name | ||
| 274 | /// @param[out] file_list Return value about selected images | ||
| 275 | /// @return False if selection becomes canceled | ||
| 276 | /// | ||
| 277 | inline bool ATTRIBUTE_HIDDEN ShowAndGetImageList(const std::string& shares, | ||
| 278 | const std::string& heading, | ||
| 279 | std::vector<std::string>& file_list) | ||
| 280 | { | ||
| 281 | using namespace ::kodi::addon; | ||
| 282 | char** list = nullptr; | ||
| 283 | unsigned int listSize = 0; | ||
| 284 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image_list( | ||
| 285 | CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), &list, &listSize); | ||
| 286 | if (ret) | ||
| 287 | { | ||
| 288 | for (unsigned int i = 0; i < listSize; ++i) | ||
| 289 | file_list.emplace_back(list[i]); | ||
| 290 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list( | ||
| 291 | CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); | ||
| 292 | } | ||
| 293 | return ret; | ||
| 294 | } | ||
| 295 | //------------------------------------------------------------------------------ | ||
| 296 | }; // namespace FileBrowser | ||
| 297 | |||
| 298 | } /* namespace dialogs */ | ||
| 299 | } /* namespace gui */ | ||
| 300 | } /* namespace kodi */ | ||
| 301 | |||
| 302 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Keyboard.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Keyboard.h new file mode 100644 index 0000000..710b7dd --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Keyboard.h | |||
| @@ -0,0 +1,404 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../AddonBase.h" | ||
| 12 | #include "../../c-api/gui/dialogs/keyboard.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace dialogs | ||
| 21 | { | ||
| 22 | |||
| 23 | //================================================================================ | ||
| 24 | /// @defgroup cpp_kodi_gui_dialogs_Keyboard Dialog Keyboard | ||
| 25 | /// @ingroup cpp_kodi_gui_dialogs | ||
| 26 | /// @brief @cpp_namespace{ kodi::gui::dialogs::Keyboard } | ||
| 27 | /// **Keyboard dialogs**\n | ||
| 28 | /// The functions listed below have to be permitted by the user for the | ||
| 29 | /// representation of a keyboard around an input. | ||
| 30 | /// | ||
| 31 | /// The class supports several kinds, from an easy text choice up to the | ||
| 32 | /// passport Word production and their confirmation for add-on. | ||
| 33 | /// | ||
| 34 | /// It has the header @ref Keyboard.h "#include <kodi/gui/dialogs/Keyboard.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | namespace Keyboard | ||
| 38 | { | ||
| 39 | //============================================================================== | ||
| 40 | /// @ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 41 | /// @brief Show keyboard with initial value `text` and replace with result | ||
| 42 | /// string. | ||
| 43 | /// | ||
| 44 | /// @param[in,out] text Overwritten with user input if return=true. | ||
| 45 | /// @param[in] heading String shown on dialog title. | ||
| 46 | /// @param[in] allowEmptyResult Whether a blank password is valid or not. | ||
| 47 | /// @param[in] hiddenInput [opt] The inserted input is not shown as text. | ||
| 48 | /// @param[in] autoCloseMs [opt] To close the dialog after a specified time, in | ||
| 49 | /// milliseconds, default is 0 which keeps the dialog | ||
| 50 | /// open indefinitely. | ||
| 51 | /// @return true if successful display and user input. false if unsuccessful | ||
| 52 | /// display, no user input, or canceled editing. | ||
| 53 | /// | ||
| 54 | /// | ||
| 55 | ///------------------------------------------------------------------------- | ||
| 56 | /// | ||
| 57 | /// **Example:** | ||
| 58 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 59 | /// #include <kodi/gui/dialogs/Keyboard.h> | ||
| 60 | /// | ||
| 61 | /// // The example shows the display of keyboard call dialog at Kodi from the add-on. | ||
| 62 | /// // Below all values are set, however, can last two (hidden input = false and autoCloseMs = 0) | ||
| 63 | /// // to be released if not needed. | ||
| 64 | /// std::string text = "Please change me to them want you want"; // It can be leaved empty or a entry text added | ||
| 65 | /// bool bRet = ::kodi::gui::dialogs::Keyboard::ShowAndGetInput(text, | ||
| 66 | /// "Demonstration text entry", | ||
| 67 | /// true, | ||
| 68 | /// false, | ||
| 69 | /// 0); | ||
| 70 | /// fprintf(stderr, "Written keyboard input is : '%s' and was %s\n", | ||
| 71 | /// text.c_str(), bRet ? "OK" : "Canceled"); | ||
| 72 | /// ~~~~~~~~~~~~~ | ||
| 73 | /// | ||
| 74 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(std::string& text, | ||
| 75 | const std::string& heading, | ||
| 76 | bool allowEmptyResult, | ||
| 77 | bool hiddenInput = false, | ||
| 78 | unsigned int autoCloseMs = 0) | ||
| 79 | { | ||
| 80 | using namespace ::kodi::addon; | ||
| 81 | char* retString = nullptr; | ||
| 82 | bool ret = | ||
| 83 | CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input_with_head( | ||
| 84 | CAddonBase::m_interface->toKodi->kodiBase, text.c_str(), &retString, heading.c_str(), | ||
| 85 | allowEmptyResult, hiddenInput, autoCloseMs); | ||
| 86 | if (retString != nullptr) | ||
| 87 | { | ||
| 88 | text = retString; | ||
| 89 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 90 | retString); | ||
| 91 | } | ||
| 92 | return ret; | ||
| 93 | } | ||
| 94 | //------------------------------------------------------------------------------ | ||
| 95 | |||
| 96 | //============================================================================== | ||
| 97 | /// @ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 98 | /// @brief The example shows the display of keyboard call dialog at Kodi | ||
| 99 | /// from the add-on. | ||
| 100 | /// | ||
| 101 | /// @param[out] text Overwritten with user input if return=true. | ||
| 102 | /// @param[in] allowEmptyResult If set to true keyboard can also exited without | ||
| 103 | /// entered text. | ||
| 104 | /// @param[in] autoCloseMs [opt] To close the dialog after a specified time, in | ||
| 105 | /// milliseconds, default is 0 which keeps the dialog | ||
| 106 | /// open indefinitely. | ||
| 107 | /// @return true if successful display and user input. false if unsuccessful | ||
| 108 | /// display, no user input, or canceled editing. | ||
| 109 | /// | ||
| 110 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(std::string& text, | ||
| 111 | bool allowEmptyResult, | ||
| 112 | unsigned int autoCloseMs = 0) | ||
| 113 | { | ||
| 114 | using namespace ::kodi::addon; | ||
| 115 | char* retString = nullptr; | ||
| 116 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input( | ||
| 117 | CAddonBase::m_interface->toKodi->kodiBase, text.c_str(), &retString, allowEmptyResult, | ||
| 118 | autoCloseMs); | ||
| 119 | if (retString != nullptr) | ||
| 120 | { | ||
| 121 | text = retString; | ||
| 122 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 123 | retString); | ||
| 124 | } | ||
| 125 | return ret; | ||
| 126 | } | ||
| 127 | //------------------------------------------------------------------------------ | ||
| 128 | |||
| 129 | //============================================================================== | ||
| 130 | /// @ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 131 | /// @brief Shows keyboard and prompts for a password. Differs from | ||
| 132 | /// `ShowAndVerifyNewPassword()` in that no second verification. | ||
| 133 | /// | ||
| 134 | /// @param[in,out] newPassword Overwritten with user input if return=true. | ||
| 135 | /// @param[in] heading String shown on dialog title. | ||
| 136 | /// @param[in] allowEmptyResult Whether a blank password is valid or not. | ||
| 137 | /// @param[in] autoCloseMs [opt] To close the dialog after a specified time, in | ||
| 138 | /// milliseconds, default is 0 which keeps the dialog | ||
| 139 | /// open indefinitely. | ||
| 140 | /// @return true if successful display and user input. false if unsuccessful | ||
| 141 | /// display, no user input, or canceled editing. | ||
| 142 | /// | ||
| 143 | inline bool ATTRIBUTE_HIDDEN ShowAndGetNewPassword(std::string& newPassword, | ||
| 144 | const std::string& heading, | ||
| 145 | bool allowEmptyResult, | ||
| 146 | unsigned int autoCloseMs = 0) | ||
| 147 | { | ||
| 148 | using namespace ::kodi::addon; | ||
| 149 | char* retString = nullptr; | ||
| 150 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard | ||
| 151 | ->show_and_get_new_password_with_head( | ||
| 152 | CAddonBase::m_interface->toKodi->kodiBase, newPassword.c_str(), &retString, | ||
| 153 | heading.c_str(), allowEmptyResult, autoCloseMs); | ||
| 154 | if (retString != nullptr) | ||
| 155 | { | ||
| 156 | newPassword = retString; | ||
| 157 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 158 | retString); | ||
| 159 | } | ||
| 160 | return ret; | ||
| 161 | } | ||
| 162 | //------------------------------------------------------------------------------ | ||
| 163 | |||
| 164 | //============================================================================== | ||
| 165 | /// @ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 166 | /// @brief Shows keyboard and prompts for a password. Differs from | ||
| 167 | /// `ShowAndVerifyNewPassword()` in that no second verification. | ||
| 168 | /// | ||
| 169 | /// @param[in,out] newPassword Overwritten with user input if return=true. | ||
| 170 | /// @param[in] autoCloseMs [opt] To close the dialog after a specified time, in | ||
| 171 | /// milliseconds, default is 0 which keeps the dialog | ||
| 172 | /// open indefinitely. | ||
| 173 | /// @return true if successful display and user input. false if unsuccessful | ||
| 174 | /// display, no user input, or canceled editing. | ||
| 175 | /// | ||
| 176 | inline bool ATTRIBUTE_HIDDEN ShowAndGetNewPassword(std::string& newPassword, | ||
| 177 | unsigned int autoCloseMs = 0) | ||
| 178 | { | ||
| 179 | using namespace ::kodi::addon; | ||
| 180 | char* retString = nullptr; | ||
| 181 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password( | ||
| 182 | CAddonBase::m_interface->toKodi->kodiBase, newPassword.c_str(), &retString, autoCloseMs); | ||
| 183 | if (retString != nullptr) | ||
| 184 | { | ||
| 185 | newPassword = retString; | ||
| 186 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 187 | retString); | ||
| 188 | } | ||
| 189 | return ret; | ||
| 190 | } | ||
| 191 | //------------------------------------------------------------------------------ | ||
| 192 | |||
| 193 | //============================================================================== | ||
| 194 | /// @ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 195 | /// @brief Show keyboard twice to get and confirm a user-entered password | ||
| 196 | /// string. | ||
| 197 | /// | ||
| 198 | /// @param[out] newPassword Overwritten with user input if return=true. | ||
| 199 | /// @param[in] heading String shown on dialog title. | ||
| 200 | /// @param[in] allowEmptyResult | ||
| 201 | /// @param[in] autoCloseMs [opt] To close the dialog after a specified time, in | ||
| 202 | /// milliseconds, default is 0 which keeps the dialog | ||
| 203 | /// open indefinitely. | ||
| 204 | /// @return true if successful display and user input. false if unsuccessful | ||
| 205 | /// display, no user input, or canceled editing. | ||
| 206 | /// | ||
| 207 | /// | ||
| 208 | ///------------------------------------------------------------------------- | ||
| 209 | /// | ||
| 210 | /// **Example:** | ||
| 211 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 212 | /// #include <kodi/General.h> | ||
| 213 | /// #include <kodi/gui/dialogs/Keyboard.h> | ||
| 214 | /// | ||
| 215 | /// // The example below shows the complete use of keyboard dialog for password | ||
| 216 | /// // check. If only one check from add-on needed can be function with retries | ||
| 217 | /// // set to '0' called alone. | ||
| 218 | /// // | ||
| 219 | /// // The use of MD5 translated password is always required for the check on Kodi! | ||
| 220 | /// | ||
| 221 | /// int maxretries = 3; | ||
| 222 | /// // Password names need to be send as md5 sum to kodi. | ||
| 223 | /// std::string password; | ||
| 224 | /// kodi::GetMD5("kodi", password); | ||
| 225 | /// | ||
| 226 | /// // To the loop about password checks. | ||
| 227 | /// int ret; | ||
| 228 | /// for (unsigned int i = 0; i < maxretries; i++) | ||
| 229 | /// { | ||
| 230 | /// // Ask the user about the password. | ||
| 231 | /// ret = ::kodi::gui::dialogs::Keyboard::ShowAndVerifyPassword(password, "Demo password call for PW 'kodi'", i, 0); | ||
| 232 | /// if (ret == 0) | ||
| 233 | /// { | ||
| 234 | /// fprintf(stderr, "Password successfull confirmed after '%i' tries\n", i+1); | ||
| 235 | /// break; | ||
| 236 | /// } | ||
| 237 | /// else if (ret < 0) | ||
| 238 | /// { | ||
| 239 | /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); | ||
| 240 | /// break; | ||
| 241 | /// } | ||
| 242 | /// else // if (ret > 0) | ||
| 243 | /// { | ||
| 244 | /// fprintf(stderr, "Wrong password entered on try '%i'\n", i+1); | ||
| 245 | /// } | ||
| 246 | /// } | ||
| 247 | /// ~~~~~~~~~~~~~ | ||
| 248 | /// | ||
| 249 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword, | ||
| 250 | const std::string& heading, | ||
| 251 | bool allowEmptyResult, | ||
| 252 | unsigned int autoCloseMs = 0) | ||
| 253 | { | ||
| 254 | using namespace ::kodi::addon; | ||
| 255 | char* retString = nullptr; | ||
| 256 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard | ||
| 257 | ->show_and_verify_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 258 | &retString, heading.c_str(), | ||
| 259 | allowEmptyResult, autoCloseMs); | ||
| 260 | if (retString != nullptr) | ||
| 261 | { | ||
| 262 | newPassword = retString; | ||
| 263 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 264 | retString); | ||
| 265 | } | ||
| 266 | return ret; | ||
| 267 | } | ||
| 268 | //------------------------------------------------------------------------------ | ||
| 269 | |||
| 270 | //============================================================================== | ||
| 271 | /// @ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 272 | /// @brief Show keyboard twice to get and confirm a user-entered password | ||
| 273 | /// string. | ||
| 274 | /// | ||
| 275 | /// @param[out] newPassword Overwritten with user input if return=true. | ||
| 276 | /// @param[in] autoCloseMs [opt] To close the dialog after a specified time, in | ||
| 277 | /// milliseconds, default is 0 which keeps the dialog | ||
| 278 | /// open indefinitely. | ||
| 279 | /// @return true if successful display and user input. false if unsuccessful | ||
| 280 | /// display, no user input, or canceled editing. | ||
| 281 | /// | ||
| 282 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword, | ||
| 283 | unsigned int autoCloseMs = 0) | ||
| 284 | { | ||
| 285 | using namespace ::kodi::addon; | ||
| 286 | char* retString = nullptr; | ||
| 287 | bool ret = | ||
| 288 | CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password( | ||
| 289 | CAddonBase::m_interface->toKodi->kodiBase, &retString, autoCloseMs); | ||
| 290 | if (retString != nullptr) | ||
| 291 | { | ||
| 292 | newPassword = retString; | ||
| 293 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 294 | retString); | ||
| 295 | } | ||
| 296 | return ret; | ||
| 297 | } | ||
| 298 | //------------------------------------------------------------------------------ | ||
| 299 | |||
| 300 | //============================================================================== | ||
| 301 | /// @ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 302 | /// @brief Show keyboard and verify user input against `password`. | ||
| 303 | /// | ||
| 304 | /// @param[in,out] password Value to compare against user input. | ||
| 305 | /// @param[in] heading String shown on dialog title. | ||
| 306 | /// @param[in] retries If greater than 0, shows "Incorrect password, %d retries | ||
| 307 | /// left" on dialog line 2, else line 2 is blank. | ||
| 308 | /// @param[in] autoCloseMs [opt] To close the dialog after a specified time, in | ||
| 309 | /// milliseconds, default is 0 which keeps the dialog | ||
| 310 | /// open indefinitely. | ||
| 311 | /// @return 0 if successful display and user input. 1 if unsuccessful input. | ||
| 312 | /// -1 if no user input or canceled editing. | ||
| 313 | /// | ||
| 314 | inline int ATTRIBUTE_HIDDEN ShowAndVerifyPassword(std::string& password, | ||
| 315 | const std::string& heading, | ||
| 316 | int retries, | ||
| 317 | unsigned int autoCloseMs = 0) | ||
| 318 | { | ||
| 319 | using namespace ::kodi::addon; | ||
| 320 | char* retString = nullptr; | ||
| 321 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_password( | ||
| 322 | CAddonBase::m_interface->toKodi->kodiBase, password.c_str(), &retString, heading.c_str(), | ||
| 323 | retries, autoCloseMs); | ||
| 324 | if (retString != nullptr) | ||
| 325 | { | ||
| 326 | password = retString; | ||
| 327 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 328 | retString); | ||
| 329 | } | ||
| 330 | return ret; | ||
| 331 | } | ||
| 332 | //------------------------------------------------------------------------------ | ||
| 333 | |||
| 334 | //============================================================================== | ||
| 335 | /// @ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 336 | /// @brief Shows a filter related keyboard. | ||
| 337 | /// | ||
| 338 | /// @param[in,out] text Overwritten with user input if return=true. | ||
| 339 | /// @param[in] searching Use dialog for search and send our search message in | ||
| 340 | /// safe way (only the active window needs it) | ||
| 341 | /// - header name if true is "Enter search string" | ||
| 342 | /// - header name if false is "Enter value" | ||
| 343 | /// @param autoCloseMs [opt] To close the dialog after a specified time, in | ||
| 344 | /// milliseconds, default is 0 which keeps the dialog open | ||
| 345 | /// indefinitely. | ||
| 346 | /// @return true if successful display and user input. false if unsuccessful | ||
| 347 | /// display, no user input, or canceled editing. | ||
| 348 | /// | ||
| 349 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFilter(std::string& text, | ||
| 350 | bool searching, | ||
| 351 | unsigned int autoCloseMs = 0) | ||
| 352 | { | ||
| 353 | using namespace ::kodi::addon; | ||
| 354 | char* retString = nullptr; | ||
| 355 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_filter( | ||
| 356 | CAddonBase::m_interface->toKodi->kodiBase, text.c_str(), &retString, searching, autoCloseMs); | ||
| 357 | if (retString != nullptr) | ||
| 358 | { | ||
| 359 | text = retString; | ||
| 360 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 361 | retString); | ||
| 362 | } | ||
| 363 | return ret; | ||
| 364 | } | ||
| 365 | //------------------------------------------------------------------------------ | ||
| 366 | |||
| 367 | //============================================================================== | ||
| 368 | /// @ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 369 | /// @brief Send a text to a visible keyboard. | ||
| 370 | /// | ||
| 371 | /// @param[in] text Overwritten with user input if return=true. | ||
| 372 | /// @param[in] closeKeyboard [opt] The open dialog is if also closed on 'true'. | ||
| 373 | /// @return true if successful done, false if unsuccessful or keyboard not | ||
| 374 | /// present. | ||
| 375 | /// | ||
| 376 | inline bool ATTRIBUTE_HIDDEN SendTextToActiveKeyboard(const std::string& text, | ||
| 377 | bool closeKeyboard = false) | ||
| 378 | { | ||
| 379 | using namespace ::kodi::addon; | ||
| 380 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->send_text_to_active_keyboard( | ||
| 381 | CAddonBase::m_interface->toKodi->kodiBase, text.c_str(), closeKeyboard); | ||
| 382 | } | ||
| 383 | //------------------------------------------------------------------------------ | ||
| 384 | |||
| 385 | //============================================================================== | ||
| 386 | /// @ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 387 | /// @brief Check for visible keyboard on GUI. | ||
| 388 | /// | ||
| 389 | /// @return true if keyboard present, false if not present | ||
| 390 | /// | ||
| 391 | inline bool ATTRIBUTE_HIDDEN IsKeyboardActivated() | ||
| 392 | { | ||
| 393 | using namespace ::kodi::addon; | ||
| 394 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->is_keyboard_activated( | ||
| 395 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 396 | } | ||
| 397 | //------------------------------------------------------------------------------ | ||
| 398 | }; // namespace Keyboard | ||
| 399 | |||
| 400 | } /* namespace dialogs */ | ||
| 401 | } /* namespace gui */ | ||
| 402 | } /* namespace kodi */ | ||
| 403 | |||
| 404 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Numeric.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Numeric.h new file mode 100644 index 0000000..835a8d4 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Numeric.h | |||
| @@ -0,0 +1,346 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../AddonBase.h" | ||
| 12 | #include "../../c-api/gui/dialogs/numeric.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace dialogs | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_dialogs_Numeric Dialog Numeric | ||
| 25 | /// @ingroup cpp_kodi_gui_dialogs | ||
| 26 | /// @{ | ||
| 27 | /// @brief @cpp_namespace{ kodi::gui::dialogs::Numeric } | ||
| 28 | /// **Numeric dialogs**\n | ||
| 29 | /// The functions listed below have to be permitted by the user for the | ||
| 30 | /// representation of a numeric keyboard around an input. | ||
| 31 | /// | ||
| 32 | /// The class supports several kinds, from an easy number choice up to the | ||
| 33 | /// passport Word production and their confirmation for add-on. | ||
| 34 | /// | ||
| 35 | /// It has the header @ref Numeric.h "#include <kodi/gui/dialogs/Numeric.h>" | ||
| 36 | /// be included to enjoy it. | ||
| 37 | /// | ||
| 38 | namespace Numeric | ||
| 39 | { | ||
| 40 | //============================================================================== | ||
| 41 | /// @ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 42 | /// @brief Use dialog to get numeric new password | ||
| 43 | /// | ||
| 44 | /// @param[out] newPassword String to preload into the keyboard accumulator. | ||
| 45 | /// Overwritten with user input if return=true. | ||
| 46 | /// Returned in MD5 format. | ||
| 47 | /// @return true if successful display and user input entry/re-entry. false if | ||
| 48 | /// unsuccessful display, no user input, or canceled editing. | ||
| 49 | /// | ||
| 50 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword) | ||
| 51 | { | ||
| 52 | using namespace ::kodi::addon; | ||
| 53 | char* pw = nullptr; | ||
| 54 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_new_password( | ||
| 55 | CAddonBase::m_interface->toKodi->kodiBase, &pw); | ||
| 56 | if (pw != nullptr) | ||
| 57 | { | ||
| 58 | newPassword = pw; | ||
| 59 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, pw); | ||
| 60 | } | ||
| 61 | return ret; | ||
| 62 | } | ||
| 63 | //------------------------------------------------------------------------------ | ||
| 64 | |||
| 65 | //============================================================================== | ||
| 66 | /// | ||
| 67 | /// @ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 68 | /// @brief Use dialog to verify numeric password. | ||
| 69 | /// | ||
| 70 | /// @param[in] password Password to compare with user input, need | ||
| 71 | /// in MD5 format. | ||
| 72 | /// @param[in] heading Heading to display | ||
| 73 | /// @param[in] retries If greater than 0, shows "Incorrect | ||
| 74 | /// password, %d retries left" on dialog | ||
| 75 | /// line 2, else line 2 is blank. | ||
| 76 | /// @return Possible values: | ||
| 77 | /// - 0 if successful display and user input. | ||
| 78 | /// - 1 if unsuccessful input. | ||
| 79 | /// - -1 if no user input or canceled editing. | ||
| 80 | /// | ||
| 81 | /// | ||
| 82 | ///------------------------------------------------------------------------- | ||
| 83 | /// | ||
| 84 | /// **Example:** | ||
| 85 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 86 | /// #include <stdio.h> // fprintf | ||
| 87 | /// #include <kodi/General.h> | ||
| 88 | /// #include <kodi/gui/dialogs/Numeric.h> | ||
| 89 | /// | ||
| 90 | /// // The example below shows the complete use of keyboard dialog for password | ||
| 91 | /// // check. If only one check from add-on needed can be function with retries | ||
| 92 | /// // set to '0' called alone. | ||
| 93 | /// // | ||
| 94 | /// // The use of MD5 translated password is always required for the check on Kodi! | ||
| 95 | /// | ||
| 96 | /// int maxretries = 3; | ||
| 97 | /// | ||
| 98 | /// // Password names need to be send as md5 sum to kodi. | ||
| 99 | /// std::string password = kodi::GetMD5("1234"); | ||
| 100 | /// | ||
| 101 | /// // To the loop about password checks. | ||
| 102 | /// int ret; | ||
| 103 | /// for (unsigned int i = 0; i < maxretries; i++) | ||
| 104 | /// { | ||
| 105 | /// // Ask the user about the password. | ||
| 106 | /// ret = kodi::gui::dialogs::Numeric::ShowAndVerifyPassword(password, "Demo numeric password call for PW '1234'", i); | ||
| 107 | /// if (ret == 0) | ||
| 108 | /// { | ||
| 109 | /// fprintf(stderr, "Numeric password successfull confirmed after '%i' tries\n", i+1); | ||
| 110 | /// break; | ||
| 111 | /// } | ||
| 112 | /// else if (ret < 0) | ||
| 113 | /// { | ||
| 114 | /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); | ||
| 115 | /// break; | ||
| 116 | /// } | ||
| 117 | /// else // if (ret > 0) | ||
| 118 | /// { | ||
| 119 | /// fprintf(stderr, "Wrong numeric password entered on try '%i'\n", i+1); | ||
| 120 | /// } | ||
| 121 | /// } | ||
| 122 | /// ~~~~~~~~~~~~~ | ||
| 123 | /// | ||
| 124 | inline int ATTRIBUTE_HIDDEN ShowAndVerifyPassword(const std::string& password, | ||
| 125 | const std::string& heading, | ||
| 126 | int retries) | ||
| 127 | { | ||
| 128 | using namespace ::kodi::addon; | ||
| 129 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_password( | ||
| 130 | CAddonBase::m_interface->toKodi->kodiBase, password.c_str(), heading.c_str(), retries); | ||
| 131 | } | ||
| 132 | //------------------------------------------------------------------------------ | ||
| 133 | |||
| 134 | //============================================================================== | ||
| 135 | /// @ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 136 | /// @brief Use dialog to verify numeric password | ||
| 137 | /// | ||
| 138 | /// @param[in,out] toVerify Value to compare against user input. | ||
| 139 | /// @param[in] heading Heading to display | ||
| 140 | /// @param[in] verifyInput If set as true we verify the users input versus | ||
| 141 | /// toVerify. | ||
| 142 | /// @return true if successful display and user input. false if unsuccessful | ||
| 143 | /// display, no user input, or canceled editing. | ||
| 144 | /// | ||
| 145 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyInput(std::string& toVerify, | ||
| 146 | const std::string& heading, | ||
| 147 | bool verifyInput) | ||
| 148 | { | ||
| 149 | using namespace ::kodi::addon; | ||
| 150 | char* retString = nullptr; | ||
| 151 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_input( | ||
| 152 | CAddonBase::m_interface->toKodi->kodiBase, toVerify.c_str(), &retString, heading.c_str(), | ||
| 153 | verifyInput); | ||
| 154 | if (retString != nullptr) | ||
| 155 | { | ||
| 156 | toVerify = retString; | ||
| 157 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 158 | retString); | ||
| 159 | } | ||
| 160 | return ret; | ||
| 161 | } | ||
| 162 | //------------------------------------------------------------------------------ | ||
| 163 | |||
| 164 | //============================================================================== | ||
| 165 | /// @ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 166 | /// @brief Use dialog to get time value. | ||
| 167 | /// | ||
| 168 | /// @param[out] time Overwritten with user input if return=true and time | ||
| 169 | /// inserted. | ||
| 170 | /// @param[in] heading Heading to display. | ||
| 171 | /// @return true if successful display and user input. false if unsuccessful | ||
| 172 | /// display, no user input, or canceled editing. | ||
| 173 | /// | ||
| 174 | /// | ||
| 175 | ///------------------------------------------------------------------------- | ||
| 176 | /// | ||
| 177 | /// **Example:** | ||
| 178 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 179 | /// #include <stdio.h> // printf | ||
| 180 | /// #include <time.h> // time_t, struct tm, time, localtime, strftime | ||
| 181 | /// #include <kodi/gui/dialogs/Numeric.h> | ||
| 182 | /// | ||
| 183 | /// time_t rawtime; | ||
| 184 | /// struct tm * timeinfo; | ||
| 185 | /// char buffer [10]; | ||
| 186 | /// | ||
| 187 | /// time (&rawtime); | ||
| 188 | /// timeinfo = localtime(&rawtime); | ||
| 189 | /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetTime(*timeinfo, "Selected time test call"); | ||
| 190 | /// strftime(buffer, sizeof(buffer), "%H:%M.", timeinfo); | ||
| 191 | /// printf("Selected time it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); | ||
| 192 | /// ~~~~~~~~~~~~~ | ||
| 193 | /// | ||
| 194 | inline bool ATTRIBUTE_HIDDEN ShowAndGetTime(tm& time, const std::string& heading) | ||
| 195 | { | ||
| 196 | using namespace ::kodi::addon; | ||
| 197 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_time( | ||
| 198 | CAddonBase::m_interface->toKodi->kodiBase, &time, heading.c_str()); | ||
| 199 | } | ||
| 200 | //------------------------------------------------------------------------------ | ||
| 201 | |||
| 202 | //============================================================================== | ||
| 203 | /// @ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 204 | /// @brief Use dialog to get date value. | ||
| 205 | /// | ||
| 206 | /// @param[in,out] date Overwritten with user input if return=true and date | ||
| 207 | /// inserted. | ||
| 208 | /// @param[in] heading Heading to display | ||
| 209 | /// @return true if successful display and user input. false if unsuccessful | ||
| 210 | /// display, no user input, or canceled editing. | ||
| 211 | /// | ||
| 212 | /// | ||
| 213 | ///------------------------------------------------------------------------- | ||
| 214 | /// | ||
| 215 | /// **Example:** | ||
| 216 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 217 | /// #include <stdio.h> // printf | ||
| 218 | /// #include <time.h> // time_t, struct tm, time, localtime, strftime | ||
| 219 | /// #include <kodi/gui/dialogs/Numeric.h> | ||
| 220 | /// | ||
| 221 | /// time_t rawtime; | ||
| 222 | /// struct tm * timeinfo; | ||
| 223 | /// char buffer [20]; | ||
| 224 | /// | ||
| 225 | /// time (&rawtime); | ||
| 226 | /// timeinfo = localtime(&rawtime); | ||
| 227 | /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetDate(*timeinfo, "Selected date test call"); | ||
| 228 | /// strftime(buffer, sizeof(buffer), "%Y-%m-%d", timeinfo); | ||
| 229 | /// printf("Selected date it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); | ||
| 230 | /// ~~~~~~~~~~~~~ | ||
| 231 | /// | ||
| 232 | inline bool ATTRIBUTE_HIDDEN ShowAndGetDate(tm& date, const std::string& heading) | ||
| 233 | { | ||
| 234 | using namespace ::kodi::addon; | ||
| 235 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_date( | ||
| 236 | CAddonBase::m_interface->toKodi->kodiBase, &date, heading.c_str()); | ||
| 237 | } | ||
| 238 | //------------------------------------------------------------------------------ | ||
| 239 | |||
| 240 | //============================================================================== | ||
| 241 | /// @ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 242 | /// @brief Use dialog to get a IP | ||
| 243 | /// | ||
| 244 | /// @param[in,out] ipAddress Overwritten with user input if return=true and | ||
| 245 | /// IP address inserted. | ||
| 246 | /// @param[in] heading Heading to display. | ||
| 247 | /// @return true if successful display and user input. false if unsuccessful | ||
| 248 | /// display, no user input, or canceled editing. | ||
| 249 | /// | ||
| 250 | inline bool ATTRIBUTE_HIDDEN ShowAndGetIPAddress(std::string& ipAddress, const std::string& heading) | ||
| 251 | { | ||
| 252 | using namespace ::kodi::addon; | ||
| 253 | char* retString = nullptr; | ||
| 254 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_ip_address( | ||
| 255 | CAddonBase::m_interface->toKodi->kodiBase, ipAddress.c_str(), &retString, heading.c_str()); | ||
| 256 | if (retString != nullptr) | ||
| 257 | { | ||
| 258 | ipAddress = retString; | ||
| 259 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 260 | retString); | ||
| 261 | } | ||
| 262 | return ret; | ||
| 263 | } | ||
| 264 | //------------------------------------------------------------------------------ | ||
| 265 | |||
| 266 | //============================================================================== | ||
| 267 | /// @ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 268 | /// @brief Use dialog to get normal number. | ||
| 269 | /// | ||
| 270 | /// @param[in,out] input Overwritten with user input if return=true and time | ||
| 271 | /// in seconds inserted | ||
| 272 | /// @param[in] heading Heading to display | ||
| 273 | /// @param[in] autoCloseTimeoutMs [opt] To close the dialog after a specified | ||
| 274 | /// time, in milliseconds, default is 0 | ||
| 275 | /// which keeps the dialog open | ||
| 276 | /// indefinitely. | ||
| 277 | /// @return true if successful display and user input. false if unsuccessful | ||
| 278 | /// display, no user input, or canceled editing. | ||
| 279 | /// | ||
| 280 | /// | ||
| 281 | ///------------------------------------------------------------------------- | ||
| 282 | /// | ||
| 283 | /// **Example:** | ||
| 284 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 285 | /// #include <stdio.h> // printf | ||
| 286 | /// #include <stdlib.h> // strtoull (C++11) | ||
| 287 | /// #include <kodi/gui/dialogs/Numeric.h> | ||
| 288 | /// | ||
| 289 | /// std::string number; | ||
| 290 | /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetNumber(number, "Number test call"); | ||
| 291 | /// printf("Written number input is : %llu and was %s\n", | ||
| 292 | /// strtoull(number.c_str(), nullptr, 0), bRet ? "OK" : "Canceled"); | ||
| 293 | /// ~~~~~~~~~~~~~ | ||
| 294 | /// | ||
| 295 | inline bool ATTRIBUTE_HIDDEN ShowAndGetNumber(std::string& input, | ||
| 296 | const std::string& heading, | ||
| 297 | unsigned int autoCloseTimeoutMs = 0) | ||
| 298 | { | ||
| 299 | using namespace ::kodi::addon; | ||
| 300 | char* retString = nullptr; | ||
| 301 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_number( | ||
| 302 | CAddonBase::m_interface->toKodi->kodiBase, input.c_str(), &retString, heading.c_str(), | ||
| 303 | autoCloseTimeoutMs); | ||
| 304 | if (retString != nullptr) | ||
| 305 | { | ||
| 306 | input = retString; | ||
| 307 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 308 | retString); | ||
| 309 | } | ||
| 310 | return ret; | ||
| 311 | } | ||
| 312 | //------------------------------------------------------------------------------ | ||
| 313 | |||
| 314 | //============================================================================== | ||
| 315 | /// @ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 316 | /// @brief Show numeric keypad to get seconds. | ||
| 317 | /// | ||
| 318 | /// @param[in,out] time Overwritten with user input if return=true and time | ||
| 319 | /// in seconds inserted. | ||
| 320 | /// @param[in] heading Heading to display | ||
| 321 | /// @return true if successful display and user input. false if unsuccessful | ||
| 322 | /// display, no user input, or canceled editing. | ||
| 323 | /// | ||
| 324 | inline bool ATTRIBUTE_HIDDEN ShowAndGetSeconds(std::string& time, const std::string& heading) | ||
| 325 | { | ||
| 326 | using namespace ::kodi::addon; | ||
| 327 | char* retString = nullptr; | ||
| 328 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_seconds( | ||
| 329 | CAddonBase::m_interface->toKodi->kodiBase, time.c_str(), &retString, heading.c_str()); | ||
| 330 | if (retString != nullptr) | ||
| 331 | { | ||
| 332 | time = retString; | ||
| 333 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 334 | retString); | ||
| 335 | } | ||
| 336 | return ret; | ||
| 337 | } | ||
| 338 | //------------------------------------------------------------------------------ | ||
| 339 | }; // namespace Numeric | ||
| 340 | /// @} | ||
| 341 | |||
| 342 | } /* namespace dialogs */ | ||
| 343 | } /* namespace gui */ | ||
| 344 | } /* namespace kodi */ | ||
| 345 | |||
| 346 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/OK.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/OK.h new file mode 100644 index 0000000..747ab9d --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/OK.h | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../AddonBase.h" | ||
| 12 | #include "../../c-api/gui/dialogs/ok.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace dialogs | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_dialogs_OK Dialog OK | ||
| 25 | /// @ingroup cpp_kodi_gui_dialogs | ||
| 26 | /// @{ | ||
| 27 | /// @brief @cpp_namespace{ kodi::gui::dialogs::OK } | ||
| 28 | /// **OK dialog**\n | ||
| 29 | /// The functions listed below permit the call of a dialogue of information, a | ||
| 30 | /// confirmation of the user by press from OK required. | ||
| 31 | /// | ||
| 32 | /// It has the header @ref OK.h "#include <kodi/gui/dialogs/OK.h>" | ||
| 33 | /// be included to enjoy it. | ||
| 34 | /// | ||
| 35 | namespace OK | ||
| 36 | { | ||
| 37 | //============================================================================== | ||
| 38 | /// @ingroup cpp_kodi_gui_dialogs_OK | ||
| 39 | /// @brief Use dialog to inform user with text and confirmation with OK with | ||
| 40 | /// continued string. | ||
| 41 | /// | ||
| 42 | /// @param[in] heading Dialog heading. | ||
| 43 | /// @param[in] text Multi-line text. | ||
| 44 | /// | ||
| 45 | /// | ||
| 46 | ///------------------------------------------------------------------------- | ||
| 47 | /// | ||
| 48 | /// **Example:** | ||
| 49 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 50 | /// #include <kodi/gui/dialogs/OK.h> | ||
| 51 | /// ... | ||
| 52 | /// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!\nI'm a call from add-on\n :) :D"); | ||
| 53 | /// ~~~~~~~~~~~~~ | ||
| 54 | /// | ||
| 55 | inline void ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, const std::string& text) | ||
| 56 | { | ||
| 57 | using namespace ::kodi::addon; | ||
| 58 | CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_single_text( | ||
| 59 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); | ||
| 60 | } | ||
| 61 | //------------------------------------------------------------------------------ | ||
| 62 | |||
| 63 | //============================================================================== | ||
| 64 | /// @ingroup cpp_kodi_gui_dialogs_OK | ||
| 65 | /// @brief Use dialog to inform user with text and confirmation with OK with | ||
| 66 | /// strings separated to the lines. | ||
| 67 | /// | ||
| 68 | /// @param[in] heading Dialog heading. | ||
| 69 | /// @param[in] line0 Line #1 text. | ||
| 70 | /// @param[in] line1 Line #2 text. | ||
| 71 | /// @param[in] line2 Line #3 text. | ||
| 72 | /// | ||
| 73 | /// | ||
| 74 | ///------------------------------------------------------------------------- | ||
| 75 | /// | ||
| 76 | /// **Example:** | ||
| 77 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 78 | /// #include <kodi/gui/dialogs/OK.h> | ||
| 79 | /// ... | ||
| 80 | /// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!", "I'm a call from add-on", " :) :D"); | ||
| 81 | /// ~~~~~~~~~~~~~ | ||
| 82 | /// | ||
| 83 | inline void ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, | ||
| 84 | const std::string& line0, | ||
| 85 | const std::string& line1, | ||
| 86 | const std::string& line2) | ||
| 87 | { | ||
| 88 | using namespace ::kodi::addon; | ||
| 89 | CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_line_text( | ||
| 90 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), line0.c_str(), line1.c_str(), | ||
| 91 | line2.c_str()); | ||
| 92 | } | ||
| 93 | //------------------------------------------------------------------------------ | ||
| 94 | } // namespace OK | ||
| 95 | /// @} | ||
| 96 | |||
| 97 | } /* namespace dialogs */ | ||
| 98 | } /* namespace gui */ | ||
| 99 | } /* namespace kodi */ | ||
| 100 | |||
| 101 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Progress.h index b1f8cc5..d242a56 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Progress.h | |||
| @@ -8,8 +8,10 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | 11 | #include "../../AddonBase.h" |
| 12 | #include "../../c-api/gui/dialogs/progress.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 13 | 15 | ||
| 14 | namespace kodi | 16 | namespace kodi |
| 15 | { | 17 | { |
| @@ -18,14 +20,12 @@ namespace gui | |||
| 18 | namespace dialogs | 20 | namespace dialogs |
| 19 | { | 21 | { |
| 20 | 22 | ||
| 21 | //============================================================================ | 23 | //============================================================================== |
| 22 | /// | 24 | /// @defgroup cpp_kodi_gui_dialogs_CProgress Dialog Progress |
| 23 | /// \defgroup cpp_kodi_gui_dialogs_CProgress Dialog Progress | 25 | /// @ingroup cpp_kodi_gui_dialogs |
| 24 | /// \ingroup cpp_kodi_gui | 26 | /// @brief @cpp_class{ kodi::gui::dialogs::CProgress } |
| 25 | /// @brief \cpp_class{ kodi::gui::dialogs::CProgress } | 27 | /// **Progress dialog shown in center**\n |
| 26 | /// **Progress dialog shown in center** | 28 | /// The with @ref Progress.h "#include <kodi/gui/dialogs/Progress.h>" |
| 27 | /// | ||
| 28 | /// The with \ref DialogProgress.h "#include <kodi/gui/dialogs/Progress.h>" | ||
| 29 | /// given class are basically used to create Kodi's progress dialog with named | 29 | /// given class are basically used to create Kodi's progress dialog with named |
| 30 | /// text fields. | 30 | /// text fields. |
| 31 | /// | 31 | /// |
| @@ -52,9 +52,8 @@ namespace dialogs | |||
| 52 | class ATTRIBUTE_HIDDEN CProgress | 52 | class ATTRIBUTE_HIDDEN CProgress |
| 53 | { | 53 | { |
| 54 | public: | 54 | public: |
| 55 | //========================================================================== | 55 | //============================================================================ |
| 56 | /// | 56 | /// @ingroup cpp_kodi_gui_dialogs_CProgress |
| 57 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 58 | /// @brief Construct a new dialog | 57 | /// @brief Construct a new dialog |
| 59 | /// | 58 | /// |
| 60 | CProgress() | 59 | CProgress() |
| @@ -66,11 +65,10 @@ public: | |||
| 66 | kodi::Log(ADDON_LOG_FATAL, | 65 | kodi::Log(ADDON_LOG_FATAL, |
| 67 | "kodi::gui::dialogs::CProgress can't create window class from Kodi !!!"); | 66 | "kodi::gui::dialogs::CProgress can't create window class from Kodi !!!"); |
| 68 | } | 67 | } |
| 69 | //-------------------------------------------------------------------------- | 68 | //---------------------------------------------------------------------------- |
| 70 | 69 | ||
| 71 | //========================================================================== | 70 | //============================================================================ |
| 72 | /// | 71 | /// @ingroup cpp_kodi_gui_dialogs_CProgress |
| 73 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 74 | /// @brief Destructor | 72 | /// @brief Destructor |
| 75 | /// | 73 | /// |
| 76 | ~CProgress() | 74 | ~CProgress() |
| @@ -80,11 +78,10 @@ public: | |||
| 80 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->delete_dialog( | 78 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->delete_dialog( |
| 81 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | 79 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); |
| 82 | } | 80 | } |
| 83 | //-------------------------------------------------------------------------- | 81 | //---------------------------------------------------------------------------- |
| 84 | 82 | ||
| 85 | //========================================================================== | 83 | //============================================================================ |
| 86 | /// | 84 | /// @ingroup cpp_kodi_gui_dialogs_CProgress |
| 87 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 88 | /// @brief To open the dialog | 85 | /// @brief To open the dialog |
| 89 | /// | 86 | /// |
| 90 | void Open() | 87 | void Open() |
| @@ -93,11 +90,10 @@ public: | |||
| 93 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->open( | 90 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->open( |
| 94 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | 91 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); |
| 95 | } | 92 | } |
| 96 | //-------------------------------------------------------------------------- | 93 | //---------------------------------------------------------------------------- |
| 97 | 94 | ||
| 98 | //========================================================================== | 95 | //============================================================================ |
| 99 | /// | 96 | /// @ingroup cpp_kodi_gui_dialogs_CProgress |
| 100 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 101 | /// @brief Set the heading title of dialog | 97 | /// @brief Set the heading title of dialog |
| 102 | /// | 98 | /// |
| 103 | /// @param[in] heading Title string to use | 99 | /// @param[in] heading Title string to use |
| @@ -108,11 +104,10 @@ public: | |||
| 108 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_heading( | 104 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_heading( |
| 109 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, heading.c_str()); | 105 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, heading.c_str()); |
| 110 | } | 106 | } |
| 111 | //-------------------------------------------------------------------------- | 107 | //---------------------------------------------------------------------------- |
| 112 | 108 | ||
| 113 | //========================================================================== | 109 | //============================================================================ |
| 114 | /// | 110 | /// @ingroup cpp_kodi_gui_dialogs_CProgress |
| 115 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 116 | /// @brief To set the line text field on dialog from 0 - 2 | 111 | /// @brief To set the line text field on dialog from 0 - 2 |
| 117 | /// | 112 | /// |
| 118 | /// @param[in] iLine Line number | 113 | /// @param[in] iLine Line number |
| @@ -124,11 +119,10 @@ public: | |||
| 124 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_line( | 119 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_line( |
| 125 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, iLine, line.c_str()); | 120 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, iLine, line.c_str()); |
| 126 | } | 121 | } |
| 127 | //-------------------------------------------------------------------------- | 122 | //---------------------------------------------------------------------------- |
| 128 | 123 | ||
| 129 | //========================================================================== | 124 | //============================================================================ |
| 130 | /// | 125 | /// @ingroup cpp_kodi_gui_dialogs_CProgress |
| 131 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 132 | /// @brief To enable and show cancel button on dialog | 126 | /// @brief To enable and show cancel button on dialog |
| 133 | /// | 127 | /// |
| 134 | /// @param[in] canCancel if true becomes it shown | 128 | /// @param[in] canCancel if true becomes it shown |
| @@ -139,11 +133,10 @@ public: | |||
| 139 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_can_cancel( | 133 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_can_cancel( |
| 140 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, canCancel); | 134 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, canCancel); |
| 141 | } | 135 | } |
| 142 | //-------------------------------------------------------------------------- | 136 | //---------------------------------------------------------------------------- |
| 143 | 137 | ||
| 144 | //========================================================================== | 138 | //============================================================================ |
| 145 | /// | 139 | /// @ingroup cpp_kodi_gui_dialogs_CProgress |
| 146 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 147 | /// @brief To check dialog for clicked cancel button | 140 | /// @brief To check dialog for clicked cancel button |
| 148 | /// | 141 | /// |
| 149 | /// @return True if canceled | 142 | /// @return True if canceled |
| @@ -154,11 +147,10 @@ public: | |||
| 154 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->is_canceled( | 147 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->is_canceled( |
| 155 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | 148 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); |
| 156 | } | 149 | } |
| 157 | //-------------------------------------------------------------------------- | 150 | //---------------------------------------------------------------------------- |
| 158 | 151 | ||
| 159 | //========================================================================== | 152 | //============================================================================ |
| 160 | /// | 153 | /// @ingroup cpp_kodi_gui_dialogs_CProgress |
| 161 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 162 | /// @brief Get the current progress position as percent | 154 | /// @brief Get the current progress position as percent |
| 163 | /// | 155 | /// |
| 164 | /// @param[in] percentage Position to use from 0 to 100 | 156 | /// @param[in] percentage Position to use from 0 to 100 |
| @@ -169,11 +161,10 @@ public: | |||
| 169 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_percentage( | 161 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_percentage( |
| 170 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | 162 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); |
| 171 | } | 163 | } |
| 172 | //-------------------------------------------------------------------------- | 164 | //---------------------------------------------------------------------------- |
| 173 | 165 | ||
| 174 | //========================================================================== | 166 | //============================================================================ |
| 175 | /// | 167 | /// @ingroup cpp_kodi_gui_dialogs_CProgress |
| 176 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 177 | /// @brief To set the current progress position as percent | 168 | /// @brief To set the current progress position as percent |
| 178 | /// | 169 | /// |
| 179 | /// @return Current Position used from 0 to 100 | 170 | /// @return Current Position used from 0 to 100 |
| @@ -184,11 +175,10 @@ public: | |||
| 184 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->get_percentage( | 175 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->get_percentage( |
| 185 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | 176 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); |
| 186 | } | 177 | } |
| 187 | //-------------------------------------------------------------------------- | 178 | //---------------------------------------------------------------------------- |
| 188 | 179 | ||
| 189 | //========================================================================== | 180 | //============================================================================ |
| 190 | /// | 181 | /// @ingroup cpp_kodi_gui_dialogs_CProgress |
| 191 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 192 | /// @brief To show or hide progress bar dialog | 182 | /// @brief To show or hide progress bar dialog |
| 193 | /// | 183 | /// |
| 194 | /// @param[in] onOff If true becomes it shown | 184 | /// @param[in] onOff If true becomes it shown |
| @@ -199,11 +189,10 @@ public: | |||
| 199 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->show_progress_bar( | 189 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->show_progress_bar( |
| 200 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, onOff); | 190 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, onOff); |
| 201 | } | 191 | } |
| 202 | //-------------------------------------------------------------------------- | 192 | //---------------------------------------------------------------------------- |
| 203 | 193 | ||
| 204 | //========================================================================== | 194 | //============================================================================ |
| 205 | /// | 195 | /// @ingroup cpp_kodi_gui_dialogs_CProgress |
| 206 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 207 | /// @brief Set the maximum position of progress, needed if `SetProgressAdvance(...)` is used | 196 | /// @brief Set the maximum position of progress, needed if `SetProgressAdvance(...)` is used |
| 208 | /// | 197 | /// |
| 209 | /// @param[in] max Biggest usable position to use | 198 | /// @param[in] max Biggest usable position to use |
| @@ -214,11 +203,10 @@ public: | |||
| 214 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_max( | 203 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_max( |
| 215 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, max); | 204 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, max); |
| 216 | } | 205 | } |
| 217 | //-------------------------------------------------------------------------- | 206 | //---------------------------------------------------------------------------- |
| 218 | 207 | ||
| 219 | //========================================================================== | 208 | //============================================================================ |
| 220 | /// | 209 | /// @ingroup cpp_kodi_gui_dialogs_CProgress |
| 221 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 222 | /// @brief To increase progress bar by defined step size until reach of maximum position | 210 | /// @brief To increase progress bar by defined step size until reach of maximum position |
| 223 | /// | 211 | /// |
| 224 | /// @param[in] steps Step size to increase, default is 1 | 212 | /// @param[in] steps Step size to increase, default is 1 |
| @@ -229,11 +217,10 @@ public: | |||
| 229 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_advance( | 217 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_advance( |
| 230 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, steps); | 218 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, steps); |
| 231 | } | 219 | } |
| 232 | //-------------------------------------------------------------------------- | 220 | //---------------------------------------------------------------------------- |
| 233 | 221 | ||
| 234 | //========================================================================== | 222 | //============================================================================ |
| 235 | /// | 223 | /// @ingroup cpp_kodi_gui_dialogs_CProgress |
| 236 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 237 | /// @brief To check progress was canceled on work | 224 | /// @brief To check progress was canceled on work |
| 238 | /// | 225 | /// |
| 239 | /// @return True if aborted | 226 | /// @return True if aborted |
| @@ -244,12 +231,14 @@ public: | |||
| 244 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->abort( | 231 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->abort( |
| 245 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | 232 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); |
| 246 | } | 233 | } |
| 247 | //-------------------------------------------------------------------------- | 234 | //---------------------------------------------------------------------------- |
| 248 | 235 | ||
| 249 | private: | 236 | private: |
| 250 | void* m_DialogHandle; | 237 | KODI_GUI_HANDLE m_DialogHandle; |
| 251 | }; | 238 | }; |
| 252 | 239 | ||
| 253 | } /* namespace dialogs */ | 240 | } /* namespace dialogs */ |
| 254 | } /* namespace gui */ | 241 | } /* namespace gui */ |
| 255 | } /* namespace kodi */ | 242 | } /* namespace kodi */ |
| 243 | |||
| 244 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Select.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Select.h new file mode 100644 index 0000000..9b1923e --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Select.h | |||
| @@ -0,0 +1,269 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../AddonBase.h" | ||
| 12 | #include "../../c-api/gui/dialogs/select.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace dialogs | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_dialogs_Select_Defs Definitions, structures and enumerators | ||
| 25 | /// @ingroup cpp_kodi_gui_dialogs_Select | ||
| 26 | /// @brief **Dialog Select definition values**\n | ||
| 27 | /// Data structures associated with this dialog. | ||
| 28 | /// | ||
| 29 | //------------------------------------------------------------------------------ | ||
| 30 | |||
| 31 | //============================================================================== | ||
| 32 | /// @ingroup cpp_kodi_gui_dialogs_Select_Defs | ||
| 33 | /// @brief **Selection entry structure**\n | ||
| 34 | /// Used to provide the necessary data for the selection dialog and to declare | ||
| 35 | /// the selected position in it. | ||
| 36 | /// | ||
| 37 | typedef struct SSelectionEntry | ||
| 38 | { | ||
| 39 | /*! \cond PRIVATE */ | ||
| 40 | SSelectionEntry() = default; | ||
| 41 | /*! \endcond */ | ||
| 42 | |||
| 43 | /// Entry identfication string | ||
| 44 | std::string id; | ||
| 45 | |||
| 46 | /// Entry name to show on GUI dialog | ||
| 47 | std::string name; | ||
| 48 | |||
| 49 | /// Place where entry can be preselected and after return the from user | ||
| 50 | /// selected is set. | ||
| 51 | bool selected = false; | ||
| 52 | } SSelectionEntry; | ||
| 53 | //------------------------------------------------------------------------------ | ||
| 54 | |||
| 55 | //============================================================================== | ||
| 56 | /// @defgroup cpp_kodi_gui_dialogs_Select Dialog Select | ||
| 57 | /// @ingroup cpp_kodi_gui_dialogs | ||
| 58 | /// @{ | ||
| 59 | /// @brief @cpp_namespace{ kodi::gui::dialogs::Select } | ||
| 60 | /// **Selection dialog**\n | ||
| 61 | /// The function listed below permits the call of a dialogue to select of an | ||
| 62 | /// entry as a key | ||
| 63 | /// | ||
| 64 | /// It has the header @ref Select.h "#include <kodi/gui/dialogs/Select.h>" | ||
| 65 | /// be included to enjoy it. | ||
| 66 | /// | ||
| 67 | /// | ||
| 68 | namespace Select | ||
| 69 | { | ||
| 70 | //============================================================================== | ||
| 71 | /// @ingroup cpp_kodi_gui_dialogs_Select | ||
| 72 | /// @brief Show a selection dialog about given parts. | ||
| 73 | /// | ||
| 74 | /// @param[in] heading Dialog heading name | ||
| 75 | /// @param[in] entries String list about entries | ||
| 76 | /// @param[in] selected [opt] Predefined selection (default is <tt>-1</tt> for | ||
| 77 | /// the first) | ||
| 78 | /// @param[in] autoclose [opt] To close dialog automatic after the given time | ||
| 79 | /// in ms. As '0' it stays open. | ||
| 80 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or | ||
| 81 | /// canceled | ||
| 82 | /// | ||
| 83 | /// | ||
| 84 | ///------------------------------------------------------------------------- | ||
| 85 | /// | ||
| 86 | /// **Example:** | ||
| 87 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 88 | /// #include <kodi/gui/dialogs/Select.h> | ||
| 89 | /// | ||
| 90 | /// const std::vector<std::string> entries | ||
| 91 | /// { | ||
| 92 | /// "Test 1", | ||
| 93 | /// "Test 2", | ||
| 94 | /// "Test 3", | ||
| 95 | /// "Test 4", | ||
| 96 | /// "Test 5" | ||
| 97 | /// }; | ||
| 98 | /// | ||
| 99 | /// int selected = kodi::gui::dialogs::Select::Show("Test selection", entries, -1); | ||
| 100 | /// if (selected < 0) | ||
| 101 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 102 | /// else | ||
| 103 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 104 | /// ~~~~~~~~~~~~~ | ||
| 105 | /// | ||
| 106 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 107 | const std::vector<std::string>& entries, | ||
| 108 | int selected = -1, | ||
| 109 | unsigned int autoclose = 0) | ||
| 110 | { | ||
| 111 | using namespace ::kodi::addon; | ||
| 112 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 113 | const char** cEntries = (const char**)malloc(size * sizeof(const char**)); | ||
| 114 | for (unsigned int i = 0; i < size; ++i) | ||
| 115 | { | ||
| 116 | cEntries[i] = entries[i].c_str(); | ||
| 117 | } | ||
| 118 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open( | ||
| 119 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected, | ||
| 120 | autoclose); | ||
| 121 | free(cEntries); | ||
| 122 | return ret; | ||
| 123 | } | ||
| 124 | //------------------------------------------------------------------------------ | ||
| 125 | |||
| 126 | //============================================================================== | ||
| 127 | /// @ingroup cpp_kodi_gui_dialogs_Select | ||
| 128 | /// @brief Show a selection dialog about given parts. | ||
| 129 | /// | ||
| 130 | /// This function is mostly equal to the other, only becomes the string list | ||
| 131 | /// here done by a @ref SSelectionEntry, where a ID string can be defined. | ||
| 132 | /// | ||
| 133 | /// @param[in] heading Dialog heading name | ||
| 134 | /// @param[in] entries @ref SSelectionEntry list about entries | ||
| 135 | /// @param[in] selected [opt] Predefined selection (default is <tt>-1</tt> for | ||
| 136 | /// the first) | ||
| 137 | /// @param[in] autoclose [opt] To close dialog automatic after the given time | ||
| 138 | /// in ms. As '0' it stays open. | ||
| 139 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected | ||
| 140 | /// or canceled | ||
| 141 | /// | ||
| 142 | /// | ||
| 143 | ///------------------------------------------------------------------------- | ||
| 144 | /// | ||
| 145 | /// **Example:** | ||
| 146 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 147 | /// #include <kodi/gui/dialogs/Select.h> | ||
| 148 | /// | ||
| 149 | /// std::vector<kodi::gui::dialogs::SSelectionEntry> entries | ||
| 150 | /// { | ||
| 151 | /// { "ID 1", "Test 1", false }, | ||
| 152 | /// { "ID 2", "Test 2", false }, | ||
| 153 | /// { "ID 3", "Test 3", false }, | ||
| 154 | /// { "ID 4", "Test 4", false }, | ||
| 155 | /// { "ID 5", "Test 5", false } | ||
| 156 | /// }; | ||
| 157 | /// | ||
| 158 | /// int selected = kodi::gui::dialogs::Select::Show("Test selection", entries, -1); | ||
| 159 | /// if (selected < 0) | ||
| 160 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 161 | /// else | ||
| 162 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 163 | /// ~~~~~~~~~~~~~ | ||
| 164 | /// | ||
| 165 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 166 | std::vector<kodi::gui::dialogs::SSelectionEntry>& entries, | ||
| 167 | int selected = -1, | ||
| 168 | unsigned int autoclose = 0) | ||
| 169 | { | ||
| 170 | using namespace ::kodi::addon; | ||
| 171 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 172 | const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char*))); | ||
| 173 | for (unsigned int i = 0; i < size; ++i) | ||
| 174 | { | ||
| 175 | cEntries[i] = entries[i].name.c_str(); | ||
| 176 | if (selected == -1 && entries[i].selected) | ||
| 177 | selected = i; | ||
| 178 | } | ||
| 179 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open( | ||
| 180 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected, | ||
| 181 | autoclose); | ||
| 182 | if (ret >= 0) | ||
| 183 | { | ||
| 184 | entries[ret].selected = true; | ||
| 185 | } | ||
| 186 | free(cEntries); | ||
| 187 | return ret; | ||
| 188 | } | ||
| 189 | //------------------------------------------------------------------------------ | ||
| 190 | |||
| 191 | //============================================================================== | ||
| 192 | /// @ingroup cpp_kodi_gui_dialogs_Select | ||
| 193 | /// @brief Show a multiple selection dialog about given parts. | ||
| 194 | /// | ||
| 195 | /// @param[in] heading Dialog heading name | ||
| 196 | /// @param[in] entries @ref SSelectionEntry list about entries | ||
| 197 | /// @param[in] autoclose [opt] To close dialog automatic after the given time in | ||
| 198 | /// ms. As '0' it stays open. | ||
| 199 | /// @return The selected entries, if return <tt>empty</tt> was nothing selected | ||
| 200 | /// or canceled | ||
| 201 | /// | ||
| 202 | /// With selected on @ref SSelectionEntry can be a pre selection defined. | ||
| 203 | /// | ||
| 204 | ///------------------------------------------------------------------------- | ||
| 205 | /// | ||
| 206 | /// **Example:** | ||
| 207 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 208 | /// #include <kodi/gui/dialogs/Select.h> | ||
| 209 | /// | ||
| 210 | /// std::vector<kodi::gui::dialogs::SSelectionEntry> entries | ||
| 211 | /// { | ||
| 212 | /// { "ID 1", "Test 1", false }, | ||
| 213 | /// { "ID 2", "Test 2", false }, | ||
| 214 | /// { "ID 3", "Test 3", false }, | ||
| 215 | /// { "ID 4", "Test 4", false }, | ||
| 216 | /// { "ID 5", "Test 5", false } | ||
| 217 | /// }; | ||
| 218 | /// | ||
| 219 | /// bool ret = kodi::gui::dialogs::Select::ShowMultiSelect("Test selection", entries); | ||
| 220 | /// if (!ret) | ||
| 221 | /// fprintf(stderr, "Selection canceled\n"); | ||
| 222 | /// else | ||
| 223 | /// { | ||
| 224 | /// fprintf(stderr, "Selected items:\n"); | ||
| 225 | /// for (const auto& entry : entries) | ||
| 226 | /// { | ||
| 227 | /// if (entry.selected) | ||
| 228 | /// fprintf(stderr, " - %s\n", entry.selected.id.c_str()); | ||
| 229 | /// } | ||
| 230 | /// } | ||
| 231 | /// ~~~~~~~~~~~~~ | ||
| 232 | /// | ||
| 233 | inline bool ATTRIBUTE_HIDDEN ShowMultiSelect(const std::string& heading, | ||
| 234 | std::vector<kodi::gui::dialogs::SSelectionEntry>& entries, | ||
| 235 | int autoclose = 0) | ||
| 236 | { | ||
| 237 | using namespace ::kodi::addon; | ||
| 238 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 239 | const char** cEntryIDs = static_cast<const char**>(malloc(size * sizeof(const char*))); | ||
| 240 | const char** cEntryNames = static_cast<const char**>(malloc(size * sizeof(const char*))); | ||
| 241 | bool* cEntriesSelected = static_cast<bool*>(malloc(size * sizeof(bool))); | ||
| 242 | for (unsigned int i = 0; i < size; ++i) | ||
| 243 | { | ||
| 244 | cEntryIDs[i] = entries[i].id.c_str(); | ||
| 245 | cEntryNames[i] = entries[i].name.c_str(); | ||
| 246 | cEntriesSelected[i] = entries[i].selected; | ||
| 247 | } | ||
| 248 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open_multi_select( | ||
| 249 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntryIDs, cEntryNames, | ||
| 250 | cEntriesSelected, size, autoclose); | ||
| 251 | if (ret) | ||
| 252 | { | ||
| 253 | for (unsigned int i = 0; i < size; ++i) | ||
| 254 | entries[i].selected = cEntriesSelected[i]; | ||
| 255 | } | ||
| 256 | free(cEntryNames); | ||
| 257 | free(cEntryIDs); | ||
| 258 | free(cEntriesSelected); | ||
| 259 | return ret; | ||
| 260 | } | ||
| 261 | //------------------------------------------------------------------------------ | ||
| 262 | }; // namespace Select | ||
| 263 | /// @} | ||
| 264 | |||
| 265 | } /* namespace dialogs */ | ||
| 266 | } /* namespace gui */ | ||
| 267 | } /* namespace kodi */ | ||
| 268 | |||
| 269 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/TextViewer.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/TextViewer.h new file mode 100644 index 0000000..42a86f3 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/TextViewer.h | |||
| @@ -0,0 +1,109 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2015-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../AddonBase.h" | ||
| 12 | #include "../../c-api/gui/dialogs/text_viewer.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace dialogs | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_dialogs_TextViewer Dialog Text Viewer | ||
| 25 | /// @ingroup cpp_kodi_gui_dialogs | ||
| 26 | /// @{ | ||
| 27 | /// @brief @cpp_namespace{ kodi::gui::dialogs::TextViewer } | ||
| 28 | /// **Text viewer dialog**\n | ||
| 29 | /// The text viewer dialog can be used to display descriptions, help texts or | ||
| 30 | /// other larger texts. | ||
| 31 | /// | ||
| 32 | /// In order to achieve a line break is a <b>\\n</b> directly in the text or | ||
| 33 | /// in the <em>"./resources/language/resource.language.??_??/strings.po"</em> | ||
| 34 | /// to call with <b>std::string kodi::general::GetLocalizedString(...);</b>. | ||
| 35 | /// | ||
| 36 | /// It has the header \ref TextViewer.h "#include <kodi/gui/dialogs/TextViewer.h>" | ||
| 37 | /// be included to enjoy it. | ||
| 38 | /// | ||
| 39 | namespace TextViewer | ||
| 40 | { | ||
| 41 | //============================================================================== | ||
| 42 | /// @ingroup cpp_kodi_gui_dialogs_TextViewer | ||
| 43 | /// @brief Show info text dialog | ||
| 44 | /// | ||
| 45 | /// @param[in] heading mall heading text | ||
| 46 | /// @param[in] text Showed text on dialog | ||
| 47 | /// | ||
| 48 | /// | ||
| 49 | ///------------------------------------------------------------------------- | ||
| 50 | /// | ||
| 51 | /// **Example:** | ||
| 52 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 53 | /// #include <kodi/gui/dialogs/TextViewer.h> | ||
| 54 | /// | ||
| 55 | /// kodi::gui::dialogs::TextViewer::Show("The Wizard of Oz (1939 film)", | ||
| 56 | /// "The Wizard of Oz is a 1939 American musical comedy-drama fantasy film " | ||
| 57 | /// "produced by Metro-Goldwyn-Mayer, and the most well-known and commercially " | ||
| 58 | /// "successful adaptation based on the 1900 novel The Wonderful Wizard of Oz " | ||
| 59 | /// "by L. Frank Baum. The film stars Judy Garland as Dorothy Gale. The film" | ||
| 60 | /// "co-stars Terry the dog, billed as Toto; Ray Bolger, Jack Haley, Bert Lahr, " | ||
| 61 | /// "Frank Morgan, Billie Burke, Margaret Hamilton, with Charley Grapewin and " | ||
| 62 | /// "Clara Blandick, and the Singer Midgets as the Munchkins.\n" | ||
| 63 | /// "\n" | ||
| 64 | /// "Notable for its use of Technicolor, fantasy storytelling, musical score and " | ||
| 65 | /// "unusual characters, over the years it has become an icon of American popular " | ||
| 66 | /// "culture. It was nominated for six Academy Awards, including Best Picture but " | ||
| 67 | /// "lost to Gone with the Wind. It did win in two other categories including Best " | ||
| 68 | /// "Original Song for \"Over the Rainbow\". However, the film was a box office " | ||
| 69 | /// "disappointment on its initial release, earning only $3,017,000 on a $2,777,000 " | ||
| 70 | /// "budget, despite receiving largely positive reviews. It was MGM's most " | ||
| 71 | /// "expensive production at that time, and did not completely recoup the studio's " | ||
| 72 | /// "investment and turn a profit until theatrical re-releases starting in 1949.\n" | ||
| 73 | /// "\n" | ||
| 74 | /// "The 1956 broadcast television premiere of the film on CBS re-introduced the " | ||
| 75 | /// "film to the wider public and eventually made the presentation an annual " | ||
| 76 | /// "tradition, making it one of the most known films in cinema history. The " | ||
| 77 | /// "film was named the most-viewed motion picture on television syndication by " | ||
| 78 | /// "the Library of Congress who also included the film in its National Film " | ||
| 79 | /// "Registry in its inaugural year in 1989. Designation on the registry calls " | ||
| 80 | /// "for efforts to preserve it for being \"culturally, historically, and " | ||
| 81 | /// "aesthetically significant\". It is also one of the few films on UNESCO's " | ||
| 82 | /// "Memory of the World Register.\n" | ||
| 83 | /// "\n" | ||
| 84 | /// "The Wizard of Oz is often ranked on best-movie lists in critics' and public " | ||
| 85 | /// "polls. It is the source of many quotes referenced in modern popular culture. " | ||
| 86 | /// "It was directed primarily by Victor Fleming (who left production to take " | ||
| 87 | /// "over direction on the troubled Gone with the Wind production). Noel Langley, " | ||
| 88 | /// "Florence Ryerson and Edgar Allan Woolf received credit for the screenplay, " | ||
| 89 | /// "but there were uncredited contributions by others. The songs were written " | ||
| 90 | /// "by Edgar \"Yip\" Harburg (lyrics) and Harold Arlen (music). The incidental " | ||
| 91 | /// "music, based largely on the songs, was composed by Herbert Stothart, with " | ||
| 92 | /// "interspersed renderings from classical composers.\n"); | ||
| 93 | /// ~~~~~~~~~~~~~ | ||
| 94 | /// | ||
| 95 | inline void ATTRIBUTE_HIDDEN Show(const std::string& heading, const std::string& text) | ||
| 96 | { | ||
| 97 | using namespace ::kodi::addon; | ||
| 98 | CAddonBase::m_interface->toKodi->kodi_gui->dialogTextViewer->open( | ||
| 99 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); | ||
| 100 | } | ||
| 101 | //------------------------------------------------------------------------------ | ||
| 102 | }; // namespace TextViewer | ||
| 103 | /// @} | ||
| 104 | |||
| 105 | } /* namespace dialogs */ | ||
| 106 | } /* namespace gui */ | ||
| 107 | } /* namespace kodi */ | ||
| 108 | |||
| 109 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/YesNo.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/YesNo.h new file mode 100644 index 0000000..6e6e069 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/YesNo.h | |||
| @@ -0,0 +1,188 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../AddonBase.h" | ||
| 12 | #include "../../c-api/gui/dialogs/yes_no.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace dialogs | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_dialogs_YesNo Dialog Yes/No | ||
| 25 | /// @ingroup cpp_kodi_gui_dialogs | ||
| 26 | /// @{ | ||
| 27 | /// @brief @cpp_namespace{ kodi::gui::dialogs::YesNo } | ||
| 28 | /// **Yes / No dialog**\n | ||
| 29 | /// The Yes / No dialog can be used to inform the user about questions and get | ||
| 30 | /// the answer. | ||
| 31 | /// | ||
| 32 | /// In order to achieve a line break is a <b>\\n</b> directly in the text or | ||
| 33 | /// in the <em>"./resources/language/resource.language.??_??/strings.po"</em> | ||
| 34 | /// to call with <b>std::string kodi::general::GetLocalizedString(...);</b>. | ||
| 35 | /// | ||
| 36 | /// It has the header @ref YesNo.h "#include <kodi/gui/dialogs/YesNo.h>" | ||
| 37 | /// be included to enjoy it. | ||
| 38 | /// | ||
| 39 | namespace YesNo | ||
| 40 | { | ||
| 41 | //============================================================================== | ||
| 42 | /// @ingroup cpp_kodi_gui_dialogs_YesNo | ||
| 43 | /// @brief Use dialog to get numeric new password with one text string shown | ||
| 44 | /// everywhere and cancel return field. | ||
| 45 | /// | ||
| 46 | /// @param[in] heading Dialog heading | ||
| 47 | /// @param[in] text Multi-line text | ||
| 48 | /// @param[out] canceled Return value about cancel button | ||
| 49 | /// @param[in] noLabel [opt] label to put on the no button | ||
| 50 | /// @param[in] yesLabel [opt] label to put on the yes button | ||
| 51 | /// @return Returns True if 'Yes' was pressed, else False | ||
| 52 | /// | ||
| 53 | /// @note It is preferred to only use this as it is actually a multi-line text. | ||
| 54 | /// | ||
| 55 | /// | ||
| 56 | ///------------------------------------------------------------------------- | ||
| 57 | /// | ||
| 58 | /// **Example:** | ||
| 59 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 60 | /// #include <kodi/gui/dialogs/YesNo.h> | ||
| 61 | /// | ||
| 62 | /// bool canceled = false; | ||
| 63 | /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( | ||
| 64 | /// "Yes / No test call", // The Header | ||
| 65 | /// "You has opened Yes / No dialog for test\n\nIs this OK for you?", | ||
| 66 | /// canceled, // return value about cancel button | ||
| 67 | /// "Not really", // No label, is optional and if empty "No" | ||
| 68 | /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" | ||
| 69 | /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", | ||
| 70 | /// ret ? "yes" : "no", | ||
| 71 | /// canceled ? "canceled" : "not canceled"); | ||
| 72 | /// ~~~~~~~~~~~~~ | ||
| 73 | /// | ||
| 74 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, | ||
| 75 | const std::string& text, | ||
| 76 | bool& canceled, | ||
| 77 | const std::string& noLabel = "", | ||
| 78 | const std::string& yesLabel = "") | ||
| 79 | { | ||
| 80 | using namespace ::kodi::addon; | ||
| 81 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_single_text( | ||
| 82 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str(), &canceled, | ||
| 83 | noLabel.c_str(), yesLabel.c_str()); | ||
| 84 | } | ||
| 85 | //------------------------------------------------------------------------------ | ||
| 86 | |||
| 87 | //============================================================================== | ||
| 88 | /// @ingroup cpp_kodi_gui_dialogs_YesNo | ||
| 89 | /// @brief Use dialog to get numeric new password with separated line strings. | ||
| 90 | /// | ||
| 91 | /// @param[in] heading Dialog heading | ||
| 92 | /// @param[in] line0 Line #0 text | ||
| 93 | /// @param[in] line1 Line #1 text | ||
| 94 | /// @param[in] line2 Line #2 text | ||
| 95 | /// @param[in] noLabel [opt] label to put on the no button | ||
| 96 | /// @param[in] yesLabel [opt] label to put on the yes button | ||
| 97 | /// @return Returns True if 'Yes' was pressed, else False | ||
| 98 | /// | ||
| 99 | /// | ||
| 100 | ///------------------------------------------------------------------------- | ||
| 101 | /// | ||
| 102 | /// **Example:** | ||
| 103 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 104 | /// #include <kodi/gui/dialogs/YesNo.h> | ||
| 105 | /// | ||
| 106 | /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( | ||
| 107 | /// "Yes / No test call", // The Header | ||
| 108 | /// "You has opened Yes / No dialog for test", | ||
| 109 | /// "", | ||
| 110 | /// "Is this OK for you?", | ||
| 111 | /// "Not really", // No label, is optional and if empty "No" | ||
| 112 | /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" | ||
| 113 | /// fprintf(stderr, "You has called Yes/No, returned '%s'\n", | ||
| 114 | /// ret ? "yes" : "no"); | ||
| 115 | /// ~~~~~~~~~~~~~ | ||
| 116 | /// | ||
| 117 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, | ||
| 118 | const std::string& line0, | ||
| 119 | const std::string& line1, | ||
| 120 | const std::string& line2, | ||
| 121 | const std::string& noLabel = "", | ||
| 122 | const std::string& yesLabel = "") | ||
| 123 | { | ||
| 124 | using namespace ::kodi::addon; | ||
| 125 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_text( | ||
| 126 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), line0.c_str(), line1.c_str(), | ||
| 127 | line2.c_str(), noLabel.c_str(), yesLabel.c_str()); | ||
| 128 | } | ||
| 129 | //------------------------------------------------------------------------------ | ||
| 130 | |||
| 131 | //============================================================================== | ||
| 132 | /// @ingroup cpp_kodi_gui_dialogs_YesNo | ||
| 133 | /// @brief Use dialog to get numeric new password with separated line strings | ||
| 134 | /// and cancel return field. | ||
| 135 | /// | ||
| 136 | /// @param[in] heading Dialog heading | ||
| 137 | /// @param[in] line0 Line #0 text | ||
| 138 | /// @param[in] line1 Line #1 text | ||
| 139 | /// @param[in] line2 Line #2 text | ||
| 140 | /// @param[out] canceled Return value about cancel button | ||
| 141 | /// @param[in] noLabel [opt] label to put on the no button | ||
| 142 | /// @param[in] yesLabel [opt] label to put on the yes button | ||
| 143 | /// @return Returns True if 'Yes' was pressed, else False | ||
| 144 | /// | ||
| 145 | /// | ||
| 146 | ///------------------------------------------------------------------------- | ||
| 147 | /// | ||
| 148 | /// **Example:** | ||
| 149 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 150 | /// #include <kodi/gui/dialogs/YesNo.h> | ||
| 151 | /// | ||
| 152 | /// bool canceled = false; | ||
| 153 | /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( | ||
| 154 | /// "Yes / No test call", // The Header | ||
| 155 | /// "You has opened Yes / No dialog for test", | ||
| 156 | /// "", | ||
| 157 | /// "Is this OK for you?", | ||
| 158 | /// canceled, // return value about cancel button | ||
| 159 | /// "Not really", // No label, is optional and if empty "No" | ||
| 160 | /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" | ||
| 161 | /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", | ||
| 162 | /// ret ? "yes" : "no", | ||
| 163 | /// canceled ? "canceled" : "not canceled"); | ||
| 164 | /// ~~~~~~~~~~~~~ | ||
| 165 | /// | ||
| 166 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, | ||
| 167 | const std::string& line0, | ||
| 168 | const std::string& line1, | ||
| 169 | const std::string& line2, | ||
| 170 | bool& canceled, | ||
| 171 | const std::string& noLabel = "", | ||
| 172 | const std::string& yesLabel = "") | ||
| 173 | { | ||
| 174 | using namespace ::kodi::addon; | ||
| 175 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo | ||
| 176 | ->show_and_get_input_line_button_text( | ||
| 177 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), line0.c_str(), line1.c_str(), | ||
| 178 | line2.c_str(), &canceled, noLabel.c_str(), yesLabel.c_str()); | ||
| 179 | } | ||
| 180 | //------------------------------------------------------------------------------ | ||
| 181 | }; // namespace YesNo | ||
| 182 | /// @} | ||
| 183 | |||
| 184 | } /* namespace dialogs */ | ||
| 185 | } /* namespace gui */ | ||
| 186 | } /* namespace kodi */ | ||
| 187 | |||
| 188 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/CMakeLists.txt index a9ab70c..844902d 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/CMakeLists.txt +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/CMakeLists.txt | |||
| @@ -3,5 +3,5 @@ set(HEADERS GL.h | |||
| 3 | Shader.h) | 3 | Shader.h) |
| 4 | 4 | ||
| 5 | if(NOT ENABLE_STATIC_LIBS) | 5 | if(NOT ENABLE_STATIC_LIBS) |
| 6 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_gui_gl) | 6 | core_add_library(addons_kodi-dev-kit_include_kodi_gui_gl) |
| 7 | endif() | 7 | endif() |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GL.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h index 943c7d0..16d43e3 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GL.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h | |||
| @@ -8,28 +8,25 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifdef __cplusplus | ||
| 12 | |||
| 11 | //============================================================================== | 13 | //============================================================================== |
| 12 | /// | 14 | /// @defgroup cpp_kodi_gui_helpers_gl OpenGL helpers |
| 13 | /// \defgroup cpp_kodi_gui_gl OpenGL helpers | 15 | /// @ingroup cpp_kodi_gui_helpers |
| 14 | /// \ingroup cpp_kodi_gui | 16 | /// @brief **Auxiliary functions for Open GL**\n |
| 15 | /// \brief Auxiliary functions for Open GL | ||
| 16 | /// | ||
| 17 | /// This group includes help for definitions, functions, and classes for | 17 | /// This group includes help for definitions, functions, and classes for |
| 18 | /// OpenGL. | 18 | /// OpenGL. |
| 19 | /// | 19 | /// |
| 20 | /// To use OpenGL for your system, add the \ref GL.h "#include <kodi/gui/gl/GL.h>". | 20 | /// To use OpenGL for your system, add the @ref GL.h "#include <kodi/gui/gl/GL.h>". |
| 21 | /// | ||
| 22 | /// | 21 | /// |
| 23 | ///----------------------------------------------------------------------------- | 22 | /// The @ref HAS_GL is declared if Open GL is required and @ref HAS_GLES if Open GL |
| 24 | /// | ||
| 25 | /// The \ref HAS_GL is declared if Open GL is required and \ref HAS_GLES if Open GL | ||
| 26 | /// Embedded Systems (ES) is required, with ES the version is additionally given | 23 | /// Embedded Systems (ES) is required, with ES the version is additionally given |
| 27 | /// in the definition, this can be "2" or "3". | 24 | /// in the definition, this can be "2" or "3". |
| 28 | /// | 25 | /// |
| 29 | /// | 26 | /// |
| 30 | ///----------------------------------------------------------------------------- | 27 | ///----------------------------------------------------------------------------- |
| 31 | /// | 28 | /// |
| 32 | /// Following \ref GL_TYPE_STRING define can be used, for example, to manage | 29 | /// Following @ref GL_TYPE_STRING define can be used, for example, to manage |
| 33 | /// different folders for GL and GLES and make the selection easier. | 30 | /// different folders for GL and GLES and make the selection easier. |
| 34 | /// This are on OpenGL <b>"GL"</b> and on Open GL|ES <b>"GLES"</b>. | 31 | /// This are on OpenGL <b>"GL"</b> and on Open GL|ES <b>"GLES"</b>. |
| 35 | /// | 32 | /// |
| @@ -41,7 +38,7 @@ | |||
| 41 | /// | 38 | /// |
| 42 | ///---------------------------------------------------------------------------- | 39 | ///---------------------------------------------------------------------------- |
| 43 | /// | 40 | /// |
| 44 | /// In addition, \ref BUFFER_OFFSET is declared in it which can be used to give an | 41 | /// In addition, @ref BUFFER_OFFSET is declared in it which can be used to give an |
| 45 | /// offset on the array to GL. | 42 | /// offset on the array to GL. |
| 46 | /// | 43 | /// |
| 47 | /// **Example:** | 44 | /// **Example:** |
| @@ -63,49 +60,53 @@ | |||
| 63 | /// ~~~~~~~~~~~~~~~~~ | 60 | /// ~~~~~~~~~~~~~~~~~ |
| 64 | 61 | ||
| 65 | #if HAS_GL | 62 | #if HAS_GL |
| 66 | #define GL_TYPE_STRING "GL" | 63 | #define GL_TYPE_STRING "GL" |
| 67 | // always define GL_GLEXT_PROTOTYPES before include gl headers | 64 | // always define GL_GLEXT_PROTOTYPES before include gl headers |
| 68 | #if !defined(GL_GLEXT_PROTOTYPES) | 65 | #if !defined(GL_GLEXT_PROTOTYPES) |
| 69 | #define GL_GLEXT_PROTOTYPES | 66 | #define GL_GLEXT_PROTOTYPES |
| 70 | #endif | 67 | #endif |
| 71 | #if defined(TARGET_LINUX) | 68 | #if defined(TARGET_LINUX) |
| 72 | #include <GL/gl.h> | 69 | #include <GL/gl.h> |
| 73 | #include <GL/glext.h> | 70 | #include <GL/glext.h> |
| 74 | #elif defined(TARGET_FREEBSD) | 71 | #elif defined(TARGET_FREEBSD) |
| 75 | #include <GL/gl.h> | 72 | #include <GL/gl.h> |
| 76 | #elif defined(TARGET_DARWIN) | 73 | #elif defined(TARGET_DARWIN) |
| 77 | #include <OpenGL/gl3.h> | 74 | #include <OpenGL/gl3.h> |
| 78 | #include <OpenGL/gl3ext.h> | 75 | #include <OpenGL/gl3ext.h> |
| 79 | #elif defined(WIN32) | 76 | #elif defined(WIN32) |
| 80 | #error Use of GL under Windows is not possible | 77 | #error Use of GL under Windows is not possible |
| 81 | #endif | 78 | #endif |
| 82 | #elif HAS_GLES >= 2 | 79 | #elif HAS_GLES >= 2 |
| 83 | #define GL_TYPE_STRING "GLES" | 80 | #define GL_TYPE_STRING "GLES" |
| 84 | #if defined(WIN32) | 81 | #if defined(WIN32) |
| 85 | #if defined(HAS_ANGLE) | 82 | #if defined(HAS_ANGLE) |
| 86 | #include <angle_gl.h> | 83 | #include <angle_gl.h> |
| 87 | #else | 84 | #else |
| 88 | #error Use of GLES only be available under Windows by the use of angle | 85 | #error Use of GLES only be available under Windows by the use of angle |
| 89 | #endif | 86 | #endif |
| 90 | #elif defined(TARGET_DARWIN) | 87 | #elif defined(TARGET_DARWIN) |
| 91 | #if HAS_GLES == 3 | 88 | #if HAS_GLES == 3 |
| 92 | #include <OpenGLES/ES3/gl.h> | 89 | #include <OpenGLES/ES3/gl.h> |
| 93 | #include <OpenGLES/ES3/glext.h> | 90 | #include <OpenGLES/ES3/glext.h> |
| 94 | #else | 91 | #else |
| 95 | #include <OpenGLES/ES2/gl.h> | 92 | #include <OpenGLES/ES2/gl.h> |
| 96 | #include <OpenGLES/ES2/glext.h> | 93 | #include <OpenGLES/ES2/glext.h> |
| 97 | #endif | 94 | #endif |
| 98 | #else | 95 | #else |
| 99 | #if HAS_GLES == 3 | 96 | #if HAS_GLES == 3 |
| 100 | #include <GLES3/gl3.h> | 97 | #include <GLES3/gl3.h> |
| 101 | #include <GLES3/gl3ext.h> | 98 | #include <GLES3/gl3ext.h> |
| 102 | #else | 99 | #else |
| 103 | #include <GLES2/gl2.h> | 100 | #include <GLES2/gl2.h> |
| 104 | #include <GLES2/gl2ext.h> | 101 | #include <GLES2/gl2ext.h> |
| 105 | #endif | 102 | #endif |
| 106 | #endif | 103 | #endif |
| 107 | #endif | 104 | #endif |
| 108 | 105 | ||
| 109 | #ifndef BUFFER_OFFSET | 106 | #ifndef BUFFER_OFFSET |
| 110 | #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) | 107 | /// @ingroup cpp_kodi_gui_helpers_gl |
| 108 | /// @brief To give a offset number as pointer value. | ||
| 109 | #define BUFFER_OFFSET(i) ((char*)nullptr + (i)) | ||
| 111 | #endif | 110 | #endif |
| 111 | |||
| 112 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GLonDX.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GLonDX.h index 7a6a0a1..4dd97af 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GLonDX.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GLonDX.h | |||
| @@ -8,16 +8,18 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifdef __cplusplus | ||
| 12 | |||
| 13 | #include <EGL/egl.h> | ||
| 14 | #include <EGL/eglext.h> | ||
| 11 | #include <angle_gl.h> | 15 | #include <angle_gl.h> |
| 12 | #include <d3d11.h> | 16 | #include <d3d11.h> |
| 13 | #include <d3dcompiler.h> | 17 | #include <d3dcompiler.h> |
| 14 | #include <EGL/egl.h> | ||
| 15 | #include <EGL/eglext.h> | ||
| 16 | #include <kodi/AddonBase.h> | 18 | #include <kodi/AddonBase.h> |
| 17 | #include <kodi/gui/General.h> | 19 | #include <kodi/gui/General.h> |
| 18 | #include <wrl/client.h> | 20 | #include <wrl/client.h> |
| 19 | 21 | ||
| 20 | #pragma comment( lib, "d3dcompiler.lib" ) | 22 | #pragma comment(lib, "d3dcompiler.lib") |
| 21 | #ifndef GL_CLIENT_VERSION | 23 | #ifndef GL_CLIENT_VERSION |
| 22 | #define GL_CLIENT_VERSION 3 | 24 | #define GL_CLIENT_VERSION 3 |
| 23 | #endif | 25 | #endif |
| @@ -32,33 +34,41 @@ namespace gl | |||
| 32 | class ATTRIBUTE_HIDDEN CGLonDX : public kodi::gui::IRenderHelper | 34 | class ATTRIBUTE_HIDDEN CGLonDX : public kodi::gui::IRenderHelper |
| 33 | { | 35 | { |
| 34 | public: | 36 | public: |
| 35 | explicit CGLonDX() : m_pContext(reinterpret_cast<ID3D11DeviceContext*>(kodi::gui::GetHWContext())) {} | 37 | explicit CGLonDX() : m_pContext(reinterpret_cast<ID3D11DeviceContext*>(kodi::gui::GetHWContext())) |
| 38 | { | ||
| 39 | } | ||
| 36 | ~CGLonDX() override { destruct(); } | 40 | ~CGLonDX() override { destruct(); } |
| 37 | 41 | ||
| 38 | bool Init() override | 42 | bool Init() override |
| 39 | { | 43 | { |
| 40 | EGLint egl_display_attrs[] = | 44 | EGLint egl_display_attrs[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE, |
| 41 | { | 45 | EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, |
| 42 | EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, | 46 | EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, |
| 43 | EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE, | 47 | EGL_DONT_CARE, |
| 44 | EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE, | 48 | EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, |
| 45 | EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE, EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE, | 49 | EGL_DONT_CARE, |
| 46 | EGL_NONE | 50 | EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE, |
| 47 | }; | 51 | EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE, |
| 48 | EGLint egl_config_attrs[] = | 52 | EGL_NONE}; |
| 49 | { | 53 | EGLint egl_config_attrs[] = {EGL_RED_SIZE, |
| 50 | EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, | 54 | 8, |
| 51 | EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE, | 55 | EGL_GREEN_SIZE, |
| 52 | EGL_RENDERABLE_TYPE, GL_CLIENT_VERSION == 3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, | 56 | 8, |
| 53 | EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, | 57 | EGL_BLUE_SIZE, |
| 54 | EGL_NONE | 58 | 8, |
| 55 | }; | 59 | EGL_ALPHA_SIZE, |
| 56 | EGLint egl_context_attrs[] = | 60 | 8, |
| 57 | { | 61 | EGL_BIND_TO_TEXTURE_RGBA, |
| 58 | EGL_CONTEXT_CLIENT_VERSION, GL_CLIENT_VERSION, EGL_NONE | 62 | EGL_TRUE, |
| 59 | }; | 63 | EGL_RENDERABLE_TYPE, |
| 60 | 64 | GL_CLIENT_VERSION == 3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, | |
| 61 | m_eglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, egl_display_attrs); | 65 | EGL_SURFACE_TYPE, |
| 66 | EGL_PBUFFER_BIT, | ||
| 67 | EGL_NONE}; | ||
| 68 | EGLint egl_context_attrs[] = {EGL_CONTEXT_CLIENT_VERSION, GL_CLIENT_VERSION, EGL_NONE}; | ||
| 69 | |||
| 70 | m_eglDisplay = | ||
| 71 | eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, egl_display_attrs); | ||
| 62 | if (m_eglDisplay == EGL_NO_DISPLAY) | 72 | if (m_eglDisplay == EGL_NO_DISPLAY) |
| 63 | { | 73 | { |
| 64 | Log(ADDON_LOG_ERROR, "GLonDX: unable to get EGL display (%s)", eglGetErrorString()); | 74 | Log(ADDON_LOG_ERROR, "GLonDX: unable to get EGL display (%s)", eglGetErrorString()); |
| @@ -72,7 +82,8 @@ public: | |||
| 72 | } | 82 | } |
| 73 | 83 | ||
| 74 | EGLint numConfigs = 0; | 84 | EGLint numConfigs = 0; |
| 75 | if (eglChooseConfig(m_eglDisplay, egl_config_attrs, &m_eglConfig, 1, &numConfigs) != EGL_TRUE || numConfigs == 0) | 85 | if (eglChooseConfig(m_eglDisplay, egl_config_attrs, &m_eglConfig, 1, &numConfigs) != EGL_TRUE || |
| 86 | numConfigs == 0) | ||
| 76 | { | 87 | { |
| 77 | Log(ADDON_LOG_ERROR, "GLonDX: unable to get EGL config (%s)", eglGetErrorString()); | 88 | Log(ADDON_LOG_ERROR, "GLonDX: unable to get EGL config (%s)", eglGetErrorString()); |
| 78 | return false; | 89 | return false; |
| @@ -165,7 +176,7 @@ private: | |||
| 165 | Microsoft::WRL::ComPtr<ID3D11Resource> pRTResource; | 176 | Microsoft::WRL::ComPtr<ID3D11Resource> pRTResource; |
| 166 | Microsoft::WRL::ComPtr<ID3D11Texture2D> pRTTexture; | 177 | Microsoft::WRL::ComPtr<ID3D11Texture2D> pRTTexture; |
| 167 | Microsoft::WRL::ComPtr<ID3D11Texture2D> pOffScreenTexture; | 178 | Microsoft::WRL::ComPtr<ID3D11Texture2D> pOffScreenTexture; |
| 168 | Microsoft::WRL::ComPtr<IDXGIResource> dxgiResource; | 179 | Microsoft::WRL::ComPtr<IDXGIResource> dxgiResource; |
| 169 | 180 | ||
| 170 | m_pContext->GetDevice(&pDevice); | 181 | m_pContext->GetDevice(&pDevice); |
| 171 | m_pContext->OMGetRenderTargets(1, &pRTView, nullptr); | 182 | m_pContext->OMGetRenderTargets(1, &pRTView, nullptr); |
| @@ -187,7 +198,8 @@ private: | |||
| 187 | return false; | 198 | return false; |
| 188 | } | 199 | } |
| 189 | 200 | ||
| 190 | CD3D11_SHADER_RESOURCE_VIEW_DESC srvDesc(pOffScreenTexture.Get(), D3D11_SRV_DIMENSION_TEXTURE2D); | 201 | CD3D11_SHADER_RESOURCE_VIEW_DESC srvDesc(pOffScreenTexture.Get(), |
| 202 | D3D11_SRV_DIMENSION_TEXTURE2D); | ||
| 191 | if (FAILED(pDevice->CreateShaderResourceView(pOffScreenTexture.Get(), &srvDesc, &m_pSRView))) | 203 | if (FAILED(pDevice->CreateShaderResourceView(pOffScreenTexture.Get(), &srvDesc, &m_pSRView))) |
| 192 | { | 204 | { |
| 193 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create shader view"); | 205 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create shader view"); |
| @@ -215,18 +227,19 @@ private: | |||
| 215 | } | 227 | } |
| 216 | 228 | ||
| 217 | // create EGL buffer from D3D shared texture | 229 | // create EGL buffer from D3D shared texture |
| 218 | EGLint egl_buffer_attrs[] = | 230 | EGLint egl_buffer_attrs[] = {EGL_WIDTH, |
| 219 | { | 231 | static_cast<EGLint>(texDesc.Width), |
| 220 | EGL_WIDTH, static_cast<EGLint>(texDesc.Width), | 232 | EGL_HEIGHT, |
| 221 | EGL_HEIGHT, static_cast<EGLint>(texDesc.Height), | 233 | static_cast<EGLint>(texDesc.Height), |
| 222 | EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, | 234 | EGL_TEXTURE_TARGET, |
| 223 | EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, | 235 | EGL_TEXTURE_2D, |
| 224 | EGL_NONE | 236 | EGL_TEXTURE_FORMAT, |
| 225 | }; | 237 | EGL_TEXTURE_RGBA, |
| 226 | 238 | EGL_NONE}; | |
| 227 | m_eglBuffer = eglCreatePbufferFromClientBuffer(m_eglDisplay, | 239 | |
| 228 | EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, | 240 | m_eglBuffer = |
| 229 | sharedHandle, m_eglConfig, egl_buffer_attrs); | 241 | eglCreatePbufferFromClientBuffer(m_eglDisplay, EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, |
| 242 | sharedHandle, m_eglConfig, egl_buffer_attrs); | ||
| 230 | 243 | ||
| 231 | if (m_eglBuffer == EGL_NO_SURFACE) | 244 | if (m_eglBuffer == EGL_NO_SURFACE) |
| 232 | { | 245 | { |
| @@ -236,13 +249,15 @@ private: | |||
| 236 | return true; | 249 | return true; |
| 237 | } | 250 | } |
| 238 | 251 | ||
| 239 | HRESULT d3dCreateShader(ShaderType shaderType, const std::string& source, IUnknown** ppShader) const | 252 | HRESULT d3dCreateShader(ShaderType shaderType, |
| 253 | const std::string& source, | ||
| 254 | IUnknown** ppShader) const | ||
| 240 | { | 255 | { |
| 241 | Microsoft::WRL::ComPtr<ID3DBlob> pBlob; | 256 | Microsoft::WRL::ComPtr<ID3DBlob> pBlob; |
| 242 | Microsoft::WRL::ComPtr<ID3DBlob> pErrors; | 257 | Microsoft::WRL::ComPtr<ID3DBlob> pErrors; |
| 243 | 258 | ||
| 244 | auto hr = D3DCompile(source.c_str(), source.length(), nullptr, nullptr, nullptr, "main", | 259 | auto hr = D3DCompile(source.c_str(), source.length(), nullptr, nullptr, nullptr, "main", |
| 245 | shaderType == PIXEL_SHADER ? "ps_4_0" : "vs_4_0", 0, 0, &pBlob, &pErrors); | 260 | shaderType == PIXEL_SHADER ? "ps_4_0" : "vs_4_0", 0, 0, &pBlob, &pErrors); |
| 246 | 261 | ||
| 247 | if (SUCCEEDED(hr)) | 262 | if (SUCCEEDED(hr)) |
| 248 | { | 263 | { |
| @@ -252,18 +267,18 @@ private: | |||
| 252 | if (shaderType == PIXEL_SHADER) | 267 | if (shaderType == PIXEL_SHADER) |
| 253 | { | 268 | { |
| 254 | hr = pDevice->CreatePixelShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), nullptr, | 269 | hr = pDevice->CreatePixelShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), nullptr, |
| 255 | reinterpret_cast<ID3D11PixelShader**>(ppShader)); | 270 | reinterpret_cast<ID3D11PixelShader**>(ppShader)); |
| 256 | } | 271 | } |
| 257 | else | 272 | else |
| 258 | { | 273 | { |
| 259 | hr = pDevice->CreateVertexShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), nullptr, | 274 | hr = pDevice->CreateVertexShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), nullptr, |
| 260 | reinterpret_cast<ID3D11VertexShader**>(ppShader)); | 275 | reinterpret_cast<ID3D11VertexShader**>(ppShader)); |
| 261 | } | 276 | } |
| 262 | 277 | ||
| 263 | if (FAILED(hr)) | 278 | if (FAILED(hr)) |
| 264 | { | 279 | { |
| 265 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create %s shader", | 280 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create %s shader", |
| 266 | shaderType == PIXEL_SHADER ? "pixel" : "vertex"); | 281 | shaderType == PIXEL_SHADER ? "pixel" : "vertex"); |
| 267 | } | 282 | } |
| 268 | } | 283 | } |
| 269 | else | 284 | else |
| @@ -275,7 +290,9 @@ private: | |||
| 275 | 290 | ||
| 276 | static const char* eglGetErrorString() | 291 | static const char* eglGetErrorString() |
| 277 | { | 292 | { |
| 278 | #define CASE_STR( value ) case value: return #value | 293 | #define CASE_STR(value) \ |
| 294 | case value: \ | ||
| 295 | return #value | ||
| 279 | switch (eglGetError()) | 296 | switch (eglGetError()) |
| 280 | { | 297 | { |
| 281 | CASE_STR(EGL_SUCCESS); | 298 | CASE_STR(EGL_SUCCESS); |
| @@ -293,8 +310,8 @@ private: | |||
| 293 | CASE_STR(EGL_BAD_NATIVE_PIXMAP); | 310 | CASE_STR(EGL_BAD_NATIVE_PIXMAP); |
| 294 | CASE_STR(EGL_BAD_NATIVE_WINDOW); | 311 | CASE_STR(EGL_BAD_NATIVE_WINDOW); |
| 295 | CASE_STR(EGL_CONTEXT_LOST); | 312 | CASE_STR(EGL_CONTEXT_LOST); |
| 296 | default: | 313 | default: |
| 297 | return "Unknown"; | 314 | return "Unknown"; |
| 298 | } | 315 | } |
| 299 | #undef CASE_STR | 316 | #undef CASE_STR |
| 300 | } | 317 | } |
| @@ -338,9 +355,10 @@ private: | |||
| 338 | Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pPShader = nullptr; | 355 | Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pPShader = nullptr; |
| 339 | 356 | ||
| 340 | #define TO_STRING(...) #__VA_ARGS__ | 357 | #define TO_STRING(...) #__VA_ARGS__ |
| 341 | std::string vs_out_shader_text = TO_STRING( | 358 | std::string vs_out_shader_text = TO_STRING(void main(uint id |
| 342 | void main(uint id : SV_VertexId, out float2 tex : TEXCOORD0, out float4 pos : SV_POSITION) | 359 | : SV_VertexId, out float2 tex |
| 343 | { | 360 | : TEXCOORD0, out float4 pos |
| 361 | : SV_POSITION) { | ||
| 344 | tex = float2(id % 2, (id % 4) >> 1); | 362 | tex = float2(id % 2, (id % 4) >> 1); |
| 345 | pos = float4((tex.x - 0.5f) * 2, -(tex.y - 0.5f) * 2, 0, 1); | 363 | pos = float4((tex.x - 0.5f) * 2, -(tex.y - 0.5f) * 2, 0, 1); |
| 346 | }); | 364 | }); |
| @@ -367,3 +385,5 @@ private: | |||
| 367 | using CRenderHelper = gl::CGLonDX; | 385 | using CRenderHelper = gl::CGLonDX; |
| 368 | } /* namespace gui */ | 386 | } /* namespace gui */ |
| 369 | } /* namespace kodi */ | 387 | } /* namespace kodi */ |
| 388 | |||
| 389 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/Shader.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/Shader.h index 209f274..bf6d48c 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/Shader.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/Shader.h | |||
| @@ -10,9 +10,11 @@ | |||
| 10 | 10 | ||
| 11 | #include "GL.h" | 11 | #include "GL.h" |
| 12 | 12 | ||
| 13 | #ifdef __cplusplus | ||
| 14 | |||
| 13 | #include <stdio.h> | 15 | #include <stdio.h> |
| 14 | #include <vector> | ||
| 15 | #include <string> | 16 | #include <string> |
| 17 | #include <vector> | ||
| 16 | 18 | ||
| 17 | #include <kodi/AddonBase.h> | 19 | #include <kodi/AddonBase.h> |
| 18 | #include <kodi/Filesystem.h> | 20 | #include <kodi/Filesystem.h> |
| @@ -34,8 +36,7 @@ class ATTRIBUTE_HIDDEN CShader | |||
| 34 | public: | 36 | public: |
| 35 | CShader() = default; | 37 | CShader() = default; |
| 36 | virtual ~CShader() = default; | 38 | virtual ~CShader() = default; |
| 37 | virtual bool Compile(const std::string& extraBegin = "", | 39 | virtual bool Compile(const std::string& extraBegin = "", const std::string& extraEnd = "") = 0; |
| 38 | const std::string& extraEnd = "") = 0; | ||
| 39 | virtual void Free() = 0; | 40 | virtual void Free() = 0; |
| 40 | virtual GLuint Handle() = 0; | 41 | virtual GLuint Handle() = 0; |
| 41 | 42 | ||
| @@ -46,7 +47,8 @@ public: | |||
| 46 | kodi::vfs::CFile source; | 47 | kodi::vfs::CFile source; |
| 47 | if (!source.OpenFile(file)) | 48 | if (!source.OpenFile(file)) |
| 48 | { | 49 | { |
| 49 | kodi::Log(ADDON_LOG_ERROR, "CShader::%s: Failed to open file '%s'", __FUNCTION__, file.c_str()); | 50 | kodi::Log(ADDON_LOG_ERROR, "CShader::%s: Failed to open file '%s'", __FUNCTION__, |
| 51 | file.c_str()); | ||
| 50 | return false; | 52 | return false; |
| 51 | } | 53 | } |
| 52 | size_t len = source.Read(buffer, sizeof(buffer)); | 54 | size_t len = source.Read(buffer, sizeof(buffer)); |
| @@ -80,8 +82,7 @@ public: | |||
| 80 | m_vertexShader = 0; | 82 | m_vertexShader = 0; |
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | bool Compile(const std::string& extraBegin = "", | 85 | bool Compile(const std::string& extraBegin = "", const std::string& extraEnd = "") override |
| 84 | const std::string& extraEnd = "") override | ||
| 85 | { | 86 | { |
| 86 | GLint params[4]; | 87 | GLint params[4]; |
| 87 | 88 | ||
| @@ -90,7 +91,7 @@ public: | |||
| 90 | m_vertexShader = glCreateShader(GL_VERTEX_SHADER); | 91 | m_vertexShader = glCreateShader(GL_VERTEX_SHADER); |
| 91 | 92 | ||
| 92 | GLsizei count = 0; | 93 | GLsizei count = 0; |
| 93 | const char *sources[3]; | 94 | const char* sources[3]; |
| 94 | if (!extraBegin.empty()) | 95 | if (!extraBegin.empty()) |
| 95 | sources[count++] = extraBegin.c_str(); | 96 | sources[count++] = extraBegin.c_str(); |
| 96 | if (!m_source.empty()) | 97 | if (!m_source.empty()) |
| @@ -141,8 +142,7 @@ public: | |||
| 141 | m_pixelShader = 0; | 142 | m_pixelShader = 0; |
| 142 | } | 143 | } |
| 143 | 144 | ||
| 144 | bool Compile(const std::string& extraBegin = "", | 145 | bool Compile(const std::string& extraBegin = "", const std::string& extraEnd = "") override |
| 145 | const std::string& extraEnd = "") override | ||
| 146 | { | 146 | { |
| 147 | GLint params[4]; | 147 | GLint params[4]; |
| 148 | 148 | ||
| @@ -151,7 +151,7 @@ public: | |||
| 151 | m_pixelShader = glCreateShader(GL_FRAGMENT_SHADER); | 151 | m_pixelShader = glCreateShader(GL_FRAGMENT_SHADER); |
| 152 | 152 | ||
| 153 | GLsizei count = 0; | 153 | GLsizei count = 0; |
| 154 | const char *sources[3]; | 154 | const char* sources[3]; |
| 155 | if (!extraBegin.empty()) | 155 | if (!extraBegin.empty()) |
| 156 | sources[count++] = extraBegin.c_str(); | 156 | sources[count++] = extraBegin.c_str(); |
| 157 | if (!m_source.empty()) | 157 | if (!m_source.empty()) |
| @@ -189,16 +189,14 @@ protected: | |||
| 189 | //------------------------------------------------------------------------ | 189 | //------------------------------------------------------------------------ |
| 190 | 190 | ||
| 191 | //============================================================================ | 191 | //============================================================================ |
| 192 | /// | 192 | /// @defgroup cpp_kodi_gui_helpers_gl_CShaderProgram GL Shader Program |
| 193 | /// \defgroup cpp_kodi_gui_gl_CShaderProgram GL Shader Program | 193 | /// @ingroup cpp_kodi_gui_helpers_gl |
| 194 | /// \ingroup cpp_kodi_gui_gl | 194 | /// @brief @cpp_class{ kodi::gui::gl::CShaderProgram } |
| 195 | /// @brief \cpp_class{ kodi::gui::gl::CShaderProgram } | 195 | /// **Class to manage an OpenGL shader program**\n |
| 196 | /// **Class to manage an OpenGL shader program** | ||
| 197 | /// | ||
| 198 | /// With this class the used GL shader code can be defined on the GPU and | 196 | /// With this class the used GL shader code can be defined on the GPU and |
| 199 | /// its variables can be managed between CPU and GPU. | 197 | /// its variables can be managed between CPU and GPU. |
| 200 | /// | 198 | /// |
| 201 | /// It has the header \ref Shader.h "#include <kodi/gui/gl/Shader.h>" | 199 | /// It has the header @ref Shader.h "#include <kodi/gui/gl/Shader.h>" |
| 202 | /// be included to enjoy it. | 200 | /// be included to enjoy it. |
| 203 | /// | 201 | /// |
| 204 | /// ---------------------------------------------------------------------------- | 202 | /// ---------------------------------------------------------------------------- |
| @@ -275,58 +273,45 @@ protected: | |||
| 275 | /// ADDONCREATOR(CExample); | 273 | /// ADDONCREATOR(CExample); |
| 276 | /// ~~~~~~~~~~~~~ | 274 | /// ~~~~~~~~~~~~~ |
| 277 | /// | 275 | /// |
| 278 | |||
| 279 | //======================================================================== | ||
| 280 | /// CShaderProgram | ||
| 281 | class ATTRIBUTE_HIDDEN CShaderProgram | 276 | class ATTRIBUTE_HIDDEN CShaderProgram |
| 282 | { | 277 | { |
| 283 | public: | 278 | public: |
| 284 | //========================================================================== | 279 | //========================================================================== |
| 280 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram | ||
| 281 | /// @brief Construct a new shader. | ||
| 285 | /// | 282 | /// |
| 286 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | 283 | /// Load must be done later with @ref LoadShaderFiles. |
| 287 | /// @brief Construct a new shader | ||
| 288 | /// | ||
| 289 | /// Load must be done later with \ref LoadShaderFiles. | ||
| 290 | /// | 284 | /// |
| 291 | CShaderProgram() = default; | 285 | CShaderProgram() = default; |
| 292 | //-------------------------------------------------------------------------- | 286 | //-------------------------------------------------------------------------- |
| 293 | 287 | ||
| 294 | //========================================================================== | 288 | //========================================================================== |
| 295 | /// | 289 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram |
| 296 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | 290 | /// @brief Construct a new shader and load defined shader files. |
| 297 | /// @brief Construct a new shader and load defined shader files | ||
| 298 | /// | 291 | /// |
| 299 | /// @param[in] vert Path to used GL vertext shader | 292 | /// @param[in] vert Path to used GL vertext shader |
| 300 | /// @param[in] frag Path to used GL fragment shader | 293 | /// @param[in] frag Path to used GL fragment shader |
| 301 | /// | 294 | /// |
| 302 | CShaderProgram(const std::string& vert, const std::string& frag) | 295 | CShaderProgram(const std::string& vert, const std::string& frag) { LoadShaderFiles(vert, frag); } |
| 303 | { | ||
| 304 | LoadShaderFiles(vert, frag); | ||
| 305 | } | ||
| 306 | //-------------------------------------------------------------------------- | 296 | //-------------------------------------------------------------------------- |
| 307 | 297 | ||
| 308 | //========================================================================== | 298 | //========================================================================== |
| 299 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram | ||
| 300 | /// @brief Destructor. | ||
| 309 | /// | 301 | /// |
| 310 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | 302 | virtual ~CShaderProgram() { ShaderFree(); } |
| 311 | /// @brief Destructor | ||
| 312 | /// | ||
| 313 | virtual ~CShaderProgram() | ||
| 314 | { | ||
| 315 | ShaderFree(); | ||
| 316 | } | ||
| 317 | //-------------------------------------------------------------------------- | 303 | //-------------------------------------------------------------------------- |
| 318 | 304 | ||
| 319 | //========================================================================== | 305 | //========================================================================== |
| 320 | /// | 306 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram |
| 321 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | 307 | /// @brief To load manually the needed shader files. |
| 322 | /// @brief To load manually the needed shader files | ||
| 323 | /// | 308 | /// |
| 324 | /// @param[in] vert Path to used GL vertext shader | 309 | /// @param[in] vert Path to used GL vertext shader |
| 325 | /// @param[in] frag Path to used GL fragment shader | 310 | /// @param[in] frag Path to used GL fragment shader |
| 326 | /// | 311 | /// |
| 327 | /// | 312 | /// |
| 328 | /// @note The use of the files is optional, but it must either be passed over | 313 | /// @note The use of the files is optional, but it must either be passed over |
| 329 | /// here or via \ref CompileAndLink, or both of the source code. | 314 | /// here or via @ref CompileAndLink, or both of the source code. |
| 330 | /// | 315 | /// |
| 331 | bool LoadShaderFiles(const std::string& vert, const std::string& frag) | 316 | bool LoadShaderFiles(const std::string& vert, const std::string& frag) |
| 332 | { | 317 | { |
| @@ -347,9 +332,8 @@ public: | |||
| 347 | //-------------------------------------------------------------------------- | 332 | //-------------------------------------------------------------------------- |
| 348 | 333 | ||
| 349 | //========================================================================== | 334 | //========================================================================== |
| 350 | /// | 335 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram |
| 351 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | 336 | /// @brief To compile and link the shader to the GL interface. |
| 352 | /// @brief To compile and link the shader to the GL interface | ||
| 353 | /// | 337 | /// |
| 354 | /// Optionally, additional source code can be transferred here, or it can be | 338 | /// Optionally, additional source code can be transferred here, or it can be |
| 355 | /// used independently without any files | 339 | /// used independently without any files |
| @@ -421,7 +405,7 @@ public: | |||
| 421 | GLchar log[LOG_SIZE]; | 405 | GLchar log[LOG_SIZE]; |
| 422 | glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log); | 406 | glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log); |
| 423 | kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log); | 407 | kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log); |
| 424 | fprintf(stderr, "CShaderProgram::%s: %s\n", __FUNCTION__, log); | 408 | fprintf(stderr, "CShaderProgram::%s: %s@n", __FUNCTION__, log); |
| 425 | ShaderFree(); | 409 | ShaderFree(); |
| 426 | return false; | 410 | return false; |
| 427 | } | 411 | } |
| @@ -434,14 +418,13 @@ public: | |||
| 434 | //-------------------------------------------------------------------------- | 418 | //-------------------------------------------------------------------------- |
| 435 | 419 | ||
| 436 | //========================================================================== | 420 | //========================================================================== |
| 437 | /// | 421 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram |
| 438 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | 422 | /// @brief To activate the shader and use it on the GPU. |
| 439 | /// @brief To activate the shader and use it on the GPU | ||
| 440 | /// | 423 | /// |
| 441 | /// @return true if enable was successfull done | 424 | /// @return true if enable was successfull done |
| 442 | /// | 425 | /// |
| 443 | /// | 426 | /// |
| 444 | /// @note During this call, the \ref OnEnabled stored in the child is also | 427 | /// @note During this call, the @ref OnEnabled stored in the child is also |
| 445 | /// called | 428 | /// called |
| 446 | /// | 429 | /// |
| 447 | bool EnableShader() | 430 | bool EnableShader() |
| @@ -480,9 +463,8 @@ public: | |||
| 480 | //-------------------------------------------------------------------------- | 463 | //-------------------------------------------------------------------------- |
| 481 | 464 | ||
| 482 | //========================================================================== | 465 | //========================================================================== |
| 483 | /// | 466 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram |
| 484 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | 467 | /// @brief To deactivate the shader use on the GPU. |
| 485 | /// @brief To deactivate the shader use on the GPU | ||
| 486 | /// | 468 | /// |
| 487 | void DisableShader() | 469 | void DisableShader() |
| 488 | { | 470 | { |
| @@ -495,8 +477,7 @@ public: | |||
| 495 | //-------------------------------------------------------------------------- | 477 | //-------------------------------------------------------------------------- |
| 496 | 478 | ||
| 497 | //========================================================================== | 479 | //========================================================================== |
| 498 | /// | 480 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram |
| 499 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 500 | /// @brief Used to check if shader has been loaded before. | 481 | /// @brief Used to check if shader has been loaded before. |
| 501 | /// | 482 | /// |
| 502 | /// @return true if enable was successfull done | 483 | /// @return true if enable was successfull done |
| @@ -507,9 +488,8 @@ public: | |||
| 507 | //-------------------------------------------------------------------------- | 488 | //-------------------------------------------------------------------------- |
| 508 | 489 | ||
| 509 | //========================================================================== | 490 | //========================================================================== |
| 510 | /// | 491 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram |
| 511 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | 492 | /// @brief To get the vertex shader class used by Kodi at the addon. |
| 512 | /// @brief To get the vertex shader class used by Kodi at the addon | ||
| 513 | /// | 493 | /// |
| 514 | /// @return pointer to vertex shader class | 494 | /// @return pointer to vertex shader class |
| 515 | /// | 495 | /// |
| @@ -517,9 +497,8 @@ public: | |||
| 517 | //-------------------------------------------------------------------------- | 497 | //-------------------------------------------------------------------------- |
| 518 | 498 | ||
| 519 | //========================================================================== | 499 | //========================================================================== |
| 520 | /// | 500 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram |
| 521 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | 501 | /// @brief To get the fragment shader class used by Kodi at the addon. |
| 522 | /// @brief To get the fragment shader class used by Kodi at the addon | ||
| 523 | /// | 502 | /// |
| 524 | /// @return pointer to fragment shader class | 503 | /// @return pointer to fragment shader class |
| 525 | /// | 504 | /// |
| @@ -527,9 +506,8 @@ public: | |||
| 527 | //-------------------------------------------------------------------------- | 506 | //-------------------------------------------------------------------------- |
| 528 | 507 | ||
| 529 | //========================================================================== | 508 | //========================================================================== |
| 530 | /// | 509 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram |
| 531 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | 510 | /// @brief Used to get the definition created in the OpenGL itself. |
| 532 | /// @brief Used to get the definition created in the OpenGL itself | ||
| 533 | /// | 511 | /// |
| 534 | /// @return GLuint of GL shader program handler | 512 | /// @return GLuint of GL shader program handler |
| 535 | /// | 513 | /// |
| @@ -537,24 +515,22 @@ public: | |||
| 537 | //-------------------------------------------------------------------------- | 515 | //-------------------------------------------------------------------------- |
| 538 | 516 | ||
| 539 | //========================================================================== | 517 | //========================================================================== |
| 540 | /// | 518 | /// @defgroup cpp_kodi_gui_helpers_gl_CShaderProgram_child Child Functions |
| 541 | /// \defgroup cpp_kodi_gui_gl_CShaderProgram_child Child Functions | 519 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram |
| 542 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | 520 | /// @brief @cpp_class{ kodi::gui::gl::CShaderProgram child functions } |
| 543 | /// @brief \cpp_class{ kodi::gui::gl::CShaderProgram child functions } | ||
| 544 | /// | 521 | /// |
| 545 | /// Functions that are added by parent in the child | 522 | /// Functions that are added by parent in the child |
| 546 | //@{ | 523 | /// @{ |
| 547 | //========================================================================== | 524 | //========================================================================== |
| 548 | /// | 525 | /// |
| 549 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram_child | 526 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram_child |
| 550 | /// @brief Mandatory child function to set the necessary CPU to GPU data | 527 | /// @brief Mandatory child function to set the necessary CPU to GPU data |
| 551 | /// | 528 | /// |
| 552 | virtual void OnCompiledAndLinked() {}; | 529 | virtual void OnCompiledAndLinked(){}; |
| 553 | //-------------------------------------------------------------------------- | 530 | //-------------------------------------------------------------------------- |
| 554 | 531 | ||
| 555 | //========================================================================== | 532 | //========================================================================== |
| 556 | /// | 533 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram_child |
| 557 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram_child | ||
| 558 | /// @brief Optional function to exchange data between CPU and GPU while | 534 | /// @brief Optional function to exchange data between CPU and GPU while |
| 559 | /// activating the shader | 535 | /// activating the shader |
| 560 | /// | 536 | /// |
| @@ -564,13 +540,12 @@ public: | |||
| 564 | //-------------------------------------------------------------------------- | 540 | //-------------------------------------------------------------------------- |
| 565 | 541 | ||
| 566 | //========================================================================== | 542 | //========================================================================== |
| 567 | /// | 543 | /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram_child |
| 568 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram_child | ||
| 569 | /// @brief Optional child function that may have to be performed when | 544 | /// @brief Optional child function that may have to be performed when |
| 570 | /// switching off the shader | 545 | /// switching off the shader |
| 571 | virtual void OnDisabled() {}; | 546 | virtual void OnDisabled(){}; |
| 572 | //-------------------------------------------------------------------------- | 547 | //-------------------------------------------------------------------------- |
| 573 | //@} | 548 | /// @} |
| 574 | 549 | ||
| 575 | private: | 550 | private: |
| 576 | void ShaderFree() | 551 | void ShaderFree() |
| @@ -592,3 +567,5 @@ private: | |||
| 592 | } /* namespace gl */ | 567 | } /* namespace gl */ |
| 593 | } /* namespace gui */ | 568 | } /* namespace gui */ |
| 594 | } /* namespace kodi */ | 569 | } /* namespace kodi */ |
| 570 | |||
| 571 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/input/ActionIDs.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/input/ActionIDs.h new file mode 100644 index 0000000..4c816a4 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/input/ActionIDs.h | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../c-api/gui/input/action_ids.h" | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/input/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/gui/input/CMakeLists.txt new file mode 100644 index 0000000..d576974 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/input/CMakeLists.txt | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | set(HEADERS ActionIDs.h) | ||
| 2 | |||
| 3 | if(NOT ENABLE_STATIC_LIBS) | ||
| 4 | core_add_library(addons_kodi-dev-kit_include_kodi_gui_input) | ||
| 5 | endif() | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/renderHelper.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/renderHelper.h index 2e96d21..dabe101 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/renderHelper.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/renderHelper.h | |||
| @@ -10,6 +10,8 @@ | |||
| 10 | 10 | ||
| 11 | #include "../AddonBase.h" | 11 | #include "../AddonBase.h" |
| 12 | 12 | ||
| 13 | #ifdef __cplusplus | ||
| 14 | |||
| 13 | namespace kodi | 15 | namespace kodi |
| 14 | { | 16 | { |
| 15 | namespace gui | 17 | namespace gui |
| @@ -37,8 +39,8 @@ namespace gui | |||
| 37 | struct ATTRIBUTE_HIDDEN CRenderHelperStub : public IRenderHelper | 39 | struct ATTRIBUTE_HIDDEN CRenderHelperStub : public IRenderHelper |
| 38 | { | 40 | { |
| 39 | bool Init() override { return true; } | 41 | bool Init() override { return true; } |
| 40 | void Begin() override { } | 42 | void Begin() override {} |
| 41 | void End() override { } | 43 | void End() override {} |
| 42 | }; /* class CRenderHelperStub */ | 44 | }; /* class CRenderHelperStub */ |
| 43 | 45 | ||
| 44 | using CRenderHelper = CRenderHelperStub; | 46 | using CRenderHelper = CRenderHelperStub; |
| @@ -76,3 +78,5 @@ inline std::shared_ptr<IRenderHelper> ATTRIBUTE_HIDDEN GetRenderHelper() | |||
| 76 | 78 | ||
| 77 | } /* namespace gui */ | 79 | } /* namespace gui */ |
| 78 | } /* namespace kodi */ | 80 | } /* namespace kodi */ |
| 81 | |||
| 82 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h b/xbmc/addons/kodi-dev-kit/include/kodi/platform/android/System.h index ef2d728..245abd6 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/platform/android/System.h | |||
| @@ -9,44 +9,37 @@ | |||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../../AddonBase.h" | 11 | #include "../../AddonBase.h" |
| 12 | #include "../../c-api/platform/android/system.h" | ||
| 12 | 13 | ||
| 13 | /* | 14 | #ifdef __cplusplus |
| 14 | * For interface between add-on and kodi. | 15 | namespace kodi |
| 15 | * | 16 | { |
| 16 | * This structure defines the addresses of functions stored inside Kodi which | 17 | namespace platform |
| 17 | * are then available for the add-on to call | ||
| 18 | * | ||
| 19 | * All function pointers there are used by the C++ interface functions below. | ||
| 20 | * You find the set of them on xbmc/addons/interfaces/General.cpp | ||
| 21 | * | ||
| 22 | * Note: For add-on development itself this is not needed | ||
| 23 | */ | ||
| 24 | |||
| 25 | static const char* INTERFACE_ANDROID_SYSTEM_NAME = "ANDROID_SYSTEM"; | ||
| 26 | static const char* INTERFACE_ANDROID_SYSTEM_VERSION = "1.0.1"; | ||
| 27 | static const char* INTERFACE_ANDROID_SYSTEM_VERSION_MIN = "1.0.1"; | ||
| 28 | |||
| 29 | struct AddonToKodiFuncTable_android_system | ||
| 30 | { | 18 | { |
| 31 | void* (*get_jni_env)(); | ||
| 32 | int (*get_sdk_version)(); | ||
| 33 | const char *(*get_class_name)(); | ||
| 34 | }; | ||
| 35 | 19 | ||
| 36 | //============================================================================== | 20 | //============================================================================== |
| 21 | /// @defgroup cpp_kodi_platform_CInterfaceAndroidSystem class CInterfaceAndroidSystem | ||
| 22 | /// @ingroup cpp_kodi_platform | ||
| 23 | /// @brief **Android platform specific functions**\n | ||
| 24 | /// C++ class to query Android specific things in Kodi. | ||
| 37 | /// | 25 | /// |
| 38 | /// \defgroup cpp_kodi_platform Interface - kodi::platform | 26 | /// It has the header is @ref System.h "#include <kodi/platform/android/System.h>". |
| 39 | /// \ingroup cpp | ||
| 40 | /// @brief **Android platform specific functions** | ||
| 41 | /// | 27 | /// |
| 42 | /// #include <kodi/platform/android/System.h>" | 28 | /// ---------------------------------------------------------------------------- |
| 29 | /// | ||
| 30 | /// **Example:** | ||
| 31 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 32 | /// #include <kodi/platform/android/System.h> | ||
| 33 | /// | ||
| 34 | /// #if defined(ANDROID) | ||
| 35 | /// kodi::platform::CInterfaceAndroidSystem system; | ||
| 36 | /// if (system.GetSDKVersion() >= 23) | ||
| 37 | /// { | ||
| 38 | /// ... | ||
| 39 | /// } | ||
| 40 | /// #endif | ||
| 41 | /// ~~~~~~~~~~~~~ | ||
| 43 | /// | 42 | /// |
| 44 | //------------------------------------------------------------------------------ | ||
| 45 | |||
| 46 | namespace kodi | ||
| 47 | { | ||
| 48 | namespace platform | ||
| 49 | { | ||
| 50 | class ATTRIBUTE_HIDDEN CInterfaceAndroidSystem | 43 | class ATTRIBUTE_HIDDEN CInterfaceAndroidSystem |
| 51 | { | 44 | { |
| 52 | public: | 45 | public: |
| @@ -55,13 +48,12 @@ public: | |||
| 55 | GetInterface(INTERFACE_ANDROID_SYSTEM_NAME, INTERFACE_ANDROID_SYSTEM_VERSION))){}; | 48 | GetInterface(INTERFACE_ANDROID_SYSTEM_NAME, INTERFACE_ANDROID_SYSTEM_VERSION))){}; |
| 56 | 49 | ||
| 57 | //============================================================================ | 50 | //============================================================================ |
| 51 | /// @ingroup cpp_kodi_platform_CInterfaceAndroidSystem | ||
| 52 | /// @brief Request an JNI env pointer for the calling thread. | ||
| 58 | /// | 53 | /// |
| 59 | /// \ingroup cpp_kodi_platform | ||
| 60 | /// @brief request an JNI env pointer for the calling thread. | ||
| 61 | /// JNI env has to be controlled by kodi because of the underlying | 54 | /// JNI env has to be controlled by kodi because of the underlying |
| 62 | /// threading concep. | 55 | /// threading concep. |
| 63 | /// | 56 | /// |
| 64 | /// @param[in]: | ||
| 65 | /// @return JNI env pointer for the calling thread | 57 | /// @return JNI env pointer for the calling thread |
| 66 | /// | 58 | /// |
| 67 | inline void* GetJNIEnv() | 59 | inline void* GetJNIEnv() |
| @@ -74,11 +66,9 @@ public: | |||
| 74 | //---------------------------------------------------------------------------- | 66 | //---------------------------------------------------------------------------- |
| 75 | 67 | ||
| 76 | //============================================================================ | 68 | //============================================================================ |
| 69 | /// @ingroup cpp_kodi_platform_CInterfaceAndroidSystem | ||
| 70 | /// @brief Request the android sdk version to e.g. initialize <b>`JNIBase`</b>. | ||
| 77 | /// | 71 | /// |
| 78 | /// \ingroup cpp_kodi_platform | ||
| 79 | /// @brief request the android sdk version to e.g. initialize JNIBase. | ||
| 80 | /// | ||
| 81 | /// @param[in]: | ||
| 82 | /// @return Android SDK version | 72 | /// @return Android SDK version |
| 83 | /// | 73 | /// |
| 84 | inline int GetSDKVersion() | 74 | inline int GetSDKVersion() |
| @@ -88,13 +78,12 @@ public: | |||
| 88 | 78 | ||
| 89 | return 0; | 79 | return 0; |
| 90 | } | 80 | } |
| 81 | //---------------------------------------------------------------------------- | ||
| 91 | 82 | ||
| 92 | //============================================================================ | 83 | //============================================================================ |
| 84 | /// @ingroup cpp_kodi_platform_CInterfaceAndroidSystem | ||
| 85 | /// @brief Request the android main class name e.g. <b>`org.xbmc.kodi`</b>. | ||
| 93 | /// | 86 | /// |
| 94 | /// \ingroup cpp_kodi_platform | ||
| 95 | /// @brief request the android main class name e.g. org.xbmc.kodi. | ||
| 96 | /// | ||
| 97 | /// @param[in]: | ||
| 98 | /// @return package class name | 87 | /// @return package class name |
| 99 | /// | 88 | /// |
| 100 | inline std::string GetClassName() | 89 | inline std::string GetClassName() |
| @@ -104,11 +93,13 @@ public: | |||
| 104 | 93 | ||
| 105 | return std::string(); | 94 | return std::string(); |
| 106 | } | 95 | } |
| 96 | //---------------------------------------------------------------------------- | ||
| 107 | 97 | ||
| 108 | private: | 98 | private: |
| 109 | AddonToKodiFuncTable_android_system* m_interface; | 99 | AddonToKodiFuncTable_android_system* m_interface; |
| 110 | }; | 100 | }; |
| 111 | //---------------------------------------------------------------------------- | 101 | //------------------------------------------------------------------------------ |
| 112 | 102 | ||
| 113 | } /* namespace platform */ | 103 | } /* namespace platform */ |
| 114 | } /* namespace kodi */ | 104 | } /* namespace kodi */ |
| 105 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/tools/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/tools/CMakeLists.txt new file mode 100644 index 0000000..16b83cb --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/tools/CMakeLists.txt | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | set(HEADERS DllHelper.h | ||
| 2 | EndTime.h | ||
| 3 | StringUtils.h | ||
| 4 | Thread.h | ||
| 5 | Timer.h) | ||
| 6 | |||
| 7 | if(NOT ENABLE_STATIC_LIBS) | ||
| 8 | core_add_library(addons_kodi-dev-kit_include_kodi_tools) | ||
| 9 | endif() | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/DllHelper.h b/xbmc/addons/kodi-dev-kit/include/kodi/tools/DllHelper.h index 3cc9eea..3cc9eea 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/DllHelper.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/tools/DllHelper.h | |||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/tools/EndTime.h b/xbmc/addons/kodi-dev-kit/include/kodi/tools/EndTime.h new file mode 100644 index 0000000..14983fa --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/tools/EndTime.h | |||
| @@ -0,0 +1,215 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSE.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifdef __cplusplus | ||
| 12 | |||
| 13 | #include <chrono> | ||
| 14 | |||
| 15 | namespace kodi | ||
| 16 | { | ||
| 17 | namespace tools | ||
| 18 | { | ||
| 19 | |||
| 20 | //============================================================================== | ||
| 21 | /// @defgroup cpp_kodi_tools_CEndTime class CEndTime | ||
| 22 | /// @ingroup cpp_kodi_tools | ||
| 23 | /// @brief **Timeout check**\n | ||
| 24 | /// Class which makes it easy to check if a specified amount of time has passed. | ||
| 25 | /// | ||
| 26 | /// This code uses the support of platform-independent chrono system introduced | ||
| 27 | /// with C++11. | ||
| 28 | /// | ||
| 29 | /// | ||
| 30 | /// ---------------------------------------------------------------------------- | ||
| 31 | /// | ||
| 32 | /// **Example:** | ||
| 33 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 34 | /// #include <kodi/tools/EndTime.h> | ||
| 35 | /// | ||
| 36 | /// class ATTRIBUTE_HIDDEN CExample | ||
| 37 | /// { | ||
| 38 | /// public: | ||
| 39 | /// CExample() | ||
| 40 | /// { | ||
| 41 | /// TimerCall(); | ||
| 42 | /// } | ||
| 43 | /// | ||
| 44 | /// void TimerCall() | ||
| 45 | /// { | ||
| 46 | /// fprintf(stderr, "Hello World\n"); | ||
| 47 | /// CEndTime timer(1000); | ||
| 48 | /// | ||
| 49 | /// while (timer.MillisLeft()) | ||
| 50 | /// { | ||
| 51 | /// if (timer.IsTimePast()) | ||
| 52 | /// { | ||
| 53 | /// fprintf(stderr, "We timed out!\n"); | ||
| 54 | /// } | ||
| 55 | /// std::this_thread::sleep_for(std::chrono::milliseconds(10)); | ||
| 56 | /// } | ||
| 57 | /// } | ||
| 58 | /// | ||
| 59 | /// }; | ||
| 60 | /// ~~~~~~~~~~~~~ | ||
| 61 | /// | ||
| 62 | ///@{ | ||
| 63 | class CEndTime | ||
| 64 | { | ||
| 65 | public: | ||
| 66 | //============================================================================ | ||
| 67 | /// @ingroup cpp_kodi_tools_CEndTime | ||
| 68 | /// @brief Class constructor with no time to expiry set | ||
| 69 | /// | ||
| 70 | inline CEndTime() = default; | ||
| 71 | //============================================================================ | ||
| 72 | /// @ingroup cpp_kodi_tools_CEndTime | ||
| 73 | /// @brief Class constructor to set future time when timer has expired | ||
| 74 | /// | ||
| 75 | /// @param[in] millisecondsIntoTheFuture the time in the future we cosider this timer as expired | ||
| 76 | /// | ||
| 77 | inline explicit CEndTime(unsigned int millisecondsIntoTheFuture) | ||
| 78 | : m_startTime(std::chrono::system_clock::now().time_since_epoch()), | ||
| 79 | m_totalWaitTime(std::chrono::milliseconds(millisecondsIntoTheFuture)) | ||
| 80 | { | ||
| 81 | } | ||
| 82 | //---------------------------------------------------------------------------- | ||
| 83 | |||
| 84 | //============================================================================ | ||
| 85 | /// @ingroup cpp_kodi_tools_CEndTime | ||
| 86 | /// @brief Set the time in the future we cosider this timer as expired | ||
| 87 | /// | ||
| 88 | /// @param[in] millisecondsIntoTheFuture the time in the future we cosider this timer as expired | ||
| 89 | /// | ||
| 90 | inline void Set(unsigned int millisecondsIntoTheFuture) | ||
| 91 | { | ||
| 92 | using namespace std::chrono; | ||
| 93 | |||
| 94 | m_startTime = system_clock::now().time_since_epoch(); | ||
| 95 | m_totalWaitTime = milliseconds(millisecondsIntoTheFuture); | ||
| 96 | } | ||
| 97 | //---------------------------------------------------------------------------- | ||
| 98 | |||
| 99 | //============================================================================ | ||
| 100 | /// @ingroup cpp_kodi_tools_CEndTime | ||
| 101 | /// @brief Check if the expiry time has been reached | ||
| 102 | /// | ||
| 103 | /// @return True if the expiry amount of time has past, false otherwise | ||
| 104 | /// | ||
| 105 | inline bool IsTimePast() const | ||
| 106 | { | ||
| 107 | using namespace std::chrono; | ||
| 108 | |||
| 109 | // timer is infinite | ||
| 110 | if (m_totalWaitTime.count() == std::numeric_limits<unsigned int>::max()) | ||
| 111 | return false; | ||
| 112 | |||
| 113 | if (m_totalWaitTime.count() == 0) | ||
| 114 | return true; | ||
| 115 | else | ||
| 116 | return (system_clock::now().time_since_epoch() - m_startTime) >= m_totalWaitTime; | ||
| 117 | } | ||
| 118 | //---------------------------------------------------------------------------- | ||
| 119 | |||
| 120 | //============================================================================ | ||
| 121 | /// @ingroup cpp_kodi_tools_CEndTime | ||
| 122 | /// @brief The amount of time left till this timer expires | ||
| 123 | /// | ||
| 124 | /// @return 0 if the expiry amount of time has past, the numbe rof milliseconds remaining otherwise | ||
| 125 | /// | ||
| 126 | inline unsigned int MillisLeft() const | ||
| 127 | { | ||
| 128 | using namespace std::chrono; | ||
| 129 | |||
| 130 | // timer is infinite | ||
| 131 | if (m_totalWaitTime.count() == std::numeric_limits<unsigned int>::max()) | ||
| 132 | return std::numeric_limits<unsigned int>::max(); | ||
| 133 | |||
| 134 | if (m_totalWaitTime.count() == 0) | ||
| 135 | return 0; | ||
| 136 | |||
| 137 | auto elapsed = system_clock::now().time_since_epoch() - m_startTime; | ||
| 138 | |||
| 139 | auto timeWaitedAlready = duration_cast<milliseconds>(elapsed).count(); | ||
| 140 | |||
| 141 | if (timeWaitedAlready >= m_totalWaitTime.count()) | ||
| 142 | return 0; | ||
| 143 | |||
| 144 | return static_cast<unsigned int>(m_totalWaitTime.count() - timeWaitedAlready); | ||
| 145 | } | ||
| 146 | //---------------------------------------------------------------------------- | ||
| 147 | |||
| 148 | //============================================================================ | ||
| 149 | /// @ingroup cpp_kodi_tools_CEndTime | ||
| 150 | /// @brief Consider this timer expired | ||
| 151 | /// | ||
| 152 | inline void SetExpired() | ||
| 153 | { | ||
| 154 | using namespace std::chrono; | ||
| 155 | m_totalWaitTime = milliseconds(0); | ||
| 156 | } | ||
| 157 | //---------------------------------------------------------------------------- | ||
| 158 | |||
| 159 | //============================================================================ | ||
| 160 | /// @ingroup cpp_kodi_tools_CEndTime | ||
| 161 | /// @brief Set this timer as never expiring | ||
| 162 | /// | ||
| 163 | inline void SetInfinite() | ||
| 164 | { | ||
| 165 | using namespace std::chrono; | ||
| 166 | m_totalWaitTime = milliseconds(std::numeric_limits<unsigned int>::max()); | ||
| 167 | } | ||
| 168 | //---------------------------------------------------------------------------- | ||
| 169 | |||
| 170 | //============================================================================ | ||
| 171 | /// @ingroup cpp_kodi_tools_CEndTime | ||
| 172 | /// @brief Check if the timer has been set to infinite expiry | ||
| 173 | /// | ||
| 174 | /// @return True if the expiry has been set as infinite, false otherwise | ||
| 175 | /// | ||
| 176 | inline bool IsInfinite(void) const | ||
| 177 | { | ||
| 178 | return (m_totalWaitTime.count() == std::numeric_limits<unsigned int>::max()); | ||
| 179 | } | ||
| 180 | //---------------------------------------------------------------------------- | ||
| 181 | |||
| 182 | //============================================================================ | ||
| 183 | /// @ingroup cpp_kodi_tools_CEndTime | ||
| 184 | /// @brief Get the initial timeout value this timer had | ||
| 185 | /// | ||
| 186 | /// @return The initial expiry amount of time this timer had in milliseconds | ||
| 187 | /// | ||
| 188 | inline unsigned int GetInitialTimeoutValue(void) const | ||
| 189 | { | ||
| 190 | auto value = std::chrono::duration_cast<std::chrono::milliseconds>(m_totalWaitTime); | ||
| 191 | return static_cast<unsigned int>(value.count()); | ||
| 192 | } | ||
| 193 | |||
| 194 | //============================================================================ | ||
| 195 | /// @ingroup cpp_kodi_tools_CEndTime | ||
| 196 | /// @brief Get the time this timer started | ||
| 197 | /// | ||
| 198 | /// @return The time this timer started in milliseconds since epoch | ||
| 199 | /// | ||
| 200 | inline uint64_t GetStartTime(void) const | ||
| 201 | { | ||
| 202 | auto value = std::chrono::duration_cast<std::chrono::milliseconds>(m_startTime); | ||
| 203 | return value.count(); | ||
| 204 | } | ||
| 205 | //---------------------------------------------------------------------------- | ||
| 206 | |||
| 207 | private: | ||
| 208 | std::chrono::system_clock::duration m_startTime; | ||
| 209 | std::chrono::system_clock::duration m_totalWaitTime; | ||
| 210 | }; | ||
| 211 | |||
| 212 | } /* namespace tools */ | ||
| 213 | } /* namespace kodi */ | ||
| 214 | |||
| 215 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/tools/StringUtils.h b/xbmc/addons/kodi-dev-kit/include/kodi/tools/StringUtils.h new file mode 100644 index 0000000..977c0e5 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/tools/StringUtils.h | |||
| @@ -0,0 +1,3086 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifdef __cplusplus | ||
| 12 | |||
| 13 | #if !defined(NOMINMAX) | ||
| 14 | #define NOMINMAX | ||
| 15 | #endif | ||
| 16 | |||
| 17 | #include <algorithm> | ||
| 18 | #include <array> | ||
| 19 | #include <cassert> | ||
| 20 | #include <cinttypes> | ||
| 21 | #include <cmath> | ||
| 22 | #include <cstdarg> | ||
| 23 | #include <cstring> | ||
| 24 | #include <iomanip> | ||
| 25 | #include <regex> | ||
| 26 | #include <sstream> | ||
| 27 | #include <string> | ||
| 28 | #include <vector> | ||
| 29 | |||
| 30 | // # of bytes for initial allocation for printf | ||
| 31 | #define FORMAT_BLOCK_SIZE 512 | ||
| 32 | |||
| 33 | // macros for gcc, clang & others | ||
| 34 | #ifndef PARAM1_PRINTF_FORMAT | ||
| 35 | #ifdef __GNUC__ | ||
| 36 | // for use in functions that take printf format string as first parameter and additional printf parameters as second parameter | ||
| 37 | // for example: int myprintf(const char* format, ...) PARAM1_PRINTF_FORMAT; | ||
| 38 | #define PARAM1_PRINTF_FORMAT __attribute__((format(printf, 1, 2))) | ||
| 39 | |||
| 40 | // for use in functions that take printf format string as second parameter and additional printf parameters as third parameter | ||
| 41 | // for example: bool log_string(int logLevel, const char* format, ...) PARAM2_PRINTF_FORMAT; | ||
| 42 | // note: all non-static class member functions take pointer to class object as hidden first parameter | ||
| 43 | #define PARAM2_PRINTF_FORMAT __attribute__((format(printf, 2, 3))) | ||
| 44 | |||
| 45 | // for use in functions that take printf format string as third parameter and additional printf parameters as fourth parameter | ||
| 46 | // note: all non-static class member functions take pointer to class object as hidden first parameter | ||
| 47 | // for example: class A { bool log_string(int logLevel, const char* functionName, const char* format, ...) PARAM3_PRINTF_FORMAT; }; | ||
| 48 | #define PARAM3_PRINTF_FORMAT __attribute__((format(printf, 3, 4))) | ||
| 49 | |||
| 50 | // for use in functions that take printf format string as fourth parameter and additional printf parameters as fith parameter | ||
| 51 | // note: all non-static class member functions take pointer to class object as hidden first parameter | ||
| 52 | // for example: class A { bool log_string(int logLevel, const char* functionName, int component, const char* format, ...) PARAM4_PRINTF_FORMAT; }; | ||
| 53 | #define PARAM4_PRINTF_FORMAT __attribute__((format(printf, 4, 5))) | ||
| 54 | #else // ! __GNUC__ | ||
| 55 | #define PARAM1_PRINTF_FORMAT | ||
| 56 | #define PARAM2_PRINTF_FORMAT | ||
| 57 | #define PARAM3_PRINTF_FORMAT | ||
| 58 | #define PARAM4_PRINTF_FORMAT | ||
| 59 | #endif // ! __GNUC__ | ||
| 60 | #endif // PARAM1_PRINTF_FORMAT | ||
| 61 | |||
| 62 | // macros for VC | ||
| 63 | // VC check parameters only when "Code Analysis" is called | ||
| 64 | #ifndef PRINTF_FORMAT_STRING | ||
| 65 | #ifdef _MSC_VER | ||
| 66 | #include <sal.h> | ||
| 67 | |||
| 68 | // for use in any function that take printf format string and parameters | ||
| 69 | // for example: bool log_string(int logLevel, PRINTF_FORMAT_STRING const char* format, ...); | ||
| 70 | #define PRINTF_FORMAT_STRING _In_z_ _Printf_format_string_ | ||
| 71 | |||
| 72 | // specify that parameter must be zero-terminated string | ||
| 73 | // for example: void SetName(IN_STRING const char* newName); | ||
| 74 | #define IN_STRING _In_z_ | ||
| 75 | |||
| 76 | // specify that parameter must be zero-terminated string or NULL | ||
| 77 | // for example: bool SetAdditionalName(IN_OPT_STRING const char* addName); | ||
| 78 | #define IN_OPT_STRING _In_opt_z_ | ||
| 79 | #else // ! _MSC_VER | ||
| 80 | #define PRINTF_FORMAT_STRING | ||
| 81 | #define IN_STRING | ||
| 82 | #define IN_OPT_STRING | ||
| 83 | #endif // ! _MSC_VER | ||
| 84 | #endif // PRINTF_FORMAT_STRING | ||
| 85 | |||
| 86 | static constexpr wchar_t unicode_lowers[] = { | ||
| 87 | (wchar_t)0x0061, (wchar_t)0x0062, (wchar_t)0x0063, (wchar_t)0x0064, (wchar_t)0x0065, | ||
| 88 | (wchar_t)0x0066, (wchar_t)0x0067, (wchar_t)0x0068, (wchar_t)0x0069, (wchar_t)0x006A, | ||
| 89 | (wchar_t)0x006B, (wchar_t)0x006C, (wchar_t)0x006D, (wchar_t)0x006E, (wchar_t)0x006F, | ||
| 90 | (wchar_t)0x0070, (wchar_t)0x0071, (wchar_t)0x0072, (wchar_t)0x0073, (wchar_t)0x0074, | ||
| 91 | (wchar_t)0x0075, (wchar_t)0x0076, (wchar_t)0x0077, (wchar_t)0x0078, (wchar_t)0x0079, | ||
| 92 | (wchar_t)0x007A, (wchar_t)0x00E0, (wchar_t)0x00E1, (wchar_t)0x00E2, (wchar_t)0x00E3, | ||
| 93 | (wchar_t)0x00E4, (wchar_t)0x00E5, (wchar_t)0x00E6, (wchar_t)0x00E7, (wchar_t)0x00E8, | ||
| 94 | (wchar_t)0x00E9, (wchar_t)0x00EA, (wchar_t)0x00EB, (wchar_t)0x00EC, (wchar_t)0x00ED, | ||
| 95 | (wchar_t)0x00EE, (wchar_t)0x00EF, (wchar_t)0x00F0, (wchar_t)0x00F1, (wchar_t)0x00F2, | ||
| 96 | (wchar_t)0x00F3, (wchar_t)0x00F4, (wchar_t)0x00F5, (wchar_t)0x00F6, (wchar_t)0x00F8, | ||
| 97 | (wchar_t)0x00F9, (wchar_t)0x00FA, (wchar_t)0x00FB, (wchar_t)0x00FC, (wchar_t)0x00FD, | ||
| 98 | (wchar_t)0x00FE, (wchar_t)0x00FF, (wchar_t)0x0101, (wchar_t)0x0103, (wchar_t)0x0105, | ||
| 99 | (wchar_t)0x0107, (wchar_t)0x0109, (wchar_t)0x010B, (wchar_t)0x010D, (wchar_t)0x010F, | ||
| 100 | (wchar_t)0x0111, (wchar_t)0x0113, (wchar_t)0x0115, (wchar_t)0x0117, (wchar_t)0x0119, | ||
| 101 | (wchar_t)0x011B, (wchar_t)0x011D, (wchar_t)0x011F, (wchar_t)0x0121, (wchar_t)0x0123, | ||
| 102 | (wchar_t)0x0125, (wchar_t)0x0127, (wchar_t)0x0129, (wchar_t)0x012B, (wchar_t)0x012D, | ||
| 103 | (wchar_t)0x012F, (wchar_t)0x0131, (wchar_t)0x0133, (wchar_t)0x0135, (wchar_t)0x0137, | ||
| 104 | (wchar_t)0x013A, (wchar_t)0x013C, (wchar_t)0x013E, (wchar_t)0x0140, (wchar_t)0x0142, | ||
| 105 | (wchar_t)0x0144, (wchar_t)0x0146, (wchar_t)0x0148, (wchar_t)0x014B, (wchar_t)0x014D, | ||
| 106 | (wchar_t)0x014F, (wchar_t)0x0151, (wchar_t)0x0153, (wchar_t)0x0155, (wchar_t)0x0157, | ||
| 107 | (wchar_t)0x0159, (wchar_t)0x015B, (wchar_t)0x015D, (wchar_t)0x015F, (wchar_t)0x0161, | ||
| 108 | (wchar_t)0x0163, (wchar_t)0x0165, (wchar_t)0x0167, (wchar_t)0x0169, (wchar_t)0x016B, | ||
| 109 | (wchar_t)0x016D, (wchar_t)0x016F, (wchar_t)0x0171, (wchar_t)0x0173, (wchar_t)0x0175, | ||
| 110 | (wchar_t)0x0177, (wchar_t)0x017A, (wchar_t)0x017C, (wchar_t)0x017E, (wchar_t)0x0183, | ||
| 111 | (wchar_t)0x0185, (wchar_t)0x0188, (wchar_t)0x018C, (wchar_t)0x0192, (wchar_t)0x0199, | ||
| 112 | (wchar_t)0x01A1, (wchar_t)0x01A3, (wchar_t)0x01A5, (wchar_t)0x01A8, (wchar_t)0x01AD, | ||
| 113 | (wchar_t)0x01B0, (wchar_t)0x01B4, (wchar_t)0x01B6, (wchar_t)0x01B9, (wchar_t)0x01BD, | ||
| 114 | (wchar_t)0x01C6, (wchar_t)0x01C9, (wchar_t)0x01CC, (wchar_t)0x01CE, (wchar_t)0x01D0, | ||
| 115 | (wchar_t)0x01D2, (wchar_t)0x01D4, (wchar_t)0x01D6, (wchar_t)0x01D8, (wchar_t)0x01DA, | ||
| 116 | (wchar_t)0x01DC, (wchar_t)0x01DF, (wchar_t)0x01E1, (wchar_t)0x01E3, (wchar_t)0x01E5, | ||
| 117 | (wchar_t)0x01E7, (wchar_t)0x01E9, (wchar_t)0x01EB, (wchar_t)0x01ED, (wchar_t)0x01EF, | ||
| 118 | (wchar_t)0x01F3, (wchar_t)0x01F5, (wchar_t)0x01FB, (wchar_t)0x01FD, (wchar_t)0x01FF, | ||
| 119 | (wchar_t)0x0201, (wchar_t)0x0203, (wchar_t)0x0205, (wchar_t)0x0207, (wchar_t)0x0209, | ||
| 120 | (wchar_t)0x020B, (wchar_t)0x020D, (wchar_t)0x020F, (wchar_t)0x0211, (wchar_t)0x0213, | ||
| 121 | (wchar_t)0x0215, (wchar_t)0x0217, (wchar_t)0x0253, (wchar_t)0x0254, (wchar_t)0x0257, | ||
| 122 | (wchar_t)0x0258, (wchar_t)0x0259, (wchar_t)0x025B, (wchar_t)0x0260, (wchar_t)0x0263, | ||
| 123 | (wchar_t)0x0268, (wchar_t)0x0269, (wchar_t)0x026F, (wchar_t)0x0272, (wchar_t)0x0275, | ||
| 124 | (wchar_t)0x0283, (wchar_t)0x0288, (wchar_t)0x028A, (wchar_t)0x028B, (wchar_t)0x0292, | ||
| 125 | (wchar_t)0x03AC, (wchar_t)0x03AD, (wchar_t)0x03AE, (wchar_t)0x03AF, (wchar_t)0x03B1, | ||
| 126 | (wchar_t)0x03B2, (wchar_t)0x03B3, (wchar_t)0x03B4, (wchar_t)0x03B5, (wchar_t)0x03B6, | ||
| 127 | (wchar_t)0x03B7, (wchar_t)0x03B8, (wchar_t)0x03B9, (wchar_t)0x03BA, (wchar_t)0x03BB, | ||
| 128 | (wchar_t)0x03BC, (wchar_t)0x03BD, (wchar_t)0x03BE, (wchar_t)0x03BF, (wchar_t)0x03C0, | ||
| 129 | (wchar_t)0x03C1, (wchar_t)0x03C3, (wchar_t)0x03C4, (wchar_t)0x03C5, (wchar_t)0x03C6, | ||
| 130 | (wchar_t)0x03C7, (wchar_t)0x03C8, (wchar_t)0x03C9, (wchar_t)0x03CA, (wchar_t)0x03CB, | ||
| 131 | (wchar_t)0x03CC, (wchar_t)0x03CD, (wchar_t)0x03CE, (wchar_t)0x03E3, (wchar_t)0x03E5, | ||
| 132 | (wchar_t)0x03E7, (wchar_t)0x03E9, (wchar_t)0x03EB, (wchar_t)0x03ED, (wchar_t)0x03EF, | ||
| 133 | (wchar_t)0x0430, (wchar_t)0x0431, (wchar_t)0x0432, (wchar_t)0x0433, (wchar_t)0x0434, | ||
| 134 | (wchar_t)0x0435, (wchar_t)0x0436, (wchar_t)0x0437, (wchar_t)0x0438, (wchar_t)0x0439, | ||
| 135 | (wchar_t)0x043A, (wchar_t)0x043B, (wchar_t)0x043C, (wchar_t)0x043D, (wchar_t)0x043E, | ||
| 136 | (wchar_t)0x043F, (wchar_t)0x0440, (wchar_t)0x0441, (wchar_t)0x0442, (wchar_t)0x0443, | ||
| 137 | (wchar_t)0x0444, (wchar_t)0x0445, (wchar_t)0x0446, (wchar_t)0x0447, (wchar_t)0x0448, | ||
| 138 | (wchar_t)0x0449, (wchar_t)0x044A, (wchar_t)0x044B, (wchar_t)0x044C, (wchar_t)0x044D, | ||
| 139 | (wchar_t)0x044E, (wchar_t)0x044F, (wchar_t)0x0451, (wchar_t)0x0452, (wchar_t)0x0453, | ||
| 140 | (wchar_t)0x0454, (wchar_t)0x0455, (wchar_t)0x0456, (wchar_t)0x0457, (wchar_t)0x0458, | ||
| 141 | (wchar_t)0x0459, (wchar_t)0x045A, (wchar_t)0x045B, (wchar_t)0x045C, (wchar_t)0x045E, | ||
| 142 | (wchar_t)0x045F, (wchar_t)0x0461, (wchar_t)0x0463, (wchar_t)0x0465, (wchar_t)0x0467, | ||
| 143 | (wchar_t)0x0469, (wchar_t)0x046B, (wchar_t)0x046D, (wchar_t)0x046F, (wchar_t)0x0471, | ||
| 144 | (wchar_t)0x0473, (wchar_t)0x0475, (wchar_t)0x0477, (wchar_t)0x0479, (wchar_t)0x047B, | ||
| 145 | (wchar_t)0x047D, (wchar_t)0x047F, (wchar_t)0x0481, (wchar_t)0x0491, (wchar_t)0x0493, | ||
| 146 | (wchar_t)0x0495, (wchar_t)0x0497, (wchar_t)0x0499, (wchar_t)0x049B, (wchar_t)0x049D, | ||
| 147 | (wchar_t)0x049F, (wchar_t)0x04A1, (wchar_t)0x04A3, (wchar_t)0x04A5, (wchar_t)0x04A7, | ||
| 148 | (wchar_t)0x04A9, (wchar_t)0x04AB, (wchar_t)0x04AD, (wchar_t)0x04AF, (wchar_t)0x04B1, | ||
| 149 | (wchar_t)0x04B3, (wchar_t)0x04B5, (wchar_t)0x04B7, (wchar_t)0x04B9, (wchar_t)0x04BB, | ||
| 150 | (wchar_t)0x04BD, (wchar_t)0x04BF, (wchar_t)0x04C2, (wchar_t)0x04C4, (wchar_t)0x04C8, | ||
| 151 | (wchar_t)0x04CC, (wchar_t)0x04D1, (wchar_t)0x04D3, (wchar_t)0x04D5, (wchar_t)0x04D7, | ||
| 152 | (wchar_t)0x04D9, (wchar_t)0x04DB, (wchar_t)0x04DD, (wchar_t)0x04DF, (wchar_t)0x04E1, | ||
| 153 | (wchar_t)0x04E3, (wchar_t)0x04E5, (wchar_t)0x04E7, (wchar_t)0x04E9, (wchar_t)0x04EB, | ||
| 154 | (wchar_t)0x04EF, (wchar_t)0x04F1, (wchar_t)0x04F3, (wchar_t)0x04F5, (wchar_t)0x04F9, | ||
| 155 | (wchar_t)0x0561, (wchar_t)0x0562, (wchar_t)0x0563, (wchar_t)0x0564, (wchar_t)0x0565, | ||
| 156 | (wchar_t)0x0566, (wchar_t)0x0567, (wchar_t)0x0568, (wchar_t)0x0569, (wchar_t)0x056A, | ||
| 157 | (wchar_t)0x056B, (wchar_t)0x056C, (wchar_t)0x056D, (wchar_t)0x056E, (wchar_t)0x056F, | ||
| 158 | (wchar_t)0x0570, (wchar_t)0x0571, (wchar_t)0x0572, (wchar_t)0x0573, (wchar_t)0x0574, | ||
| 159 | (wchar_t)0x0575, (wchar_t)0x0576, (wchar_t)0x0577, (wchar_t)0x0578, (wchar_t)0x0579, | ||
| 160 | (wchar_t)0x057A, (wchar_t)0x057B, (wchar_t)0x057C, (wchar_t)0x057D, (wchar_t)0x057E, | ||
| 161 | (wchar_t)0x057F, (wchar_t)0x0580, (wchar_t)0x0581, (wchar_t)0x0582, (wchar_t)0x0583, | ||
| 162 | (wchar_t)0x0584, (wchar_t)0x0585, (wchar_t)0x0586, (wchar_t)0x10D0, (wchar_t)0x10D1, | ||
| 163 | (wchar_t)0x10D2, (wchar_t)0x10D3, (wchar_t)0x10D4, (wchar_t)0x10D5, (wchar_t)0x10D6, | ||
| 164 | (wchar_t)0x10D7, (wchar_t)0x10D8, (wchar_t)0x10D9, (wchar_t)0x10DA, (wchar_t)0x10DB, | ||
| 165 | (wchar_t)0x10DC, (wchar_t)0x10DD, (wchar_t)0x10DE, (wchar_t)0x10DF, (wchar_t)0x10E0, | ||
| 166 | (wchar_t)0x10E1, (wchar_t)0x10E2, (wchar_t)0x10E3, (wchar_t)0x10E4, (wchar_t)0x10E5, | ||
| 167 | (wchar_t)0x10E6, (wchar_t)0x10E7, (wchar_t)0x10E8, (wchar_t)0x10E9, (wchar_t)0x10EA, | ||
| 168 | (wchar_t)0x10EB, (wchar_t)0x10EC, (wchar_t)0x10ED, (wchar_t)0x10EE, (wchar_t)0x10EF, | ||
| 169 | (wchar_t)0x10F0, (wchar_t)0x10F1, (wchar_t)0x10F2, (wchar_t)0x10F3, (wchar_t)0x10F4, | ||
| 170 | (wchar_t)0x10F5, (wchar_t)0x1E01, (wchar_t)0x1E03, (wchar_t)0x1E05, (wchar_t)0x1E07, | ||
| 171 | (wchar_t)0x1E09, (wchar_t)0x1E0B, (wchar_t)0x1E0D, (wchar_t)0x1E0F, (wchar_t)0x1E11, | ||
| 172 | (wchar_t)0x1E13, (wchar_t)0x1E15, (wchar_t)0x1E17, (wchar_t)0x1E19, (wchar_t)0x1E1B, | ||
| 173 | (wchar_t)0x1E1D, (wchar_t)0x1E1F, (wchar_t)0x1E21, (wchar_t)0x1E23, (wchar_t)0x1E25, | ||
| 174 | (wchar_t)0x1E27, (wchar_t)0x1E29, (wchar_t)0x1E2B, (wchar_t)0x1E2D, (wchar_t)0x1E2F, | ||
| 175 | (wchar_t)0x1E31, (wchar_t)0x1E33, (wchar_t)0x1E35, (wchar_t)0x1E37, (wchar_t)0x1E39, | ||
| 176 | (wchar_t)0x1E3B, (wchar_t)0x1E3D, (wchar_t)0x1E3F, (wchar_t)0x1E41, (wchar_t)0x1E43, | ||
| 177 | (wchar_t)0x1E45, (wchar_t)0x1E47, (wchar_t)0x1E49, (wchar_t)0x1E4B, (wchar_t)0x1E4D, | ||
| 178 | (wchar_t)0x1E4F, (wchar_t)0x1E51, (wchar_t)0x1E53, (wchar_t)0x1E55, (wchar_t)0x1E57, | ||
| 179 | (wchar_t)0x1E59, (wchar_t)0x1E5B, (wchar_t)0x1E5D, (wchar_t)0x1E5F, (wchar_t)0x1E61, | ||
| 180 | (wchar_t)0x1E63, (wchar_t)0x1E65, (wchar_t)0x1E67, (wchar_t)0x1E69, (wchar_t)0x1E6B, | ||
| 181 | (wchar_t)0x1E6D, (wchar_t)0x1E6F, (wchar_t)0x1E71, (wchar_t)0x1E73, (wchar_t)0x1E75, | ||
| 182 | (wchar_t)0x1E77, (wchar_t)0x1E79, (wchar_t)0x1E7B, (wchar_t)0x1E7D, (wchar_t)0x1E7F, | ||
| 183 | (wchar_t)0x1E81, (wchar_t)0x1E83, (wchar_t)0x1E85, (wchar_t)0x1E87, (wchar_t)0x1E89, | ||
| 184 | (wchar_t)0x1E8B, (wchar_t)0x1E8D, (wchar_t)0x1E8F, (wchar_t)0x1E91, (wchar_t)0x1E93, | ||
| 185 | (wchar_t)0x1E95, (wchar_t)0x1EA1, (wchar_t)0x1EA3, (wchar_t)0x1EA5, (wchar_t)0x1EA7, | ||
| 186 | (wchar_t)0x1EA9, (wchar_t)0x1EAB, (wchar_t)0x1EAD, (wchar_t)0x1EAF, (wchar_t)0x1EB1, | ||
| 187 | (wchar_t)0x1EB3, (wchar_t)0x1EB5, (wchar_t)0x1EB7, (wchar_t)0x1EB9, (wchar_t)0x1EBB, | ||
| 188 | (wchar_t)0x1EBD, (wchar_t)0x1EBF, (wchar_t)0x1EC1, (wchar_t)0x1EC3, (wchar_t)0x1EC5, | ||
| 189 | (wchar_t)0x1EC7, (wchar_t)0x1EC9, (wchar_t)0x1ECB, (wchar_t)0x1ECD, (wchar_t)0x1ECF, | ||
| 190 | (wchar_t)0x1ED1, (wchar_t)0x1ED3, (wchar_t)0x1ED5, (wchar_t)0x1ED7, (wchar_t)0x1ED9, | ||
| 191 | (wchar_t)0x1EDB, (wchar_t)0x1EDD, (wchar_t)0x1EDF, (wchar_t)0x1EE1, (wchar_t)0x1EE3, | ||
| 192 | (wchar_t)0x1EE5, (wchar_t)0x1EE7, (wchar_t)0x1EE9, (wchar_t)0x1EEB, (wchar_t)0x1EED, | ||
| 193 | (wchar_t)0x1EEF, (wchar_t)0x1EF1, (wchar_t)0x1EF3, (wchar_t)0x1EF5, (wchar_t)0x1EF7, | ||
| 194 | (wchar_t)0x1EF9, (wchar_t)0x1F00, (wchar_t)0x1F01, (wchar_t)0x1F02, (wchar_t)0x1F03, | ||
| 195 | (wchar_t)0x1F04, (wchar_t)0x1F05, (wchar_t)0x1F06, (wchar_t)0x1F07, (wchar_t)0x1F10, | ||
| 196 | (wchar_t)0x1F11, (wchar_t)0x1F12, (wchar_t)0x1F13, (wchar_t)0x1F14, (wchar_t)0x1F15, | ||
| 197 | (wchar_t)0x1F20, (wchar_t)0x1F21, (wchar_t)0x1F22, (wchar_t)0x1F23, (wchar_t)0x1F24, | ||
| 198 | (wchar_t)0x1F25, (wchar_t)0x1F26, (wchar_t)0x1F27, (wchar_t)0x1F30, (wchar_t)0x1F31, | ||
| 199 | (wchar_t)0x1F32, (wchar_t)0x1F33, (wchar_t)0x1F34, (wchar_t)0x1F35, (wchar_t)0x1F36, | ||
| 200 | (wchar_t)0x1F37, (wchar_t)0x1F40, (wchar_t)0x1F41, (wchar_t)0x1F42, (wchar_t)0x1F43, | ||
| 201 | (wchar_t)0x1F44, (wchar_t)0x1F45, (wchar_t)0x1F51, (wchar_t)0x1F53, (wchar_t)0x1F55, | ||
| 202 | (wchar_t)0x1F57, (wchar_t)0x1F60, (wchar_t)0x1F61, (wchar_t)0x1F62, (wchar_t)0x1F63, | ||
| 203 | (wchar_t)0x1F64, (wchar_t)0x1F65, (wchar_t)0x1F66, (wchar_t)0x1F67, (wchar_t)0x1F80, | ||
| 204 | (wchar_t)0x1F81, (wchar_t)0x1F82, (wchar_t)0x1F83, (wchar_t)0x1F84, (wchar_t)0x1F85, | ||
| 205 | (wchar_t)0x1F86, (wchar_t)0x1F87, (wchar_t)0x1F90, (wchar_t)0x1F91, (wchar_t)0x1F92, | ||
| 206 | (wchar_t)0x1F93, (wchar_t)0x1F94, (wchar_t)0x1F95, (wchar_t)0x1F96, (wchar_t)0x1F97, | ||
| 207 | (wchar_t)0x1FA0, (wchar_t)0x1FA1, (wchar_t)0x1FA2, (wchar_t)0x1FA3, (wchar_t)0x1FA4, | ||
| 208 | (wchar_t)0x1FA5, (wchar_t)0x1FA6, (wchar_t)0x1FA7, (wchar_t)0x1FB0, (wchar_t)0x1FB1, | ||
| 209 | (wchar_t)0x1FD0, (wchar_t)0x1FD1, (wchar_t)0x1FE0, (wchar_t)0x1FE1, (wchar_t)0x24D0, | ||
| 210 | (wchar_t)0x24D1, (wchar_t)0x24D2, (wchar_t)0x24D3, (wchar_t)0x24D4, (wchar_t)0x24D5, | ||
| 211 | (wchar_t)0x24D6, (wchar_t)0x24D7, (wchar_t)0x24D8, (wchar_t)0x24D9, (wchar_t)0x24DA, | ||
| 212 | (wchar_t)0x24DB, (wchar_t)0x24DC, (wchar_t)0x24DD, (wchar_t)0x24DE, (wchar_t)0x24DF, | ||
| 213 | (wchar_t)0x24E0, (wchar_t)0x24E1, (wchar_t)0x24E2, (wchar_t)0x24E3, (wchar_t)0x24E4, | ||
| 214 | (wchar_t)0x24E5, (wchar_t)0x24E6, (wchar_t)0x24E7, (wchar_t)0x24E8, (wchar_t)0x24E9, | ||
| 215 | (wchar_t)0xFF41, (wchar_t)0xFF42, (wchar_t)0xFF43, (wchar_t)0xFF44, (wchar_t)0xFF45, | ||
| 216 | (wchar_t)0xFF46, (wchar_t)0xFF47, (wchar_t)0xFF48, (wchar_t)0xFF49, (wchar_t)0xFF4A, | ||
| 217 | (wchar_t)0xFF4B, (wchar_t)0xFF4C, (wchar_t)0xFF4D, (wchar_t)0xFF4E, (wchar_t)0xFF4F, | ||
| 218 | (wchar_t)0xFF50, (wchar_t)0xFF51, (wchar_t)0xFF52, (wchar_t)0xFF53, (wchar_t)0xFF54, | ||
| 219 | (wchar_t)0xFF55, (wchar_t)0xFF56, (wchar_t)0xFF57, (wchar_t)0xFF58, (wchar_t)0xFF59, | ||
| 220 | (wchar_t)0xFF5A}; | ||
| 221 | |||
| 222 | static const wchar_t unicode_uppers[] = { | ||
| 223 | (wchar_t)0x0041, (wchar_t)0x0042, (wchar_t)0x0043, (wchar_t)0x0044, (wchar_t)0x0045, | ||
| 224 | (wchar_t)0x0046, (wchar_t)0x0047, (wchar_t)0x0048, (wchar_t)0x0049, (wchar_t)0x004A, | ||
| 225 | (wchar_t)0x004B, (wchar_t)0x004C, (wchar_t)0x004D, (wchar_t)0x004E, (wchar_t)0x004F, | ||
| 226 | (wchar_t)0x0050, (wchar_t)0x0051, (wchar_t)0x0052, (wchar_t)0x0053, (wchar_t)0x0054, | ||
| 227 | (wchar_t)0x0055, (wchar_t)0x0056, (wchar_t)0x0057, (wchar_t)0x0058, (wchar_t)0x0059, | ||
| 228 | (wchar_t)0x005A, (wchar_t)0x00C0, (wchar_t)0x00C1, (wchar_t)0x00C2, (wchar_t)0x00C3, | ||
| 229 | (wchar_t)0x00C4, (wchar_t)0x00C5, (wchar_t)0x00C6, (wchar_t)0x00C7, (wchar_t)0x00C8, | ||
| 230 | (wchar_t)0x00C9, (wchar_t)0x00CA, (wchar_t)0x00CB, (wchar_t)0x00CC, (wchar_t)0x00CD, | ||
| 231 | (wchar_t)0x00CE, (wchar_t)0x00CF, (wchar_t)0x00D0, (wchar_t)0x00D1, (wchar_t)0x00D2, | ||
| 232 | (wchar_t)0x00D3, (wchar_t)0x00D4, (wchar_t)0x00D5, (wchar_t)0x00D6, (wchar_t)0x00D8, | ||
| 233 | (wchar_t)0x00D9, (wchar_t)0x00DA, (wchar_t)0x00DB, (wchar_t)0x00DC, (wchar_t)0x00DD, | ||
| 234 | (wchar_t)0x00DE, (wchar_t)0x0178, (wchar_t)0x0100, (wchar_t)0x0102, (wchar_t)0x0104, | ||
| 235 | (wchar_t)0x0106, (wchar_t)0x0108, (wchar_t)0x010A, (wchar_t)0x010C, (wchar_t)0x010E, | ||
| 236 | (wchar_t)0x0110, (wchar_t)0x0112, (wchar_t)0x0114, (wchar_t)0x0116, (wchar_t)0x0118, | ||
| 237 | (wchar_t)0x011A, (wchar_t)0x011C, (wchar_t)0x011E, (wchar_t)0x0120, (wchar_t)0x0122, | ||
| 238 | (wchar_t)0x0124, (wchar_t)0x0126, (wchar_t)0x0128, (wchar_t)0x012A, (wchar_t)0x012C, | ||
| 239 | (wchar_t)0x012E, (wchar_t)0x0049, (wchar_t)0x0132, (wchar_t)0x0134, (wchar_t)0x0136, | ||
| 240 | (wchar_t)0x0139, (wchar_t)0x013B, (wchar_t)0x013D, (wchar_t)0x013F, (wchar_t)0x0141, | ||
| 241 | (wchar_t)0x0143, (wchar_t)0x0145, (wchar_t)0x0147, (wchar_t)0x014A, (wchar_t)0x014C, | ||
| 242 | (wchar_t)0x014E, (wchar_t)0x0150, (wchar_t)0x0152, (wchar_t)0x0154, (wchar_t)0x0156, | ||
| 243 | (wchar_t)0x0158, (wchar_t)0x015A, (wchar_t)0x015C, (wchar_t)0x015E, (wchar_t)0x0160, | ||
| 244 | (wchar_t)0x0162, (wchar_t)0x0164, (wchar_t)0x0166, (wchar_t)0x0168, (wchar_t)0x016A, | ||
| 245 | (wchar_t)0x016C, (wchar_t)0x016E, (wchar_t)0x0170, (wchar_t)0x0172, (wchar_t)0x0174, | ||
| 246 | (wchar_t)0x0176, (wchar_t)0x0179, (wchar_t)0x017B, (wchar_t)0x017D, (wchar_t)0x0182, | ||
| 247 | (wchar_t)0x0184, (wchar_t)0x0187, (wchar_t)0x018B, (wchar_t)0x0191, (wchar_t)0x0198, | ||
| 248 | (wchar_t)0x01A0, (wchar_t)0x01A2, (wchar_t)0x01A4, (wchar_t)0x01A7, (wchar_t)0x01AC, | ||
| 249 | (wchar_t)0x01AF, (wchar_t)0x01B3, (wchar_t)0x01B5, (wchar_t)0x01B8, (wchar_t)0x01BC, | ||
| 250 | (wchar_t)0x01C4, (wchar_t)0x01C7, (wchar_t)0x01CA, (wchar_t)0x01CD, (wchar_t)0x01CF, | ||
| 251 | (wchar_t)0x01D1, (wchar_t)0x01D3, (wchar_t)0x01D5, (wchar_t)0x01D7, (wchar_t)0x01D9, | ||
| 252 | (wchar_t)0x01DB, (wchar_t)0x01DE, (wchar_t)0x01E0, (wchar_t)0x01E2, (wchar_t)0x01E4, | ||
| 253 | (wchar_t)0x01E6, (wchar_t)0x01E8, (wchar_t)0x01EA, (wchar_t)0x01EC, (wchar_t)0x01EE, | ||
| 254 | (wchar_t)0x01F1, (wchar_t)0x01F4, (wchar_t)0x01FA, (wchar_t)0x01FC, (wchar_t)0x01FE, | ||
| 255 | (wchar_t)0x0200, (wchar_t)0x0202, (wchar_t)0x0204, (wchar_t)0x0206, (wchar_t)0x0208, | ||
| 256 | (wchar_t)0x020A, (wchar_t)0x020C, (wchar_t)0x020E, (wchar_t)0x0210, (wchar_t)0x0212, | ||
| 257 | (wchar_t)0x0214, (wchar_t)0x0216, (wchar_t)0x0181, (wchar_t)0x0186, (wchar_t)0x018A, | ||
| 258 | (wchar_t)0x018E, (wchar_t)0x018F, (wchar_t)0x0190, (wchar_t)0x0193, (wchar_t)0x0194, | ||
| 259 | (wchar_t)0x0197, (wchar_t)0x0196, (wchar_t)0x019C, (wchar_t)0x019D, (wchar_t)0x019F, | ||
| 260 | (wchar_t)0x01A9, (wchar_t)0x01AE, (wchar_t)0x01B1, (wchar_t)0x01B2, (wchar_t)0x01B7, | ||
| 261 | (wchar_t)0x0386, (wchar_t)0x0388, (wchar_t)0x0389, (wchar_t)0x038A, (wchar_t)0x0391, | ||
| 262 | (wchar_t)0x0392, (wchar_t)0x0393, (wchar_t)0x0394, (wchar_t)0x0395, (wchar_t)0x0396, | ||
| 263 | (wchar_t)0x0397, (wchar_t)0x0398, (wchar_t)0x0399, (wchar_t)0x039A, (wchar_t)0x039B, | ||
| 264 | (wchar_t)0x039C, (wchar_t)0x039D, (wchar_t)0x039E, (wchar_t)0x039F, (wchar_t)0x03A0, | ||
| 265 | (wchar_t)0x03A1, (wchar_t)0x03A3, (wchar_t)0x03A4, (wchar_t)0x03A5, (wchar_t)0x03A6, | ||
| 266 | (wchar_t)0x03A7, (wchar_t)0x03A8, (wchar_t)0x03A9, (wchar_t)0x03AA, (wchar_t)0x03AB, | ||
| 267 | (wchar_t)0x038C, (wchar_t)0x038E, (wchar_t)0x038F, (wchar_t)0x03E2, (wchar_t)0x03E4, | ||
| 268 | (wchar_t)0x03E6, (wchar_t)0x03E8, (wchar_t)0x03EA, (wchar_t)0x03EC, (wchar_t)0x03EE, | ||
| 269 | (wchar_t)0x0410, (wchar_t)0x0411, (wchar_t)0x0412, (wchar_t)0x0413, (wchar_t)0x0414, | ||
| 270 | (wchar_t)0x0415, (wchar_t)0x0416, (wchar_t)0x0417, (wchar_t)0x0418, (wchar_t)0x0419, | ||
| 271 | (wchar_t)0x041A, (wchar_t)0x041B, (wchar_t)0x041C, (wchar_t)0x041D, (wchar_t)0x041E, | ||
| 272 | (wchar_t)0x041F, (wchar_t)0x0420, (wchar_t)0x0421, (wchar_t)0x0422, (wchar_t)0x0423, | ||
| 273 | (wchar_t)0x0424, (wchar_t)0x0425, (wchar_t)0x0426, (wchar_t)0x0427, (wchar_t)0x0428, | ||
| 274 | (wchar_t)0x0429, (wchar_t)0x042A, (wchar_t)0x042B, (wchar_t)0x042C, (wchar_t)0x042D, | ||
| 275 | (wchar_t)0x042E, (wchar_t)0x042F, (wchar_t)0x0401, (wchar_t)0x0402, (wchar_t)0x0403, | ||
| 276 | (wchar_t)0x0404, (wchar_t)0x0405, (wchar_t)0x0406, (wchar_t)0x0407, (wchar_t)0x0408, | ||
| 277 | (wchar_t)0x0409, (wchar_t)0x040A, (wchar_t)0x040B, (wchar_t)0x040C, (wchar_t)0x040E, | ||
| 278 | (wchar_t)0x040F, (wchar_t)0x0460, (wchar_t)0x0462, (wchar_t)0x0464, (wchar_t)0x0466, | ||
| 279 | (wchar_t)0x0468, (wchar_t)0x046A, (wchar_t)0x046C, (wchar_t)0x046E, (wchar_t)0x0470, | ||
| 280 | (wchar_t)0x0472, (wchar_t)0x0474, (wchar_t)0x0476, (wchar_t)0x0478, (wchar_t)0x047A, | ||
| 281 | (wchar_t)0x047C, (wchar_t)0x047E, (wchar_t)0x0480, (wchar_t)0x0490, (wchar_t)0x0492, | ||
| 282 | (wchar_t)0x0494, (wchar_t)0x0496, (wchar_t)0x0498, (wchar_t)0x049A, (wchar_t)0x049C, | ||
| 283 | (wchar_t)0x049E, (wchar_t)0x04A0, (wchar_t)0x04A2, (wchar_t)0x04A4, (wchar_t)0x04A6, | ||
| 284 | (wchar_t)0x04A8, (wchar_t)0x04AA, (wchar_t)0x04AC, (wchar_t)0x04AE, (wchar_t)0x04B0, | ||
| 285 | (wchar_t)0x04B2, (wchar_t)0x04B4, (wchar_t)0x04B6, (wchar_t)0x04B8, (wchar_t)0x04BA, | ||
| 286 | (wchar_t)0x04BC, (wchar_t)0x04BE, (wchar_t)0x04C1, (wchar_t)0x04C3, (wchar_t)0x04C7, | ||
| 287 | (wchar_t)0x04CB, (wchar_t)0x04D0, (wchar_t)0x04D2, (wchar_t)0x04D4, (wchar_t)0x04D6, | ||
| 288 | (wchar_t)0x04D8, (wchar_t)0x04DA, (wchar_t)0x04DC, (wchar_t)0x04DE, (wchar_t)0x04E0, | ||
| 289 | (wchar_t)0x04E2, (wchar_t)0x04E4, (wchar_t)0x04E6, (wchar_t)0x04E8, (wchar_t)0x04EA, | ||
| 290 | (wchar_t)0x04EE, (wchar_t)0x04F0, (wchar_t)0x04F2, (wchar_t)0x04F4, (wchar_t)0x04F8, | ||
| 291 | (wchar_t)0x0531, (wchar_t)0x0532, (wchar_t)0x0533, (wchar_t)0x0534, (wchar_t)0x0535, | ||
| 292 | (wchar_t)0x0536, (wchar_t)0x0537, (wchar_t)0x0538, (wchar_t)0x0539, (wchar_t)0x053A, | ||
| 293 | (wchar_t)0x053B, (wchar_t)0x053C, (wchar_t)0x053D, (wchar_t)0x053E, (wchar_t)0x053F, | ||
| 294 | (wchar_t)0x0540, (wchar_t)0x0541, (wchar_t)0x0542, (wchar_t)0x0543, (wchar_t)0x0544, | ||
| 295 | (wchar_t)0x0545, (wchar_t)0x0546, (wchar_t)0x0547, (wchar_t)0x0548, (wchar_t)0x0549, | ||
| 296 | (wchar_t)0x054A, (wchar_t)0x054B, (wchar_t)0x054C, (wchar_t)0x054D, (wchar_t)0x054E, | ||
| 297 | (wchar_t)0x054F, (wchar_t)0x0550, (wchar_t)0x0551, (wchar_t)0x0552, (wchar_t)0x0553, | ||
| 298 | (wchar_t)0x0554, (wchar_t)0x0555, (wchar_t)0x0556, (wchar_t)0x10A0, (wchar_t)0x10A1, | ||
| 299 | (wchar_t)0x10A2, (wchar_t)0x10A3, (wchar_t)0x10A4, (wchar_t)0x10A5, (wchar_t)0x10A6, | ||
| 300 | (wchar_t)0x10A7, (wchar_t)0x10A8, (wchar_t)0x10A9, (wchar_t)0x10AA, (wchar_t)0x10AB, | ||
| 301 | (wchar_t)0x10AC, (wchar_t)0x10AD, (wchar_t)0x10AE, (wchar_t)0x10AF, (wchar_t)0x10B0, | ||
| 302 | (wchar_t)0x10B1, (wchar_t)0x10B2, (wchar_t)0x10B3, (wchar_t)0x10B4, (wchar_t)0x10B5, | ||
| 303 | (wchar_t)0x10B6, (wchar_t)0x10B7, (wchar_t)0x10B8, (wchar_t)0x10B9, (wchar_t)0x10BA, | ||
| 304 | (wchar_t)0x10BB, (wchar_t)0x10BC, (wchar_t)0x10BD, (wchar_t)0x10BE, (wchar_t)0x10BF, | ||
| 305 | (wchar_t)0x10C0, (wchar_t)0x10C1, (wchar_t)0x10C2, (wchar_t)0x10C3, (wchar_t)0x10C4, | ||
| 306 | (wchar_t)0x10C5, (wchar_t)0x1E00, (wchar_t)0x1E02, (wchar_t)0x1E04, (wchar_t)0x1E06, | ||
| 307 | (wchar_t)0x1E08, (wchar_t)0x1E0A, (wchar_t)0x1E0C, (wchar_t)0x1E0E, (wchar_t)0x1E10, | ||
| 308 | (wchar_t)0x1E12, (wchar_t)0x1E14, (wchar_t)0x1E16, (wchar_t)0x1E18, (wchar_t)0x1E1A, | ||
| 309 | (wchar_t)0x1E1C, (wchar_t)0x1E1E, (wchar_t)0x1E20, (wchar_t)0x1E22, (wchar_t)0x1E24, | ||
| 310 | (wchar_t)0x1E26, (wchar_t)0x1E28, (wchar_t)0x1E2A, (wchar_t)0x1E2C, (wchar_t)0x1E2E, | ||
| 311 | (wchar_t)0x1E30, (wchar_t)0x1E32, (wchar_t)0x1E34, (wchar_t)0x1E36, (wchar_t)0x1E38, | ||
| 312 | (wchar_t)0x1E3A, (wchar_t)0x1E3C, (wchar_t)0x1E3E, (wchar_t)0x1E40, (wchar_t)0x1E42, | ||
| 313 | (wchar_t)0x1E44, (wchar_t)0x1E46, (wchar_t)0x1E48, (wchar_t)0x1E4A, (wchar_t)0x1E4C, | ||
| 314 | (wchar_t)0x1E4E, (wchar_t)0x1E50, (wchar_t)0x1E52, (wchar_t)0x1E54, (wchar_t)0x1E56, | ||
| 315 | (wchar_t)0x1E58, (wchar_t)0x1E5A, (wchar_t)0x1E5C, (wchar_t)0x1E5E, (wchar_t)0x1E60, | ||
| 316 | (wchar_t)0x1E62, (wchar_t)0x1E64, (wchar_t)0x1E66, (wchar_t)0x1E68, (wchar_t)0x1E6A, | ||
| 317 | (wchar_t)0x1E6C, (wchar_t)0x1E6E, (wchar_t)0x1E70, (wchar_t)0x1E72, (wchar_t)0x1E74, | ||
| 318 | (wchar_t)0x1E76, (wchar_t)0x1E78, (wchar_t)0x1E7A, (wchar_t)0x1E7C, (wchar_t)0x1E7E, | ||
| 319 | (wchar_t)0x1E80, (wchar_t)0x1E82, (wchar_t)0x1E84, (wchar_t)0x1E86, (wchar_t)0x1E88, | ||
| 320 | (wchar_t)0x1E8A, (wchar_t)0x1E8C, (wchar_t)0x1E8E, (wchar_t)0x1E90, (wchar_t)0x1E92, | ||
| 321 | (wchar_t)0x1E94, (wchar_t)0x1EA0, (wchar_t)0x1EA2, (wchar_t)0x1EA4, (wchar_t)0x1EA6, | ||
| 322 | (wchar_t)0x1EA8, (wchar_t)0x1EAA, (wchar_t)0x1EAC, (wchar_t)0x1EAE, (wchar_t)0x1EB0, | ||
| 323 | (wchar_t)0x1EB2, (wchar_t)0x1EB4, (wchar_t)0x1EB6, (wchar_t)0x1EB8, (wchar_t)0x1EBA, | ||
| 324 | (wchar_t)0x1EBC, (wchar_t)0x1EBE, (wchar_t)0x1EC0, (wchar_t)0x1EC2, (wchar_t)0x1EC4, | ||
| 325 | (wchar_t)0x1EC6, (wchar_t)0x1EC8, (wchar_t)0x1ECA, (wchar_t)0x1ECC, (wchar_t)0x1ECE, | ||
| 326 | (wchar_t)0x1ED0, (wchar_t)0x1ED2, (wchar_t)0x1ED4, (wchar_t)0x1ED6, (wchar_t)0x1ED8, | ||
| 327 | (wchar_t)0x1EDA, (wchar_t)0x1EDC, (wchar_t)0x1EDE, (wchar_t)0x1EE0, (wchar_t)0x1EE2, | ||
| 328 | (wchar_t)0x1EE4, (wchar_t)0x1EE6, (wchar_t)0x1EE8, (wchar_t)0x1EEA, (wchar_t)0x1EEC, | ||
| 329 | (wchar_t)0x1EEE, (wchar_t)0x1EF0, (wchar_t)0x1EF2, (wchar_t)0x1EF4, (wchar_t)0x1EF6, | ||
| 330 | (wchar_t)0x1EF8, (wchar_t)0x1F08, (wchar_t)0x1F09, (wchar_t)0x1F0A, (wchar_t)0x1F0B, | ||
| 331 | (wchar_t)0x1F0C, (wchar_t)0x1F0D, (wchar_t)0x1F0E, (wchar_t)0x1F0F, (wchar_t)0x1F18, | ||
| 332 | (wchar_t)0x1F19, (wchar_t)0x1F1A, (wchar_t)0x1F1B, (wchar_t)0x1F1C, (wchar_t)0x1F1D, | ||
| 333 | (wchar_t)0x1F28, (wchar_t)0x1F29, (wchar_t)0x1F2A, (wchar_t)0x1F2B, (wchar_t)0x1F2C, | ||
| 334 | (wchar_t)0x1F2D, (wchar_t)0x1F2E, (wchar_t)0x1F2F, (wchar_t)0x1F38, (wchar_t)0x1F39, | ||
| 335 | (wchar_t)0x1F3A, (wchar_t)0x1F3B, (wchar_t)0x1F3C, (wchar_t)0x1F3D, (wchar_t)0x1F3E, | ||
| 336 | (wchar_t)0x1F3F, (wchar_t)0x1F48, (wchar_t)0x1F49, (wchar_t)0x1F4A, (wchar_t)0x1F4B, | ||
| 337 | (wchar_t)0x1F4C, (wchar_t)0x1F4D, (wchar_t)0x1F59, (wchar_t)0x1F5B, (wchar_t)0x1F5D, | ||
| 338 | (wchar_t)0x1F5F, (wchar_t)0x1F68, (wchar_t)0x1F69, (wchar_t)0x1F6A, (wchar_t)0x1F6B, | ||
| 339 | (wchar_t)0x1F6C, (wchar_t)0x1F6D, (wchar_t)0x1F6E, (wchar_t)0x1F6F, (wchar_t)0x1F88, | ||
| 340 | (wchar_t)0x1F89, (wchar_t)0x1F8A, (wchar_t)0x1F8B, (wchar_t)0x1F8C, (wchar_t)0x1F8D, | ||
| 341 | (wchar_t)0x1F8E, (wchar_t)0x1F8F, (wchar_t)0x1F98, (wchar_t)0x1F99, (wchar_t)0x1F9A, | ||
| 342 | (wchar_t)0x1F9B, (wchar_t)0x1F9C, (wchar_t)0x1F9D, (wchar_t)0x1F9E, (wchar_t)0x1F9F, | ||
| 343 | (wchar_t)0x1FA8, (wchar_t)0x1FA9, (wchar_t)0x1FAA, (wchar_t)0x1FAB, (wchar_t)0x1FAC, | ||
| 344 | (wchar_t)0x1FAD, (wchar_t)0x1FAE, (wchar_t)0x1FAF, (wchar_t)0x1FB8, (wchar_t)0x1FB9, | ||
| 345 | (wchar_t)0x1FD8, (wchar_t)0x1FD9, (wchar_t)0x1FE8, (wchar_t)0x1FE9, (wchar_t)0x24B6, | ||
| 346 | (wchar_t)0x24B7, (wchar_t)0x24B8, (wchar_t)0x24B9, (wchar_t)0x24BA, (wchar_t)0x24BB, | ||
| 347 | (wchar_t)0x24BC, (wchar_t)0x24BD, (wchar_t)0x24BE, (wchar_t)0x24BF, (wchar_t)0x24C0, | ||
| 348 | (wchar_t)0x24C1, (wchar_t)0x24C2, (wchar_t)0x24C3, (wchar_t)0x24C4, (wchar_t)0x24C5, | ||
| 349 | (wchar_t)0x24C6, (wchar_t)0x24C7, (wchar_t)0x24C8, (wchar_t)0x24C9, (wchar_t)0x24CA, | ||
| 350 | (wchar_t)0x24CB, (wchar_t)0x24CC, (wchar_t)0x24CD, (wchar_t)0x24CE, (wchar_t)0x24CF, | ||
| 351 | (wchar_t)0xFF21, (wchar_t)0xFF22, (wchar_t)0xFF23, (wchar_t)0xFF24, (wchar_t)0xFF25, | ||
| 352 | (wchar_t)0xFF26, (wchar_t)0xFF27, (wchar_t)0xFF28, (wchar_t)0xFF29, (wchar_t)0xFF2A, | ||
| 353 | (wchar_t)0xFF2B, (wchar_t)0xFF2C, (wchar_t)0xFF2D, (wchar_t)0xFF2E, (wchar_t)0xFF2F, | ||
| 354 | (wchar_t)0xFF30, (wchar_t)0xFF31, (wchar_t)0xFF32, (wchar_t)0xFF33, (wchar_t)0xFF34, | ||
| 355 | (wchar_t)0xFF35, (wchar_t)0xFF36, (wchar_t)0xFF37, (wchar_t)0xFF38, (wchar_t)0xFF39, | ||
| 356 | (wchar_t)0xFF3A}; | ||
| 357 | |||
| 358 | namespace kodi | ||
| 359 | { | ||
| 360 | namespace tools | ||
| 361 | { | ||
| 362 | |||
| 363 | template<typename T, std::enable_if_t<!std::is_enum<T>::value, int> = 0> | ||
| 364 | constexpr auto&& EnumToInt(T&& arg) noexcept | ||
| 365 | { | ||
| 366 | return arg; | ||
| 367 | } | ||
| 368 | template<typename T, std::enable_if_t<std::is_enum<T>::value, int> = 0> | ||
| 369 | constexpr auto EnumToInt(T&& arg) noexcept | ||
| 370 | { | ||
| 371 | return static_cast<int>(arg); | ||
| 372 | } | ||
| 373 | |||
| 374 | //============================================================================== | ||
| 375 | /// @defgroup cpp_kodi_tools_StringUtils_Defs Definitions, structures and enumerators | ||
| 376 | /// @ingroup cpp_kodi_tools_StringUtils | ||
| 377 | /// @brief **Parts used within string util functions**\n | ||
| 378 | /// All to string functions associated data structures. | ||
| 379 | /// | ||
| 380 | /// It is divided into individual modules that correspond to the respective | ||
| 381 | /// types. | ||
| 382 | /// | ||
| 383 | /// | ||
| 384 | /// | ||
| 385 | |||
| 386 | //============================================================================== | ||
| 387 | /// @defgroup cpp_kodi_tools_StringUtils_Defs_TIME_FORMAT enum TIME_FORMAT | ||
| 388 | /// @ingroup cpp_kodi_tools_StringUtils_Defs | ||
| 389 | /// @brief TIME_FORMAT enum/bitmask used for formatting time strings. | ||
| 390 | /// | ||
| 391 | /// Note the use of bitmasking, e.g. TIME_FORMAT_HH_MM_SS = TIME_FORMAT_HH | TIME_FORMAT_MM | TIME_FORMAT_SS | ||
| 392 | /// @sa kodi::tools::StringUtils::SecondsToTimeString | ||
| 393 | /// | ||
| 394 | /// @note For InfoLabels use the equivalent value listed (bold) on the | ||
| 395 | /// description of each enum value. | ||
| 396 | /// | ||
| 397 | /// <b>Example:</b> 3661 seconds => h=1, hh=01, m=1, mm=01, ss=01, hours=1, mins=61, secs=3661 | ||
| 398 | /// | ||
| 399 | ///@{ | ||
| 400 | enum TIME_FORMAT | ||
| 401 | { | ||
| 402 | /// Usually used as the fallback value if the format value is empty | ||
| 403 | TIME_FORMAT_GUESS = 0, | ||
| 404 | |||
| 405 | /// <b>ss</b> - seconds only | ||
| 406 | TIME_FORMAT_SS = 1, | ||
| 407 | |||
| 408 | /// <b>mm</b> - minutes only (2-digit) | ||
| 409 | TIME_FORMAT_MM = 2, | ||
| 410 | |||
| 411 | /// <b>mm:ss</b> - minutes and seconds | ||
| 412 | TIME_FORMAT_MM_SS = 3, | ||
| 413 | |||
| 414 | /// <b>hh</b> - hours only (2-digit) | ||
| 415 | TIME_FORMAT_HH = 4, | ||
| 416 | |||
| 417 | /// <b>hh:ss</b> - hours and seconds (this is not particularly useful) | ||
| 418 | TIME_FORMAT_HH_SS = 5, | ||
| 419 | |||
| 420 | /// <b>hh:mm</b> - hours and minutes | ||
| 421 | TIME_FORMAT_HH_MM = 6, | ||
| 422 | |||
| 423 | /// <b>hh:mm:ss</b> - hours, minutes and seconds | ||
| 424 | TIME_FORMAT_HH_MM_SS = 7, | ||
| 425 | |||
| 426 | /// <b>xx</b> - returns AM/PM for a 12-hour clock | ||
| 427 | TIME_FORMAT_XX = 8, | ||
| 428 | |||
| 429 | /// <b>hh:mm xx</b> - returns hours and minutes in a 12-hour clock format (AM/PM) | ||
| 430 | TIME_FORMAT_HH_MM_XX = 14, | ||
| 431 | |||
| 432 | /// <b>hh:mm:ss xx</b> - returns hours (2-digit), minutes and seconds in a 12-hour clock format (AM/PM) | ||
| 433 | TIME_FORMAT_HH_MM_SS_XX = 15, | ||
| 434 | |||
| 435 | /// <b>h</b> - hours only (1-digit) | ||
| 436 | TIME_FORMAT_H = 16, | ||
| 437 | |||
| 438 | /// <b>hh:mm:ss</b> - hours, minutes and seconds | ||
| 439 | TIME_FORMAT_H_MM_SS = 19, | ||
| 440 | |||
| 441 | /// <b>hh:mm:ss xx</b> - returns hours (1-digit), minutes and seconds in a 12-hour clock format (AM/PM) | ||
| 442 | TIME_FORMAT_H_MM_SS_XX = 27, | ||
| 443 | |||
| 444 | /// <b>secs</b> - total time in seconds | ||
| 445 | TIME_FORMAT_SECS = 32, | ||
| 446 | |||
| 447 | /// <b>mins</b> - total time in minutes | ||
| 448 | TIME_FORMAT_MINS = 64, | ||
| 449 | |||
| 450 | /// <b>hours</b> - total time in hours | ||
| 451 | TIME_FORMAT_HOURS = 128, | ||
| 452 | |||
| 453 | /// <b>m</b> - minutes only (1-digit) | ||
| 454 | TIME_FORMAT_M = 256 | ||
| 455 | }; | ||
| 456 | ///@} | ||
| 457 | //------------------------------------------------------------------------------ | ||
| 458 | |||
| 459 | //============================================================================== | ||
| 460 | /// @defgroup cpp_kodi_tools_StringUtils class StringUtils | ||
| 461 | /// @ingroup cpp_kodi_tools | ||
| 462 | /// @brief **C++ class for processing strings**\n | ||
| 463 | /// This class brings many different functions to edit, check or search texts. | ||
| 464 | /// | ||
| 465 | /// Is intended to reduce any code work of C++ on addons and to have them faster | ||
| 466 | /// to use. | ||
| 467 | /// | ||
| 468 | /// All functions are static within the <b>`kodi::tools::StringUtils`</b> class. | ||
| 469 | /// | ||
| 470 | ///@{ | ||
| 471 | class StringUtils | ||
| 472 | { | ||
| 473 | public: | ||
| 474 | //============================================================================ | ||
| 475 | /// @ingroup cpp_kodi_tools_StringUtils_Defs | ||
| 476 | /// @brief Defines a static empty <b>`std::string`</b>. | ||
| 477 | /// | ||
| 478 | static const std::string Empty; | ||
| 479 | //---------------------------------------------------------------------------- | ||
| 480 | |||
| 481 | //---------------------------------------------------------------------------- | ||
| 482 | /// @defgroup cpp_kodi_tools_StringUtils_FormatControl String format | ||
| 483 | /// @ingroup cpp_kodi_tools_StringUtils | ||
| 484 | /// @brief **Formatting functions**\n | ||
| 485 | /// Used to output the given values in newly formatted text using functions. | ||
| 486 | /// | ||
| 487 | /*!@{*/ | ||
| 488 | |||
| 489 | //============================================================================ | ||
| 490 | /// @brief Returns the C++ string pointed by given format. If format includes | ||
| 491 | /// format specifiers (subsequences beginning with %), the additional arguments | ||
| 492 | /// following format are formatted and inserted in the resulting string replacing | ||
| 493 | /// their respective specifiers. | ||
| 494 | /// | ||
| 495 | /// After the format parameter, the function expects at least as many additional | ||
| 496 | /// arguments as specified by format. | ||
| 497 | /// | ||
| 498 | /// @param[in] fmt The format of the text to process for output. | ||
| 499 | /// C string that contains the text to be written to the stream. | ||
| 500 | /// It can optionally contain embedded format specifiers that are | ||
| 501 | /// replaced by the values specified in subsequent additional | ||
| 502 | /// arguments and formatted as requested. | ||
| 503 | /// | specifier | Output | Example | ||
| 504 | /// |------------|----------------------------------------------------|------------ | ||
| 505 | /// | d or i | Signed decimal integer | 392 | ||
| 506 | /// | u | Unsigned decimal integer | 7235 | ||
| 507 | /// | o | Unsigned octal | 610 | ||
| 508 | /// | x | Unsigned hexadecimal integer | 7fa | ||
| 509 | /// | X | Unsigned hexadecimal integer (uppercase) | 7FA | ||
| 510 | /// | f | Decimal floating point, lowercase | 392.65 | ||
| 511 | /// | F | Decimal floating point, uppercase | 392.65 | ||
| 512 | /// | e | Scientific notation (mantissa/exponent), lowercase | 3.9265e+2 | ||
| 513 | /// | E | Scientific notation (mantissa/exponent), uppercase | 3.9265E+2 | ||
| 514 | /// | g | Use the shortest representation: %e or %f | 392.65 | ||
| 515 | /// | G | Use the shortest representation: %E or %F | 392.65 | ||
| 516 | /// | a | Hexadecimal floating point, lowercase | -0xc.90fep-2 | ||
| 517 | /// | A | Hexadecimal floating point, uppercase | -0XC.90FEP-2 | ||
| 518 | /// | c | Character | a | ||
| 519 | /// | s | String of characters | sample | ||
| 520 | /// | p | Pointer address | b8000000 | ||
| 521 | /// | % | A % followed by another % character will write a single % to the stream. | % | ||
| 522 | /// The length sub-specifier modifies the length of the data type. This is a chart | ||
| 523 | /// showing the types used to interpret the corresponding arguments with and without | ||
| 524 | /// length specifier (if a different type is used, the proper type promotion or | ||
| 525 | /// conversion is performed, if allowed): | ||
| 526 | /// | length| d i | u o x X | f F e E g G a A | c | s | p | n | | ||
| 527 | /// |-------|---------------|-----------------------|-----------------|-------|---------|---------|-----------------| | ||
| 528 | /// | (none)| int | unsigned int | double | int | char* | void* | int* | | ||
| 529 | /// | hh | signed char | unsigned char | | | | | signed char* | | ||
| 530 | /// | h | short int | unsigned short int | | | | | short int* | | ||
| 531 | /// | l | long int | unsigned long int | | wint_t| wchar_t*| | long int* | | ||
| 532 | /// | ll | long long int | unsigned long long int| | | | | long long int* | | ||
| 533 | /// | j | intmax_t | uintmax_t | | | | | intmax_t* | | ||
| 534 | /// | z | size_t | size_t | | | | | size_t* | | ||
| 535 | /// | t | ptrdiff_t | ptrdiff_t | | | | | ptrdiff_t* | | ||
| 536 | /// | L | | | long double | | | | | | ||
| 537 | /// <b>Note:</b> that the c specifier takes an int (or wint_t) as argument, but performs the proper conversion to a char value | ||
| 538 | /// (or a wchar_t) before formatting it for output. | ||
| 539 | /// @param[in] ... <i>(additional arguments)</i>\n | ||
| 540 | /// Depending on the format string, the function may expect a | ||
| 541 | /// sequence of additional arguments, each containing a value | ||
| 542 | /// to be used to replace a format specifier in the format | ||
| 543 | /// string (or a pointer to a storage location, for n).\n | ||
| 544 | /// There should be at least as many of these arguments as the | ||
| 545 | /// number of values specified in the format specifiers. | ||
| 546 | /// Additional arguments are ignored by the function. | ||
| 547 | /// @return Formatted string | ||
| 548 | /// | ||
| 549 | /// | ||
| 550 | /// -------------------------------------------------------------------------- | ||
| 551 | /// Example: | ||
| 552 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 553 | /// #include <kodi/tools/StringUtils.h> | ||
| 554 | /// | ||
| 555 | /// std::string str = kodi::tools::StringUtils::Format("Hello %s %i", "World", 2020); | ||
| 556 | /// ~~~~~~~~~~~~~ | ||
| 557 | /// | ||
| 558 | inline static std::string Format(const char* fmt, ...) | ||
| 559 | { | ||
| 560 | va_list args; | ||
| 561 | va_start(args, fmt); | ||
| 562 | std::string str = FormatV(fmt, args); | ||
| 563 | va_end(args); | ||
| 564 | |||
| 565 | return str; | ||
| 566 | } | ||
| 567 | //---------------------------------------------------------------------------- | ||
| 568 | |||
| 569 | //============================================================================ | ||
| 570 | /// @brief Returns the C++ wide string pointed by given format. | ||
| 571 | /// | ||
| 572 | /// @param[in] fmt The format of the text to process for output | ||
| 573 | /// (see @ref Format(const char* fmt, ...) for details). | ||
| 574 | /// @param[in] ... <i>(additional arguments)</i>\n | ||
| 575 | /// Depending on the format string, the function may expect a | ||
| 576 | /// sequence of additional arguments, each containing a value | ||
| 577 | /// to be used to replace a format specifier in the format | ||
| 578 | /// string (or a pointer to a storage location, for n).\n | ||
| 579 | /// There should be at least as many of these arguments as the | ||
| 580 | /// number of values specified in the format specifiers. | ||
| 581 | /// Additional arguments are ignored by the function. | ||
| 582 | /// @return Formatted string | ||
| 583 | /// | ||
| 584 | inline static std::wstring Format(const wchar_t* fmt, ...) | ||
| 585 | { | ||
| 586 | va_list args; | ||
| 587 | va_start(args, fmt); | ||
| 588 | std::wstring str = FormatV(fmt, args); | ||
| 589 | va_end(args); | ||
| 590 | |||
| 591 | return str; | ||
| 592 | } | ||
| 593 | //---------------------------------------------------------------------------- | ||
| 594 | |||
| 595 | //============================================================================ | ||
| 596 | /// @brief Returns the C++ string pointed by given format list. | ||
| 597 | /// | ||
| 598 | /// @param[in] fmt The format of the text to process for output | ||
| 599 | /// (see @ref Format(const char* fmt, ...) for details). | ||
| 600 | /// @param[in] args A value identifying a variable arguments list initialized | ||
| 601 | /// with `va_start`. | ||
| 602 | /// @return Formatted string | ||
| 603 | /// | ||
| 604 | inline static std::string FormatV(PRINTF_FORMAT_STRING const char* fmt, va_list args) | ||
| 605 | { | ||
| 606 | if (!fmt || !fmt[0]) | ||
| 607 | return ""; | ||
| 608 | |||
| 609 | int size = FORMAT_BLOCK_SIZE; | ||
| 610 | va_list argCopy; | ||
| 611 | |||
| 612 | while (true) | ||
| 613 | { | ||
| 614 | char* cstr = reinterpret_cast<char*>(malloc(sizeof(char) * size)); | ||
| 615 | if (!cstr) | ||
| 616 | return ""; | ||
| 617 | |||
| 618 | va_copy(argCopy, args); | ||
| 619 | int nActual = vsnprintf(cstr, size, fmt, argCopy); | ||
| 620 | va_end(argCopy); | ||
| 621 | |||
| 622 | if (nActual > -1 && nActual < size) // We got a valid result | ||
| 623 | { | ||
| 624 | std::string str(cstr, nActual); | ||
| 625 | free(cstr); | ||
| 626 | return str; | ||
| 627 | } | ||
| 628 | free(cstr); | ||
| 629 | #ifndef TARGET_WINDOWS | ||
| 630 | if (nActual > -1) // Exactly what we will need (glibc 2.1) | ||
| 631 | size = nActual + 1; | ||
| 632 | else // Let's try to double the size (glibc 2.0) | ||
| 633 | size *= 2; | ||
| 634 | #else // TARGET_WINDOWS | ||
| 635 | va_copy(argCopy, args); | ||
| 636 | size = _vscprintf(fmt, argCopy); | ||
| 637 | va_end(argCopy); | ||
| 638 | if (size < 0) | ||
| 639 | return ""; | ||
| 640 | else | ||
| 641 | size++; // increment for null-termination | ||
| 642 | #endif // TARGET_WINDOWS | ||
| 643 | } | ||
| 644 | |||
| 645 | return ""; // unreachable | ||
| 646 | } | ||
| 647 | //---------------------------------------------------------------------------- | ||
| 648 | |||
| 649 | //============================================================================ | ||
| 650 | /// @brief Returns the C++ wide string pointed by given format list. | ||
| 651 | /// | ||
| 652 | /// @param[in] fmt The format of the text to process for output | ||
| 653 | /// (see @ref Format(const char* fmt, ...) for details). | ||
| 654 | /// @param[in] args A value identifying a variable arguments list initialized | ||
| 655 | /// with `va_start`. | ||
| 656 | /// @return Formatted string | ||
| 657 | /// | ||
| 658 | inline static std::wstring FormatV(PRINTF_FORMAT_STRING const wchar_t* fmt, va_list args) | ||
| 659 | { | ||
| 660 | if (!fmt || !fmt[0]) | ||
| 661 | return L""; | ||
| 662 | |||
| 663 | int size = FORMAT_BLOCK_SIZE; | ||
| 664 | va_list argCopy; | ||
| 665 | |||
| 666 | while (true) | ||
| 667 | { | ||
| 668 | wchar_t* cstr = reinterpret_cast<wchar_t*>(malloc(sizeof(wchar_t) * size)); | ||
| 669 | if (!cstr) | ||
| 670 | return L""; | ||
| 671 | |||
| 672 | va_copy(argCopy, args); | ||
| 673 | int nActual = vswprintf(cstr, size, fmt, argCopy); | ||
| 674 | va_end(argCopy); | ||
| 675 | |||
| 676 | if (nActual > -1 && nActual < size) // We got a valid result | ||
| 677 | { | ||
| 678 | std::wstring str(cstr, nActual); | ||
| 679 | free(cstr); | ||
| 680 | return str; | ||
| 681 | } | ||
| 682 | free(cstr); | ||
| 683 | |||
| 684 | #ifndef TARGET_WINDOWS | ||
| 685 | if (nActual > -1) // Exactly what we will need (glibc 2.1) | ||
| 686 | size = nActual + 1; | ||
| 687 | else // Let's try to double the size (glibc 2.0) | ||
| 688 | size *= 2; | ||
| 689 | #else // TARGET_WINDOWS | ||
| 690 | va_copy(argCopy, args); | ||
| 691 | size = _vscwprintf(fmt, argCopy); | ||
| 692 | va_end(argCopy); | ||
| 693 | if (size < 0) | ||
| 694 | return L""; | ||
| 695 | else | ||
| 696 | size++; // increment for null-termination | ||
| 697 | #endif // TARGET_WINDOWS | ||
| 698 | } | ||
| 699 | |||
| 700 | return L""; | ||
| 701 | } | ||
| 702 | //---------------------------------------------------------------------------- | ||
| 703 | |||
| 704 | //============================================================================ | ||
| 705 | /// @brief Returns bytes in a human readable format using the smallest unit | ||
| 706 | /// that will fit `bytes` in at most three digits. The number of decimals are | ||
| 707 | /// adjusted with significance such that 'small' numbers will have more | ||
| 708 | /// decimals than larger ones. | ||
| 709 | /// | ||
| 710 | /// For example: 1024 bytes will be formatted as "1.00kB", 10240 bytes as | ||
| 711 | /// "10.0kB" and 102400 bytes as "100kB". See TestStringUtils for more | ||
| 712 | /// examples. | ||
| 713 | /// | ||
| 714 | /// Supported file sizes: | ||
| 715 | /// | Value | Short | Metric | ||
| 716 | /// |------------|-------|----------- | ||
| 717 | /// | 1 | B | byte | ||
| 718 | /// | 1024¹ | kB | kilobyte | ||
| 719 | /// | 1024² | MB | megabyte | ||
| 720 | /// | 1024³ | GB | gigabyte | ||
| 721 | /// | 1024 exp 4 | TB | terabyte | ||
| 722 | /// | 1024 exp 5 | PB | petabyte | ||
| 723 | /// | 1024 exp 6 | EB | exabyte | ||
| 724 | /// | 1024 exp 7 | ZB | zettabyte | ||
| 725 | /// | 1024 exp 8 | YB | yottabyte | ||
| 726 | /// | ||
| 727 | /// @param[in] bytes Bytes amount to return as human readable string | ||
| 728 | /// @return Size as string | ||
| 729 | /// | ||
| 730 | /// | ||
| 731 | /// -------------------------------------------------------------------------- | ||
| 732 | /// Example: | ||
| 733 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 734 | /// #include <kodi/tools/StringUtils.h> | ||
| 735 | /// | ||
| 736 | /// EXPECT_STREQ("0B", kodi::tools::StringUtils::FormatFileSize(0).c_str()); | ||
| 737 | /// | ||
| 738 | /// EXPECT_STREQ("999B", kodi::tools::StringUtils::FormatFileSize(999).c_str()); | ||
| 739 | /// EXPECT_STREQ("0.98kB", kodi::tools::StringUtils::FormatFileSize(1000).c_str()); | ||
| 740 | /// | ||
| 741 | /// EXPECT_STREQ("1.00kB", kodi::tools::StringUtils::FormatFileSize(1024).c_str()); | ||
| 742 | /// EXPECT_STREQ("9.99kB", kodi::tools::StringUtils::FormatFileSize(10229).c_str()); | ||
| 743 | /// | ||
| 744 | /// EXPECT_STREQ("10.1kB", kodi::tools::StringUtils::FormatFileSize(10387).c_str()); | ||
| 745 | /// EXPECT_STREQ("99.9kB", kodi::tools::StringUtils::FormatFileSize(102297).c_str()); | ||
| 746 | /// | ||
| 747 | /// EXPECT_STREQ("100kB", kodi::tools::StringUtils::FormatFileSize(102400).c_str()); | ||
| 748 | /// EXPECT_STREQ("999kB", kodi::tools::StringUtils::FormatFileSize(1023431).c_str()); | ||
| 749 | /// | ||
| 750 | /// EXPECT_STREQ("0.98MB", kodi::tools::StringUtils::FormatFileSize(1023897).c_str()); | ||
| 751 | /// EXPECT_STREQ("0.98MB", kodi::tools::StringUtils::FormatFileSize(1024000).c_str()); | ||
| 752 | /// | ||
| 753 | /// EXPECT_STREQ("5.30EB", kodi::tools::StringUtils::FormatFileSize(6115888293969133568).c_str()); | ||
| 754 | /// ~~~~~~~~~~~~~ | ||
| 755 | /// | ||
| 756 | inline static std::string FormatFileSize(uint64_t bytes) | ||
| 757 | { | ||
| 758 | const std::array<std::string, 9> units{{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}}; | ||
| 759 | if (bytes < 1000) | ||
| 760 | return Format("%" PRIu64 "B", bytes); | ||
| 761 | |||
| 762 | size_t i = 0; | ||
| 763 | double value = static_cast<double>(bytes); | ||
| 764 | while (i + 1 < units.size() && value >= 999.5) | ||
| 765 | { | ||
| 766 | ++i; | ||
| 767 | value /= 1024.0; | ||
| 768 | } | ||
| 769 | unsigned int decimals = value < 9.995 ? 2 : (value < 99.95 ? 1 : 0); | ||
| 770 | auto frmt = "%." + Format("%u", decimals) + "f%s"; | ||
| 771 | return Format(frmt.c_str(), value, units[i].c_str()); | ||
| 772 | } | ||
| 773 | //---------------------------------------------------------------------------- | ||
| 774 | |||
| 775 | //============================================================================ | ||
| 776 | /// @brief Convert the string of binary chars to the actual string. | ||
| 777 | /// | ||
| 778 | /// Convert the string representation of binary chars to the actual string. | ||
| 779 | /// For example <b>`\1\2\3`</b> is converted to a string with binary char | ||
| 780 | /// <b>`\1`</b>, <b>`\2`</b> and <b>`\3`</b> | ||
| 781 | /// | ||
| 782 | /// @param[in] in String to convert | ||
| 783 | /// @return Converted string | ||
| 784 | /// | ||
| 785 | inline static std::string BinaryStringToString(const std::string& in) | ||
| 786 | { | ||
| 787 | std::string out; | ||
| 788 | out.reserve(in.size() / 2); | ||
| 789 | for (const char *cur = in.c_str(), *end = cur + in.size(); cur != end; ++cur) | ||
| 790 | { | ||
| 791 | if (*cur == '\\') | ||
| 792 | { | ||
| 793 | ++cur; | ||
| 794 | if (cur == end) | ||
| 795 | { | ||
| 796 | break; | ||
| 797 | } | ||
| 798 | if (isdigit(*cur)) | ||
| 799 | { | ||
| 800 | char* end; | ||
| 801 | unsigned long num = strtol(cur, &end, 10); | ||
| 802 | cur = end - 1; | ||
| 803 | out.push_back(static_cast<char>(num)); | ||
| 804 | continue; | ||
| 805 | } | ||
| 806 | } | ||
| 807 | out.push_back(*cur); | ||
| 808 | } | ||
| 809 | return out; | ||
| 810 | } | ||
| 811 | //---------------------------------------------------------------------------- | ||
| 812 | |||
| 813 | //============================================================================ | ||
| 814 | /// @brief Convert each character in the string to its hexadecimal | ||
| 815 | /// representation and return the concatenated result | ||
| 816 | /// | ||
| 817 | /// Example: "abc\n" -> "6162630a" | ||
| 818 | /// | ||
| 819 | /// @param[in] in String to convert | ||
| 820 | /// @return Converted string | ||
| 821 | /// | ||
| 822 | /// | ||
| 823 | /// -------------------------------------------------------------------------- | ||
| 824 | /// Example: | ||
| 825 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 826 | /// #include <kodi/tools/StringUtils.h> | ||
| 827 | /// | ||
| 828 | /// EXPECT_STREQ("", kodi::tools::StringUtils::ToHexadecimal("").c_str()); | ||
| 829 | /// EXPECT_STREQ("616263", kodi::tools::StringUtils::ToHexadecimal("abc").c_str()); | ||
| 830 | /// std::string a{"a\0b\n", 4}; | ||
| 831 | /// EXPECT_STREQ("6100620a", kodi::tools::StringUtils::ToHexadecimal(a).c_str()); | ||
| 832 | /// std::string nul{"\0", 1}; | ||
| 833 | /// EXPECT_STREQ("00", kodi::tools::StringUtils::ToHexadecimal(nul).c_str()); | ||
| 834 | /// std::string ff{"\xFF", 1}; | ||
| 835 | /// EXPECT_STREQ("ff", kodi::tools::StringUtils::ToHexadecimal(ff).c_str()); | ||
| 836 | /// ~~~~~~~~~~~~~ | ||
| 837 | /// | ||
| 838 | inline static std::string ToHexadecimal(const std::string& in) | ||
| 839 | { | ||
| 840 | std::ostringstream ss; | ||
| 841 | ss << std::hex; | ||
| 842 | for (unsigned char ch : in) | ||
| 843 | { | ||
| 844 | ss << std::setw(2) << std::setfill('0') << static_cast<unsigned long>(ch); | ||
| 845 | } | ||
| 846 | return ss.str(); | ||
| 847 | } | ||
| 848 | //---------------------------------------------------------------------------- | ||
| 849 | |||
| 850 | /*!@}*/ | ||
| 851 | |||
| 852 | //---------------------------------------------------------------------------- | ||
| 853 | /// @defgroup cpp_kodi_tools_StringUtils_EditControl String edit | ||
| 854 | /// @ingroup cpp_kodi_tools_StringUtils | ||
| 855 | /// @brief **Edits given texts**\n | ||
| 856 | /// This is used to revise the respective strings and to get them in the desired format. | ||
| 857 | /// | ||
| 858 | /*!@{*/ | ||
| 859 | |||
| 860 | //============================================================================ | ||
| 861 | /// @brief Convert a string to uppercase. | ||
| 862 | /// | ||
| 863 | /// @param[in,out] str String to convert | ||
| 864 | /// | ||
| 865 | /// | ||
| 866 | /// -------------------------------------------------------------------------- | ||
| 867 | /// Example: | ||
| 868 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 869 | /// #include <kodi/tools/StringUtils.h> | ||
| 870 | /// | ||
| 871 | /// std::string refstr = "TEST"; | ||
| 872 | /// | ||
| 873 | /// std::string varstr = "TeSt"; | ||
| 874 | /// kodi::tools::StringUtils::ToUpper(varstr); | ||
| 875 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 876 | /// ~~~~~~~~~~~~~ | ||
| 877 | /// | ||
| 878 | inline static void ToUpper(std::string& str) | ||
| 879 | { | ||
| 880 | std::transform(str.begin(), str.end(), str.begin(), ::toupper); | ||
| 881 | } | ||
| 882 | //---------------------------------------------------------------------------- | ||
| 883 | |||
| 884 | //============================================================================ | ||
| 885 | /// @brief Convert a 16bit wide string to uppercase. | ||
| 886 | /// | ||
| 887 | /// @param[in,out] str String to convert | ||
| 888 | /// | ||
| 889 | inline static void ToUpper(std::wstring& str) | ||
| 890 | { | ||
| 891 | transform(str.begin(), str.end(), str.begin(), toupperUnicode); | ||
| 892 | } | ||
| 893 | //---------------------------------------------------------------------------- | ||
| 894 | |||
| 895 | //============================================================================ | ||
| 896 | /// @brief Convert a string to lowercase. | ||
| 897 | /// | ||
| 898 | /// @param[in,out] str String to convert | ||
| 899 | /// | ||
| 900 | /// | ||
| 901 | /// -------------------------------------------------------------------------- | ||
| 902 | /// Example: | ||
| 903 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 904 | /// #include <kodi/tools/StringUtils.h> | ||
| 905 | /// | ||
| 906 | /// std::string refstr = "test"; | ||
| 907 | /// | ||
| 908 | /// std::string varstr = "TeSt"; | ||
| 909 | /// kodi::tools::StringUtils::ToLower(varstr); | ||
| 910 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 911 | /// ~~~~~~~~~~~~~ | ||
| 912 | /// | ||
| 913 | inline static void ToLower(std::string& str) | ||
| 914 | { | ||
| 915 | transform(str.begin(), str.end(), str.begin(), ::tolower); | ||
| 916 | } | ||
| 917 | //---------------------------------------------------------------------------- | ||
| 918 | |||
| 919 | //============================================================================ | ||
| 920 | /// @brief Convert a 16bit wide string to lowercase. | ||
| 921 | /// | ||
| 922 | /// @param[in,out] str String to convert | ||
| 923 | /// | ||
| 924 | inline static void ToLower(std::wstring& str) | ||
| 925 | { | ||
| 926 | transform(str.begin(), str.end(), str.begin(), tolowerUnicode); | ||
| 927 | } | ||
| 928 | //---------------------------------------------------------------------------- | ||
| 929 | |||
| 930 | //============================================================================ | ||
| 931 | /// @brief Combine all numerical digits and give it as integer value. | ||
| 932 | /// | ||
| 933 | /// @param[in,out] str String to check for digits | ||
| 934 | /// @return All numerical digits fit together as integer value | ||
| 935 | /// | ||
| 936 | inline static int ReturnDigits(const std::string& str) | ||
| 937 | { | ||
| 938 | std::stringstream ss; | ||
| 939 | for (const auto& character : str) | ||
| 940 | { | ||
| 941 | if (isdigit(character)) | ||
| 942 | ss << character; | ||
| 943 | } | ||
| 944 | return atoi(ss.str().c_str()); | ||
| 945 | } | ||
| 946 | //---------------------------------------------------------------------------- | ||
| 947 | |||
| 948 | //============================================================================ | ||
| 949 | /// @brief Returns a string from start with givent count. | ||
| 950 | /// | ||
| 951 | /// @param[in] str String to use | ||
| 952 | /// @param[in] count Amount of characters to go from left | ||
| 953 | /// @return The left part string in amount of given count or complete if it | ||
| 954 | /// was higher. | ||
| 955 | /// | ||
| 956 | /// | ||
| 957 | /// -------------------------------------------------------------------------- | ||
| 958 | /// Example: | ||
| 959 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 960 | /// #include <kodi/tools/StringUtils.h> | ||
| 961 | /// | ||
| 962 | /// std::string refstr, varstr; | ||
| 963 | /// std::string origstr = "test"; | ||
| 964 | /// | ||
| 965 | /// refstr = ""; | ||
| 966 | /// varstr = kodi::tools::StringUtils::Left(origstr, 0); | ||
| 967 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 968 | /// | ||
| 969 | /// refstr = "te"; | ||
| 970 | /// varstr = kodi::tools::StringUtils::Left(origstr, 2); | ||
| 971 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 972 | /// | ||
| 973 | /// refstr = "test"; | ||
| 974 | /// varstr = kodi::tools::StringUtils::Left(origstr, 10); | ||
| 975 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 976 | /// ~~~~~~~~~~~~~ | ||
| 977 | /// | ||
| 978 | inline static std::string Left(const std::string& str, size_t count) | ||
| 979 | { | ||
| 980 | count = std::max((size_t)0, std::min(count, str.size())); | ||
| 981 | return str.substr(0, count); | ||
| 982 | } | ||
| 983 | //---------------------------------------------------------------------------- | ||
| 984 | |||
| 985 | //============================================================================ | ||
| 986 | /// @brief Get substring from mid of given string. | ||
| 987 | /// | ||
| 988 | /// @param[in] str String to get substring from | ||
| 989 | /// @param[in] first Position from where to start | ||
| 990 | /// @param[in] count [opt] length of position to get after start, default is | ||
| 991 | /// complete to end | ||
| 992 | /// @return The substring taken from middle of input string | ||
| 993 | /// | ||
| 994 | /// | ||
| 995 | /// -------------------------------------------------------------------------- | ||
| 996 | /// Example: | ||
| 997 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 998 | /// #include <kodi/tools/StringUtils.h> | ||
| 999 | /// | ||
| 1000 | /// std::string refstr, varstr; | ||
| 1001 | /// std::string origstr = "test"; | ||
| 1002 | /// | ||
| 1003 | /// refstr = ""; | ||
| 1004 | /// varstr = kodi::tools::StringUtils::Mid(origstr, 0, 0); | ||
| 1005 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1006 | /// | ||
| 1007 | /// refstr = "te"; | ||
| 1008 | /// varstr = kodi::tools::StringUtils::Mid(origstr, 0, 2); | ||
| 1009 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1010 | /// | ||
| 1011 | /// refstr = "test"; | ||
| 1012 | /// varstr = kodi::tools::StringUtils::Mid(origstr, 0, 10); | ||
| 1013 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1014 | /// | ||
| 1015 | /// refstr = "st"; | ||
| 1016 | /// varstr = kodi::tools::StringUtils::Mid(origstr, 2); | ||
| 1017 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1018 | /// | ||
| 1019 | /// refstr = "st"; | ||
| 1020 | /// varstr = kodi::tools::StringUtils::Mid(origstr, 2, 2); | ||
| 1021 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1022 | /// | ||
| 1023 | /// refstr = "es"; | ||
| 1024 | /// varstr = kodi::tools::StringUtils::Mid(origstr, 1, 2); | ||
| 1025 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1026 | /// ~~~~~~~~~~~~~ | ||
| 1027 | /// | ||
| 1028 | inline static std::string Mid(const std::string& str, | ||
| 1029 | size_t first, | ||
| 1030 | size_t count = std::string::npos) | ||
| 1031 | { | ||
| 1032 | if (first + count > str.size()) | ||
| 1033 | count = str.size() - first; | ||
| 1034 | |||
| 1035 | if (first > str.size()) | ||
| 1036 | return std::string(); | ||
| 1037 | |||
| 1038 | assert(first + count <= str.size()); | ||
| 1039 | |||
| 1040 | return str.substr(first, count); | ||
| 1041 | } | ||
| 1042 | //---------------------------------------------------------------------------- | ||
| 1043 | |||
| 1044 | //============================================================================ | ||
| 1045 | /// @brief Returns a string from end with givent count. | ||
| 1046 | /// | ||
| 1047 | /// @param[in] str String to use | ||
| 1048 | /// @param[in] count Amount of characters to go from right | ||
| 1049 | /// @return The right part string in amount of given count or complete if it | ||
| 1050 | /// was higher. | ||
| 1051 | /// | ||
| 1052 | /// | ||
| 1053 | /// -------------------------------------------------------------------------- | ||
| 1054 | /// Example: | ||
| 1055 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1056 | /// #include <kodi/tools/StringUtils.h> | ||
| 1057 | /// | ||
| 1058 | /// std::string refstr, varstr; | ||
| 1059 | /// std::string origstr = "test"; | ||
| 1060 | /// | ||
| 1061 | /// refstr = ""; | ||
| 1062 | /// varstr = kodi::tools::StringUtils::Right(origstr, 0); | ||
| 1063 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1064 | /// | ||
| 1065 | /// refstr = "st"; | ||
| 1066 | /// varstr = kodi::tools::StringUtils::Right(origstr, 2); | ||
| 1067 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1068 | /// | ||
| 1069 | /// refstr = "test"; | ||
| 1070 | /// varstr = kodi::tools::StringUtils::Right(origstr, 10); | ||
| 1071 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1072 | /// ~~~~~~~~~~~~~ | ||
| 1073 | /// | ||
| 1074 | inline static std::string Right(const std::string& str, size_t count) | ||
| 1075 | { | ||
| 1076 | count = std::max((size_t)0, std::min(count, str.size())); | ||
| 1077 | return str.substr(str.size() - count); | ||
| 1078 | } | ||
| 1079 | //---------------------------------------------------------------------------- | ||
| 1080 | |||
| 1081 | //============================================================================ | ||
| 1082 | /// @brief Trim a string with remove of not wanted spaces at begin and end | ||
| 1083 | /// of string. | ||
| 1084 | /// | ||
| 1085 | /// @param[in,out] str String to trim, becomes also changed and given on | ||
| 1086 | /// return | ||
| 1087 | /// @return The changed string | ||
| 1088 | /// | ||
| 1089 | /// | ||
| 1090 | /// -------------------------------------------------------------------------- | ||
| 1091 | /// Example: | ||
| 1092 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1093 | /// #include <kodi/tools/StringUtils.h> | ||
| 1094 | /// | ||
| 1095 | /// std::string refstr = "test test"; | ||
| 1096 | /// | ||
| 1097 | /// std::string varstr = " test test "; | ||
| 1098 | /// kodi::tools::StringUtils::Trim(varstr); | ||
| 1099 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1100 | /// ~~~~~~~~~~~~~ | ||
| 1101 | /// | ||
| 1102 | inline static std::string& Trim(std::string& str) | ||
| 1103 | { | ||
| 1104 | TrimLeft(str); | ||
| 1105 | return TrimRight(str); | ||
| 1106 | } | ||
| 1107 | //---------------------------------------------------------------------------- | ||
| 1108 | |||
| 1109 | //============================================================================ | ||
| 1110 | /// @brief Trim a string with remove of not wanted characters at begin and end | ||
| 1111 | /// of string. | ||
| 1112 | /// | ||
| 1113 | /// @param[in,out] str String to trim, becomes also changed and given on | ||
| 1114 | /// return | ||
| 1115 | /// @param[in] chars Characters to use for trim | ||
| 1116 | /// @return The changed string | ||
| 1117 | /// | ||
| 1118 | inline static std::string& Trim(std::string& str, const char* const chars) | ||
| 1119 | { | ||
| 1120 | TrimLeft(str, chars); | ||
| 1121 | return TrimRight(str, chars); | ||
| 1122 | } | ||
| 1123 | //---------------------------------------------------------------------------- | ||
| 1124 | |||
| 1125 | //============================================================================ | ||
| 1126 | /// @brief Trim a string with remove of not wanted spaces at begin of string. | ||
| 1127 | /// | ||
| 1128 | /// @param[in,out] str String to trim, becomes also changed and given on | ||
| 1129 | /// return | ||
| 1130 | /// @return The changed string | ||
| 1131 | /// | ||
| 1132 | /// | ||
| 1133 | /// -------------------------------------------------------------------------- | ||
| 1134 | /// Example: | ||
| 1135 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1136 | /// #include <kodi/tools/StringUtils.h> | ||
| 1137 | /// | ||
| 1138 | /// std::string refstr = "test test "; | ||
| 1139 | /// | ||
| 1140 | /// std::string varstr = " test test "; | ||
| 1141 | /// kodi::tools::StringUtils::TrimLeft(varstr); | ||
| 1142 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1143 | /// ~~~~~~~~~~~~~ | ||
| 1144 | /// | ||
| 1145 | inline static std::string& TrimLeft(std::string& str) | ||
| 1146 | { | ||
| 1147 | str.erase(str.begin(), | ||
| 1148 | std::find_if(str.begin(), str.end(), [](char s) { return IsSpace(s) == 0; })); | ||
| 1149 | return str; | ||
| 1150 | } | ||
| 1151 | //---------------------------------------------------------------------------- | ||
| 1152 | |||
| 1153 | //============================================================================ | ||
| 1154 | /// @brief Trim a string with remove of not wanted characters at begin of | ||
| 1155 | /// string. | ||
| 1156 | /// | ||
| 1157 | /// @param[in,out] str String to trim, becomes also changed and given on | ||
| 1158 | /// return | ||
| 1159 | /// @param[in] chars Characters to use for trim | ||
| 1160 | /// @return The changed string | ||
| 1161 | /// | ||
| 1162 | inline static std::string& TrimLeft(std::string& str, const char* const chars) | ||
| 1163 | { | ||
| 1164 | size_t nidx = str.find_first_not_of(chars); | ||
| 1165 | str.erase(0, nidx); | ||
| 1166 | return str; | ||
| 1167 | } | ||
| 1168 | //---------------------------------------------------------------------------- | ||
| 1169 | |||
| 1170 | //============================================================================ | ||
| 1171 | /// @brief Trim a string with remove of not wanted spaces at end of string. | ||
| 1172 | /// | ||
| 1173 | /// @param[in,out] str String to trim, becomes also changed and given on | ||
| 1174 | /// return | ||
| 1175 | /// @return The changed string | ||
| 1176 | /// | ||
| 1177 | /// | ||
| 1178 | /// -------------------------------------------------------------------------- | ||
| 1179 | /// Example: | ||
| 1180 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1181 | /// #include <kodi/tools/StringUtils.h> | ||
| 1182 | /// | ||
| 1183 | /// std::string refstr = " test test"; | ||
| 1184 | /// | ||
| 1185 | /// std::string varstr = " test test "; | ||
| 1186 | /// kodi::tools::StringUtils::TrimRight(varstr); | ||
| 1187 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1188 | /// ~~~~~~~~~~~~~ | ||
| 1189 | /// | ||
| 1190 | inline static std::string& TrimRight(std::string& str) | ||
| 1191 | { | ||
| 1192 | str.erase(std::find_if(str.rbegin(), str.rend(), [](char s) { return IsSpace(s) == 0; }).base(), | ||
| 1193 | str.end()); | ||
| 1194 | return str; | ||
| 1195 | } | ||
| 1196 | //---------------------------------------------------------------------------- | ||
| 1197 | |||
| 1198 | //============================================================================ | ||
| 1199 | /// @brief Trim a string with remove of not wanted characters at end of | ||
| 1200 | /// string. | ||
| 1201 | /// | ||
| 1202 | /// @param[in,out] str String to trim, becomes also changed and given on | ||
| 1203 | /// return | ||
| 1204 | /// @param[in] chars Characters to use for trim | ||
| 1205 | /// @return The changed string | ||
| 1206 | /// | ||
| 1207 | inline static std::string& TrimRight(std::string& str, const char* const chars) | ||
| 1208 | { | ||
| 1209 | size_t nidx = str.find_last_not_of(chars); | ||
| 1210 | str.erase(str.npos == nidx ? 0 : ++nidx); | ||
| 1211 | return str; | ||
| 1212 | } | ||
| 1213 | //---------------------------------------------------------------------------- | ||
| 1214 | |||
| 1215 | //============================================================================ | ||
| 1216 | /// @brief Cleanup string by remove of duplicates of spaces and tabs. | ||
| 1217 | /// | ||
| 1218 | /// @param[in,out] str String to remove duplicates, becomes also changed and | ||
| 1219 | /// given further on return | ||
| 1220 | /// @return The changed string | ||
| 1221 | /// | ||
| 1222 | inline static std::string& RemoveDuplicatedSpacesAndTabs(std::string& str) | ||
| 1223 | { | ||
| 1224 | std::string::iterator it = str.begin(); | ||
| 1225 | bool onSpace = false; | ||
| 1226 | while (it != str.end()) | ||
| 1227 | { | ||
| 1228 | if (*it == '\t') | ||
| 1229 | *it = ' '; | ||
| 1230 | |||
| 1231 | if (*it == ' ') | ||
| 1232 | { | ||
| 1233 | if (onSpace) | ||
| 1234 | { | ||
| 1235 | it = str.erase(it); | ||
| 1236 | continue; | ||
| 1237 | } | ||
| 1238 | else | ||
| 1239 | onSpace = true; | ||
| 1240 | } | ||
| 1241 | else | ||
| 1242 | onSpace = false; | ||
| 1243 | |||
| 1244 | ++it; | ||
| 1245 | } | ||
| 1246 | return str; | ||
| 1247 | } | ||
| 1248 | //---------------------------------------------------------------------------- | ||
| 1249 | |||
| 1250 | //============================================================================ | ||
| 1251 | /// @brief Replace a character with another inside text string. | ||
| 1252 | /// | ||
| 1253 | /// @param[in] str String to replace within | ||
| 1254 | /// @param[in] oldChar Character to search for replacement | ||
| 1255 | /// @param[in] newChar New character to use for replacement | ||
| 1256 | /// @return Amount of replaced characters | ||
| 1257 | /// | ||
| 1258 | /// | ||
| 1259 | /// -------------------------------------------------------------------------- | ||
| 1260 | /// Example: | ||
| 1261 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1262 | /// #include <kodi/tools/StringUtils.h> | ||
| 1263 | /// | ||
| 1264 | /// std::string refstr = "text text"; | ||
| 1265 | /// | ||
| 1266 | /// std::string varstr = "test test"; | ||
| 1267 | /// EXPECT_EQ(kodi::tools::StringUtils::Replace(varstr, 's', 'x'), 2); | ||
| 1268 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1269 | /// | ||
| 1270 | /// EXPECT_EQ(kodi::tools::StringUtils::Replace(varstr, 's', 'x'), 0); | ||
| 1271 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1272 | /// ~~~~~~~~~~~~~ | ||
| 1273 | /// | ||
| 1274 | inline static int Replace(std::string& str, char oldChar, char newChar) | ||
| 1275 | { | ||
| 1276 | int replacedChars = 0; | ||
| 1277 | for (std::string::iterator it = str.begin(); it != str.end(); ++it) | ||
| 1278 | { | ||
| 1279 | if (*it == oldChar) | ||
| 1280 | { | ||
| 1281 | *it = newChar; | ||
| 1282 | replacedChars++; | ||
| 1283 | } | ||
| 1284 | } | ||
| 1285 | |||
| 1286 | return replacedChars; | ||
| 1287 | } | ||
| 1288 | //---------------------------------------------------------------------------- | ||
| 1289 | |||
| 1290 | //============================================================================ | ||
| 1291 | /// @brief Replace a complete text with another inside text string. | ||
| 1292 | /// | ||
| 1293 | /// @param[in] str String to replace within | ||
| 1294 | /// @param[in] oldStr String to search for replacement | ||
| 1295 | /// @param[in] newStr New string to use for replacement | ||
| 1296 | /// @return Amount of replaced text fields | ||
| 1297 | /// | ||
| 1298 | /// | ||
| 1299 | /// -------------------------------------------------------------------------- | ||
| 1300 | /// Example: | ||
| 1301 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1302 | /// #include <kodi/tools/StringUtils.h> | ||
| 1303 | /// | ||
| 1304 | /// std::string refstr = "text text"; | ||
| 1305 | /// | ||
| 1306 | /// std::string varstr = "test test"; | ||
| 1307 | /// EXPECT_EQ(kodi::tools::StringUtils::Replace(varstr, "s", "x"), 2); | ||
| 1308 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1309 | /// | ||
| 1310 | /// EXPECT_EQ(kodi::tools::StringUtils::Replace(varstr, "s", "x"), 0); | ||
| 1311 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1312 | /// ~~~~~~~~~~~~~ | ||
| 1313 | /// | ||
| 1314 | inline static int Replace(std::string& str, const std::string& oldStr, const std::string& newStr) | ||
| 1315 | { | ||
| 1316 | if (oldStr.empty()) | ||
| 1317 | return 0; | ||
| 1318 | |||
| 1319 | int replacedChars = 0; | ||
| 1320 | size_t index = 0; | ||
| 1321 | |||
| 1322 | while (index < str.size() && (index = str.find(oldStr, index)) != std::string::npos) | ||
| 1323 | { | ||
| 1324 | str.replace(index, oldStr.size(), newStr); | ||
| 1325 | index += newStr.size(); | ||
| 1326 | replacedChars++; | ||
| 1327 | } | ||
| 1328 | |||
| 1329 | return replacedChars; | ||
| 1330 | } | ||
| 1331 | //---------------------------------------------------------------------------- | ||
| 1332 | |||
| 1333 | //============================================================================ | ||
| 1334 | /// @brief Replace a complete text with another inside 16bit wide text string. | ||
| 1335 | /// | ||
| 1336 | /// @param[in] str String to replace within | ||
| 1337 | /// @param[in] oldStr String to search for replacement | ||
| 1338 | /// @param[in] newStr New string to use for replacement | ||
| 1339 | /// @return Amount of replaced text fields | ||
| 1340 | /// | ||
| 1341 | inline static int Replace(std::wstring& str, | ||
| 1342 | const std::wstring& oldStr, | ||
| 1343 | const std::wstring& newStr) | ||
| 1344 | { | ||
| 1345 | if (oldStr.empty()) | ||
| 1346 | return 0; | ||
| 1347 | |||
| 1348 | int replacedChars = 0; | ||
| 1349 | size_t index = 0; | ||
| 1350 | |||
| 1351 | while (index < str.size() && (index = str.find(oldStr, index)) != std::string::npos) | ||
| 1352 | { | ||
| 1353 | str.replace(index, oldStr.size(), newStr); | ||
| 1354 | index += newStr.size(); | ||
| 1355 | replacedChars++; | ||
| 1356 | } | ||
| 1357 | |||
| 1358 | return replacedChars; | ||
| 1359 | } | ||
| 1360 | //---------------------------------------------------------------------------- | ||
| 1361 | |||
| 1362 | //============================================================================ | ||
| 1363 | /// @brief Transform characters to create a safe URL. | ||
| 1364 | /// | ||
| 1365 | /// @param[in] str The string to transform | ||
| 1366 | /// @return The transformed string, with unsafe characters replaced by "_" | ||
| 1367 | /// | ||
| 1368 | /// Safe URLs are composed of the unreserved characters defined in | ||
| 1369 | /// RFC 3986 section 2.3: | ||
| 1370 | /// | ||
| 1371 | /// ALPHA / DIGIT / "-" / "." / "_" / "~" | ||
| 1372 | /// | ||
| 1373 | /// Characters outside of this set will be replaced by "_". | ||
| 1374 | /// | ||
| 1375 | inline static std::string MakeSafeUrl(const std::string& str) | ||
| 1376 | { | ||
| 1377 | std::string safeUrl; | ||
| 1378 | |||
| 1379 | safeUrl.reserve(str.size()); | ||
| 1380 | |||
| 1381 | std::transform(str.begin(), str.end(), std::back_inserter(safeUrl), [](char c) { | ||
| 1382 | if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '-' || | ||
| 1383 | c == '.' || c == '_' || c == '~') | ||
| 1384 | { | ||
| 1385 | return c; | ||
| 1386 | } | ||
| 1387 | return '_'; | ||
| 1388 | }); | ||
| 1389 | |||
| 1390 | return safeUrl; | ||
| 1391 | } | ||
| 1392 | //---------------------------------------------------------------------------- | ||
| 1393 | |||
| 1394 | //============================================================================ | ||
| 1395 | /// @brief Transform characters to create a safe, printable string. | ||
| 1396 | /// | ||
| 1397 | /// @param[in] str The string to transform | ||
| 1398 | /// @return The transformed string, with unsafe characters replaced by " " | ||
| 1399 | /// | ||
| 1400 | /// Unsafe characters are defined as the non-printable ASCII characters | ||
| 1401 | /// (character code 0-31). | ||
| 1402 | /// | ||
| 1403 | inline static std::string MakeSafeString(const std::string& str) | ||
| 1404 | { | ||
| 1405 | std::string safeString; | ||
| 1406 | |||
| 1407 | safeString.reserve(str.size()); | ||
| 1408 | |||
| 1409 | std::transform(str.begin(), str.end(), std::back_inserter(safeString), [](char c) { | ||
| 1410 | if (c < 0x20) | ||
| 1411 | return ' '; | ||
| 1412 | |||
| 1413 | return c; | ||
| 1414 | }); | ||
| 1415 | |||
| 1416 | return safeString; | ||
| 1417 | } | ||
| 1418 | //---------------------------------------------------------------------------- | ||
| 1419 | |||
| 1420 | //============================================================================ | ||
| 1421 | /// @brief Removes a MAC address from a given string. | ||
| 1422 | /// | ||
| 1423 | /// @param[in] str The string containing a MAC address | ||
| 1424 | /// @return The string without the MAC address (for chaining) | ||
| 1425 | /// | ||
| 1426 | inline static std::string RemoveMACAddress(const std::string& str) | ||
| 1427 | { | ||
| 1428 | std::regex re(R"mac([\(\[]?([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})[\)\]]?)mac"); | ||
| 1429 | return std::regex_replace(str, re, "", std::regex_constants::format_default); | ||
| 1430 | } | ||
| 1431 | //---------------------------------------------------------------------------- | ||
| 1432 | |||
| 1433 | //============================================================================ | ||
| 1434 | /// @brief Remove carriage return and line feeds on string ends. | ||
| 1435 | /// | ||
| 1436 | /// @param[in,out] str String where CR and LF becomes removed on end | ||
| 1437 | /// | ||
| 1438 | /// | ||
| 1439 | /// -------------------------------------------------------------------------- | ||
| 1440 | /// Example: | ||
| 1441 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1442 | /// #include <kodi/tools/StringUtils.h> | ||
| 1443 | /// | ||
| 1444 | /// std::string refstr, varstr; | ||
| 1445 | /// | ||
| 1446 | /// refstr = "test\r\nstring\nblah blah"; | ||
| 1447 | /// varstr = "test\r\nstring\nblah blah\n"; | ||
| 1448 | /// kodi::tools::StringUtils::RemoveCRLF(varstr); | ||
| 1449 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 1450 | /// ~~~~~~~~~~~~~ | ||
| 1451 | /// | ||
| 1452 | inline static void RemoveCRLF(std::string& strLine) { StringUtils::TrimRight(strLine, "\n\r"); } | ||
| 1453 | //---------------------------------------------------------------------------- | ||
| 1454 | |||
| 1455 | //============================================================================ | ||
| 1456 | /// @brief Convert a word to a digit numerical string | ||
| 1457 | /// | ||
| 1458 | /// @param[in] str String to convert | ||
| 1459 | /// | ||
| 1460 | /// | ||
| 1461 | /// -------------------------------------------------------------------------- | ||
| 1462 | /// Example: | ||
| 1463 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1464 | /// std::string ref, var; | ||
| 1465 | /// | ||
| 1466 | /// ref = "8378 787464"; | ||
| 1467 | /// var = "test string"; | ||
| 1468 | /// kodi::tools::StringUtils::WordToDigits(var); | ||
| 1469 | /// EXPECT_STREQ(ref.c_str(), var.c_str()); | ||
| 1470 | /// ~~~~~~~~~~~~~ | ||
| 1471 | /// | ||
| 1472 | inline static void WordToDigits(std::string& word) | ||
| 1473 | { | ||
| 1474 | static const char word_to_letter[] = "22233344455566677778889999"; | ||
| 1475 | StringUtils::ToLower(word); | ||
| 1476 | for (unsigned int i = 0; i < word.size(); ++i) | ||
| 1477 | { // NB: This assumes ascii, which probably needs extending at some point. | ||
| 1478 | char letter = word[i]; | ||
| 1479 | if ((letter >= 'a' && letter <= 'z')) // assume contiguous letter range | ||
| 1480 | { | ||
| 1481 | word[i] = word_to_letter[letter - 'a']; | ||
| 1482 | } | ||
| 1483 | else if (letter < '0' || letter > '9') // We want to keep 0-9! | ||
| 1484 | { | ||
| 1485 | word[i] = ' '; // replace everything else with a space | ||
| 1486 | } | ||
| 1487 | } | ||
| 1488 | } | ||
| 1489 | //---------------------------------------------------------------------------- | ||
| 1490 | |||
| 1491 | //============================================================================ | ||
| 1492 | /// @brief Escapes the given string to be able to be used as a parameter. | ||
| 1493 | /// | ||
| 1494 | /// Escapes backslashes and double-quotes with an additional backslash and | ||
| 1495 | /// adds double-quotes around the whole string. | ||
| 1496 | /// | ||
| 1497 | /// @param[in] param String to escape/paramify | ||
| 1498 | /// @return Escaped/Paramified string | ||
| 1499 | /// | ||
| 1500 | /// | ||
| 1501 | /// -------------------------------------------------------------------------- | ||
| 1502 | /// Example: | ||
| 1503 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1504 | /// const char *input = "some, very \\ odd \"string\""; | ||
| 1505 | /// const char *ref = "\"some, very \\\\ odd \\\"string\\\"\""; | ||
| 1506 | /// | ||
| 1507 | /// std::string result = kodi::tools::StringUtils::Paramify(input); | ||
| 1508 | /// EXPECT_STREQ(ref, result.c_str()); | ||
| 1509 | /// ~~~~~~~~~~~~~ | ||
| 1510 | /// | ||
| 1511 | inline static std::string Paramify(const std::string& param) | ||
| 1512 | { | ||
| 1513 | std::string result = param; | ||
| 1514 | // escape backspaces | ||
| 1515 | StringUtils::Replace(result, "\\", "\\\\"); | ||
| 1516 | // escape double quotes | ||
| 1517 | StringUtils::Replace(result, "\"", "\\\""); | ||
| 1518 | |||
| 1519 | // add double quotes around the whole string | ||
| 1520 | return "\"" + result + "\""; | ||
| 1521 | } | ||
| 1522 | //---------------------------------------------------------------------------- | ||
| 1523 | |||
| 1524 | /*!@}*/ | ||
| 1525 | |||
| 1526 | //---------------------------------------------------------------------------- | ||
| 1527 | /// @defgroup cpp_kodi_tools_StringUtils_CompareControl String compare | ||
| 1528 | /// @ingroup cpp_kodi_tools_StringUtils | ||
| 1529 | /// @brief **Check strings for the desired state**\n | ||
| 1530 | /// With this, texts can be checked to see that they correspond to a required | ||
| 1531 | /// format. | ||
| 1532 | /// | ||
| 1533 | /*!@{*/ | ||
| 1534 | |||
| 1535 | //============================================================================ | ||
| 1536 | /// @brief Compare two strings with ignore of lower-/uppercase. | ||
| 1537 | /// | ||
| 1538 | /// @param[in] str1 C++ string to compare | ||
| 1539 | /// @param[in] str2 C++ string to compare | ||
| 1540 | /// @return True if the strings are equal, false otherwise | ||
| 1541 | /// | ||
| 1542 | /// | ||
| 1543 | /// -------------------------------------------------------------------------- | ||
| 1544 | /// Example: | ||
| 1545 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1546 | /// #include <kodi/tools/StringUtils.h> | ||
| 1547 | /// | ||
| 1548 | /// std::string refstr = "TeSt"; | ||
| 1549 | /// | ||
| 1550 | /// EXPECT_TRUE(kodi::tools::StringUtils::EqualsNoCase(refstr, "TeSt")); | ||
| 1551 | /// EXPECT_TRUE(kodi::tools::StringUtils::EqualsNoCase(refstr, "tEsT")); | ||
| 1552 | /// ~~~~~~~~~~~~~ | ||
| 1553 | /// | ||
| 1554 | inline static bool EqualsNoCase(const std::string& str1, const std::string& str2) | ||
| 1555 | { | ||
| 1556 | // before we do the char-by-char comparison, first compare sizes of both strings. | ||
| 1557 | // This led to a 33% improvement in benchmarking on average. (size() just returns a member of std::string) | ||
| 1558 | if (str1.size() != str2.size()) | ||
| 1559 | return false; | ||
| 1560 | return EqualsNoCase(str1.c_str(), str2.c_str()); | ||
| 1561 | } | ||
| 1562 | //---------------------------------------------------------------------------- | ||
| 1563 | |||
| 1564 | //============================================================================ | ||
| 1565 | /// @brief Compare two strings with ignore of lower-/uppercase. | ||
| 1566 | /// | ||
| 1567 | /// @param[in] str1 C++ string to compare | ||
| 1568 | /// @param[in] s2 C string to compare | ||
| 1569 | /// @return True if the strings are equal, false otherwise | ||
| 1570 | /// | ||
| 1571 | inline static bool EqualsNoCase(const std::string& str1, const char* s2) | ||
| 1572 | { | ||
| 1573 | return EqualsNoCase(str1.c_str(), s2); | ||
| 1574 | } | ||
| 1575 | //---------------------------------------------------------------------------- | ||
| 1576 | |||
| 1577 | //============================================================================ | ||
| 1578 | /// @brief Compare two strings with ignore of lower-/uppercase. | ||
| 1579 | /// | ||
| 1580 | /// @param[in] s1 C string to compare | ||
| 1581 | /// @param[in] s2 C string to compare | ||
| 1582 | /// @return True if the strings are equal, false otherwise | ||
| 1583 | /// | ||
| 1584 | inline static bool EqualsNoCase(const char* s1, const char* s2) | ||
| 1585 | { | ||
| 1586 | char c2; // we need only one char outside the loop | ||
| 1587 | do | ||
| 1588 | { | ||
| 1589 | const char c1 = *s1++; // const local variable should help compiler to optimize | ||
| 1590 | c2 = *s2++; | ||
| 1591 | // This includes the possibility that one of the characters is the null-terminator, | ||
| 1592 | // which implies a string mismatch. | ||
| 1593 | if (c1 != c2 && ::tolower(c1) != ::tolower(c2)) | ||
| 1594 | return false; | ||
| 1595 | } while (c2 != '\0'); // At this point, we know c1 == c2, so there's no need to test them both. | ||
| 1596 | return true; | ||
| 1597 | } | ||
| 1598 | //---------------------------------------------------------------------------- | ||
| 1599 | |||
| 1600 | //============================================================================ | ||
| 1601 | /// @brief Compare two strings with ignore of lower-/uppercase with given | ||
| 1602 | /// size. | ||
| 1603 | /// | ||
| 1604 | /// Equal to @ref EqualsNoCase only that size can defined and on return the | ||
| 1605 | /// difference between compared character becomes given. | ||
| 1606 | /// | ||
| 1607 | /// @param[in] str1 C++ string to compare | ||
| 1608 | /// @param[in] str2 C++ string to compare | ||
| 1609 | /// @param[in] n [opt] Length to check, 0 as default to make complete | ||
| 1610 | /// @return 0 if equal, otherwise difference of failed character in string to | ||
| 1611 | /// other ("a" - "b" = -1) | ||
| 1612 | /// | ||
| 1613 | inline static int CompareNoCase(const std::string& str1, const std::string& str2, size_t n = 0) | ||
| 1614 | { | ||
| 1615 | return CompareNoCase(str1.c_str(), str2.c_str(), n); | ||
| 1616 | } | ||
| 1617 | //---------------------------------------------------------------------------- | ||
| 1618 | |||
| 1619 | //============================================================================ | ||
| 1620 | /// @brief Compare two strings with ignore of lower-/uppercase with given | ||
| 1621 | /// size. | ||
| 1622 | /// | ||
| 1623 | /// Equal to @ref EqualsNoCase only that size can defined and on return the | ||
| 1624 | /// difference between compared character becomes given. | ||
| 1625 | /// | ||
| 1626 | /// @param[in] s1 C string to compare | ||
| 1627 | /// @param[in] s2 C string to compare | ||
| 1628 | /// @param[in] n [opt] Length to check, 0 as default to make complete | ||
| 1629 | /// @return 0 if equal, otherwise difference of failed character in string to | ||
| 1630 | /// other ("a" - "b" = -1) | ||
| 1631 | /// | ||
| 1632 | inline static int CompareNoCase(const char* s1, const char* s2, size_t n = 0) | ||
| 1633 | { | ||
| 1634 | char c2; // we need only one char outside the loop | ||
| 1635 | size_t index = 0; | ||
| 1636 | do | ||
| 1637 | { | ||
| 1638 | const char c1 = *s1++; // const local variable should help compiler to optimize | ||
| 1639 | c2 = *s2++; | ||
| 1640 | index++; | ||
| 1641 | // This includes the possibility that one of the characters is the null-terminator, | ||
| 1642 | // which implies a string mismatch. | ||
| 1643 | if (c1 != c2 && ::tolower(c1) != ::tolower(c2)) | ||
| 1644 | return ::tolower(c1) - ::tolower(c2); | ||
| 1645 | } while (c2 != '\0' && | ||
| 1646 | index != n); // At this point, we know c1 == c2, so there's no need to test them both. | ||
| 1647 | return 0; | ||
| 1648 | } | ||
| 1649 | //---------------------------------------------------------------------------- | ||
| 1650 | |||
| 1651 | //============================================================================ | ||
| 1652 | /// @brief Checks a string for the begin of another string. | ||
| 1653 | /// | ||
| 1654 | /// @param[in] str1 C++ string to be checked | ||
| 1655 | /// @param[in] str2 C++ string with which text defined in str1 is checked at | ||
| 1656 | /// the beginning | ||
| 1657 | /// @return True if string started with asked text, false otherwise | ||
| 1658 | /// | ||
| 1659 | /// | ||
| 1660 | /// -------------------------------------------------------------------------- | ||
| 1661 | /// Example: | ||
| 1662 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1663 | /// #include <kodi/tools/StringUtils.h> | ||
| 1664 | /// | ||
| 1665 | /// bool ret; | ||
| 1666 | /// std::string refstr = "test"; | ||
| 1667 | /// | ||
| 1668 | /// ret = kodi::tools::StringUtils::StartsWith(refstr, "te"); | ||
| 1669 | /// fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false"); | ||
| 1670 | /// | ||
| 1671 | /// ret = kodi::tools::StringUtils::StartsWith(refstr, "abc"); | ||
| 1672 | /// fprintf(stderr, "Excpect false for here and is '%s'\n", ret ? "true" : "false"); | ||
| 1673 | /// ~~~~~~~~~~~~~ | ||
| 1674 | /// | ||
| 1675 | inline static bool StartsWith(const std::string& str1, const std::string& str2) | ||
| 1676 | { | ||
| 1677 | return str1.compare(0, str2.size(), str2) == 0; | ||
| 1678 | } | ||
| 1679 | //---------------------------------------------------------------------------- | ||
| 1680 | |||
| 1681 | //============================================================================ | ||
| 1682 | /// @brief Checks a string for the begin of another string. | ||
| 1683 | /// | ||
| 1684 | /// @param[in] str1 C++ string to be checked | ||
| 1685 | /// @param[in] s2 C string with which text defined in str1 is checked at | ||
| 1686 | /// the beginning | ||
| 1687 | /// @return True if string started with asked text, false otherwise | ||
| 1688 | /// | ||
| 1689 | inline static bool StartsWith(const std::string& str1, const char* s2) | ||
| 1690 | { | ||
| 1691 | return StartsWith(str1.c_str(), s2); | ||
| 1692 | } | ||
| 1693 | //---------------------------------------------------------------------------- | ||
| 1694 | |||
| 1695 | //============================================================================ | ||
| 1696 | /// @brief Checks a string for the begin of another string. | ||
| 1697 | /// | ||
| 1698 | /// @param[in] s1 C string to be checked | ||
| 1699 | /// @param[in] s2 C string with which text defined in str1 is checked at | ||
| 1700 | /// the beginning | ||
| 1701 | /// @return True if string started with asked text, false otherwise | ||
| 1702 | /// | ||
| 1703 | inline static bool StartsWith(const char* s1, const char* s2) | ||
| 1704 | { | ||
| 1705 | while (*s2 != '\0') | ||
| 1706 | { | ||
| 1707 | if (*s1 != *s2) | ||
| 1708 | return false; | ||
| 1709 | s1++; | ||
| 1710 | s2++; | ||
| 1711 | } | ||
| 1712 | return true; | ||
| 1713 | } | ||
| 1714 | //---------------------------------------------------------------------------- | ||
| 1715 | |||
| 1716 | //============================================================================ | ||
| 1717 | /// @brief Checks a string for the begin of another string by ignore of | ||
| 1718 | /// upper-/lowercase. | ||
| 1719 | /// | ||
| 1720 | /// @param[in] str1 C++ string to be checked | ||
| 1721 | /// @param[in] str2 C++ string with which text defined in str1 is checked at | ||
| 1722 | /// the beginning | ||
| 1723 | /// @return True if string started with asked text, false otherwise | ||
| 1724 | /// | ||
| 1725 | /// | ||
| 1726 | /// -------------------------------------------------------------------------- | ||
| 1727 | /// Example: | ||
| 1728 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1729 | /// #include <kodi/tools/StringUtils.h> | ||
| 1730 | /// | ||
| 1731 | /// bool ret; | ||
| 1732 | /// std::string refstr = "test"; | ||
| 1733 | /// | ||
| 1734 | /// ret = kodi::tools::StringUtils::StartsWithNoCase(refstr, "te"); | ||
| 1735 | /// fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false"); | ||
| 1736 | /// | ||
| 1737 | /// ret = kodi::tools::StringUtils::StartsWithNoCase(refstr, "TEs"); | ||
| 1738 | /// fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false"); | ||
| 1739 | /// | ||
| 1740 | /// ret = kodi::tools::StringUtils::StartsWithNoCase(refstr, "abc"); | ||
| 1741 | /// fprintf(stderr, "Excpect false for here and is '%s'\n", ret ? "true" : "false"); | ||
| 1742 | /// ~~~~~~~~~~~~~ | ||
| 1743 | /// | ||
| 1744 | inline static bool StartsWithNoCase(const std::string& str1, const std::string& str2) | ||
| 1745 | { | ||
| 1746 | return StartsWithNoCase(str1.c_str(), str2.c_str()); | ||
| 1747 | } | ||
| 1748 | //---------------------------------------------------------------------------- | ||
| 1749 | |||
| 1750 | //============================================================================ | ||
| 1751 | /// @brief Checks a string for the begin of another string by ignore of | ||
| 1752 | /// upper-/lowercase. | ||
| 1753 | /// | ||
| 1754 | /// @param[in] str1 C++ string to be checked | ||
| 1755 | /// @param[in] s2 C string with which text defined in str1 is checked at | ||
| 1756 | /// the beginning | ||
| 1757 | /// @return True if string started with asked text, false otherwise | ||
| 1758 | /// | ||
| 1759 | inline static bool StartsWithNoCase(const std::string& str1, const char* s2) | ||
| 1760 | { | ||
| 1761 | return StartsWithNoCase(str1.c_str(), s2); | ||
| 1762 | } | ||
| 1763 | //---------------------------------------------------------------------------- | ||
| 1764 | |||
| 1765 | //============================================================================ | ||
| 1766 | /// @brief Checks a string for the begin of another string by ignore of | ||
| 1767 | /// upper-/lowercase. | ||
| 1768 | /// | ||
| 1769 | /// @param[in] s1 C string to be checked | ||
| 1770 | /// @param[in] s2 C string with which text defined in str1 is checked at | ||
| 1771 | /// the beginning | ||
| 1772 | /// @return True if string started with asked text, false otherwise | ||
| 1773 | /// | ||
| 1774 | inline static bool StartsWithNoCase(const char* s1, const char* s2) | ||
| 1775 | { | ||
| 1776 | while (*s2 != '\0') | ||
| 1777 | { | ||
| 1778 | if (::tolower(*s1) != ::tolower(*s2)) | ||
| 1779 | return false; | ||
| 1780 | s1++; | ||
| 1781 | s2++; | ||
| 1782 | } | ||
| 1783 | return true; | ||
| 1784 | } | ||
| 1785 | //---------------------------------------------------------------------------- | ||
| 1786 | |||
| 1787 | //============================================================================ | ||
| 1788 | /// @brief Checks a string for the ending of another string. | ||
| 1789 | /// | ||
| 1790 | /// @param[in] str1 C++ string to be checked | ||
| 1791 | /// @param[in] str2 C++ string with which text defined in str1 is checked at | ||
| 1792 | /// the ending | ||
| 1793 | /// @return True if string ended with asked text, false otherwise | ||
| 1794 | /// | ||
| 1795 | /// | ||
| 1796 | /// -------------------------------------------------------------------------- | ||
| 1797 | /// Example: | ||
| 1798 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1799 | /// #include <kodi/tools/StringUtils.h> | ||
| 1800 | /// | ||
| 1801 | /// bool ret; | ||
| 1802 | /// std::string refstr = "test"; | ||
| 1803 | /// | ||
| 1804 | /// ret = kodi::tools::StringUtils::EndsWith(refstr, "st"); | ||
| 1805 | /// fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false"); | ||
| 1806 | /// | ||
| 1807 | /// ret = kodi::tools::StringUtils::EndsWith(refstr, "abc"); | ||
| 1808 | /// fprintf(stderr, "Excpect false for here and is '%s'\n", ret ? "true" : "false"); | ||
| 1809 | /// ~~~~~~~~~~~~~ | ||
| 1810 | /// | ||
| 1811 | inline static bool EndsWith(const std::string& str1, const std::string& str2) | ||
| 1812 | { | ||
| 1813 | if (str1.size() < str2.size()) | ||
| 1814 | return false; | ||
| 1815 | return str1.compare(str1.size() - str2.size(), str2.size(), str2) == 0; | ||
| 1816 | } | ||
| 1817 | //---------------------------------------------------------------------------- | ||
| 1818 | |||
| 1819 | //============================================================================ | ||
| 1820 | /// @brief Checks a string for the ending of another string. | ||
| 1821 | /// | ||
| 1822 | /// @param[in] str1 C++ string to be checked | ||
| 1823 | /// @param[in] s2 C string with which text defined in str1 is checked at | ||
| 1824 | /// the ending | ||
| 1825 | /// @return True if string ended with asked text, false otherwise | ||
| 1826 | /// | ||
| 1827 | inline static bool EndsWith(const std::string& str1, const char* s2) | ||
| 1828 | { | ||
| 1829 | size_t len2 = strlen(s2); | ||
| 1830 | if (str1.size() < len2) | ||
| 1831 | return false; | ||
| 1832 | return str1.compare(str1.size() - len2, len2, s2) == 0; | ||
| 1833 | } | ||
| 1834 | //---------------------------------------------------------------------------- | ||
| 1835 | |||
| 1836 | //============================================================================ | ||
| 1837 | /// @brief Checks a string for the ending of another string by ignore of | ||
| 1838 | /// upper-/lowercase. | ||
| 1839 | /// | ||
| 1840 | /// @param[in] str1 C++ string to be checked | ||
| 1841 | /// @param[in] str2 C++ string with which text defined in str1 is checked at | ||
| 1842 | /// the ending | ||
| 1843 | /// @return True if string ended with asked text, false otherwise | ||
| 1844 | /// | ||
| 1845 | /// | ||
| 1846 | /// -------------------------------------------------------------------------- | ||
| 1847 | /// Example: | ||
| 1848 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1849 | /// #include <kodi/tools/StringUtils.h> | ||
| 1850 | /// | ||
| 1851 | /// bool ret; | ||
| 1852 | /// std::string refstr = "test"; | ||
| 1853 | /// | ||
| 1854 | /// ret = kodi::tools::StringUtils::EndsWithNoCase(refstr, "ST"); | ||
| 1855 | /// fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false"); | ||
| 1856 | /// | ||
| 1857 | /// ret = kodi::tools::StringUtils::EndsWithNoCase(refstr, "ABC"); | ||
| 1858 | /// fprintf(stderr, "Excpect false for here and is '%s'\n", ret ? "true" : "false"); | ||
| 1859 | /// ~~~~~~~~~~~~~ | ||
| 1860 | /// | ||
| 1861 | inline static bool EndsWithNoCase(const std::string& str1, const std::string& str2) | ||
| 1862 | { | ||
| 1863 | if (str1.size() < str2.size()) | ||
| 1864 | return false; | ||
| 1865 | const char* s1 = str1.c_str() + str1.size() - str2.size(); | ||
| 1866 | const char* s2 = str2.c_str(); | ||
| 1867 | while (*s2 != '\0') | ||
| 1868 | { | ||
| 1869 | if (::tolower(*s1) != ::tolower(*s2)) | ||
| 1870 | return false; | ||
| 1871 | s1++; | ||
| 1872 | s2++; | ||
| 1873 | } | ||
| 1874 | return true; | ||
| 1875 | } | ||
| 1876 | //---------------------------------------------------------------------------- | ||
| 1877 | |||
| 1878 | //============================================================================ | ||
| 1879 | /// @brief Checks a string for the ending of another string by ignore of | ||
| 1880 | /// upper-/lowercase. | ||
| 1881 | /// | ||
| 1882 | /// @param[in] str1 C++ string to be checked | ||
| 1883 | /// @param[in] s2 C string with which text defined in str1 is checked at | ||
| 1884 | /// the ending | ||
| 1885 | /// @return True if string ended with asked text, false otherwise | ||
| 1886 | /// | ||
| 1887 | inline static bool EndsWithNoCase(const std::string& str1, const char* s2) | ||
| 1888 | { | ||
| 1889 | size_t len2 = strlen(s2); | ||
| 1890 | if (str1.size() < len2) | ||
| 1891 | return false; | ||
| 1892 | const char* s1 = str1.c_str() + str1.size() - len2; | ||
| 1893 | while (*s2 != '\0') | ||
| 1894 | { | ||
| 1895 | if (::tolower(*s1) != ::tolower(*s2)) | ||
| 1896 | return false; | ||
| 1897 | s1++; | ||
| 1898 | s2++; | ||
| 1899 | } | ||
| 1900 | return true; | ||
| 1901 | } | ||
| 1902 | //---------------------------------------------------------------------------- | ||
| 1903 | |||
| 1904 | //============================================================================ | ||
| 1905 | /// @brief Compare two strings by his calculated alpha numeric values. | ||
| 1906 | /// | ||
| 1907 | /// @param[in] left Left string to compare with right | ||
| 1908 | /// @param[in] right Right string to compare with left | ||
| 1909 | /// @return Return about compare | ||
| 1910 | /// - 0 if left and right the same | ||
| 1911 | /// - -1 if right is longer | ||
| 1912 | /// - 1 if left is longer | ||
| 1913 | /// - < 0 if less equal | ||
| 1914 | /// - > 0 if more equal | ||
| 1915 | /// | ||
| 1916 | /// | ||
| 1917 | /// -------------------------------------------------------------------------- | ||
| 1918 | /// Example: | ||
| 1919 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1920 | /// #include <kodi/tools/StringUtils.h> | ||
| 1921 | /// | ||
| 1922 | /// int64_t ref, var; | ||
| 1923 | /// | ||
| 1924 | /// ref = 0; | ||
| 1925 | /// var = kodi::tools::StringUtils::AlphaNumericCompare(L"123abc", L"abc123"); | ||
| 1926 | /// EXPECT_LT(var, ref); | ||
| 1927 | /// ~~~~~~~~~~~~~ | ||
| 1928 | /// | ||
| 1929 | inline static int64_t AlphaNumericCompare(const wchar_t* left, const wchar_t* right) | ||
| 1930 | { | ||
| 1931 | const wchar_t* l = left; | ||
| 1932 | const wchar_t* r = right; | ||
| 1933 | const wchar_t *ld, *rd; | ||
| 1934 | wchar_t lc, rc; | ||
| 1935 | int64_t lnum, rnum; | ||
| 1936 | const std::collate<wchar_t>& coll = std::use_facet<std::collate<wchar_t>>(std::locale()); | ||
| 1937 | int cmp_res = 0; | ||
| 1938 | while (*l != 0 && *r != 0) | ||
| 1939 | { | ||
| 1940 | // check if we have a numerical value | ||
| 1941 | if (*l >= L'0' && *l <= L'9' && *r >= L'0' && *r <= L'9') | ||
| 1942 | { | ||
| 1943 | ld = l; | ||
| 1944 | lnum = 0; | ||
| 1945 | while (*ld >= L'0' && *ld <= L'9' && ld < l + 15) | ||
| 1946 | { // compare only up to 15 digits | ||
| 1947 | lnum *= 10; | ||
| 1948 | lnum += *ld++ - '0'; | ||
| 1949 | } | ||
| 1950 | rd = r; | ||
| 1951 | rnum = 0; | ||
| 1952 | while (*rd >= L'0' && *rd <= L'9' && rd < r + 15) | ||
| 1953 | { // compare only up to 15 digits | ||
| 1954 | rnum *= 10; | ||
| 1955 | rnum += *rd++ - L'0'; | ||
| 1956 | } | ||
| 1957 | // do we have numbers? | ||
| 1958 | if (lnum != rnum) | ||
| 1959 | { // yes - and they're different! | ||
| 1960 | return lnum - rnum; | ||
| 1961 | } | ||
| 1962 | l = ld; | ||
| 1963 | r = rd; | ||
| 1964 | continue; | ||
| 1965 | } | ||
| 1966 | // do case less comparison | ||
| 1967 | lc = *l; | ||
| 1968 | if (lc >= L'A' && lc <= L'Z') | ||
| 1969 | lc += L'a' - L'A'; | ||
| 1970 | rc = *r; | ||
| 1971 | if (rc >= L'A' && rc <= L'Z') | ||
| 1972 | rc += L'a' - L'A'; | ||
| 1973 | |||
| 1974 | // ok, do a normal comparison, taking current locale into account. Add special case stuff (eg '(' characters)) in here later | ||
| 1975 | if ((cmp_res = coll.compare(&lc, &lc + 1, &rc, &rc + 1)) != 0) | ||
| 1976 | { | ||
| 1977 | return cmp_res; | ||
| 1978 | } | ||
| 1979 | l++; | ||
| 1980 | r++; | ||
| 1981 | } | ||
| 1982 | if (*r) | ||
| 1983 | { // r is longer | ||
| 1984 | return -1; | ||
| 1985 | } | ||
| 1986 | else if (*l) | ||
| 1987 | { // l is longer | ||
| 1988 | return 1; | ||
| 1989 | } | ||
| 1990 | return 0; // files are the same | ||
| 1991 | } | ||
| 1992 | //---------------------------------------------------------------------------- | ||
| 1993 | |||
| 1994 | //============================================================================ | ||
| 1995 | /// @brief UTF8 version of strlen | ||
| 1996 | /// | ||
| 1997 | /// Skips any non-starting bytes in the count, thus returning the number of | ||
| 1998 | /// utf8 characters. | ||
| 1999 | /// | ||
| 2000 | /// @param[in] s c-string to find the length of. | ||
| 2001 | /// @return The number of utf8 characters in the string. | ||
| 2002 | /// | ||
| 2003 | inline static size_t Utf8StringLength(const char* s) | ||
| 2004 | { | ||
| 2005 | size_t length = 0; | ||
| 2006 | while (*s) | ||
| 2007 | { | ||
| 2008 | if ((*s++ & 0xC0) != 0x80) | ||
| 2009 | length++; | ||
| 2010 | } | ||
| 2011 | return length; | ||
| 2012 | } | ||
| 2013 | //---------------------------------------------------------------------------- | ||
| 2014 | |||
| 2015 | //============================================================================ | ||
| 2016 | /// @brief Check given character is a space. | ||
| 2017 | /// | ||
| 2018 | /// Hack to check only first byte of UTF-8 character | ||
| 2019 | /// without this hack "TrimX" functions failed on Win32 and OS X with UTF-8 strings | ||
| 2020 | /// | ||
| 2021 | /// @param[in] c Character to check | ||
| 2022 | /// @return true if space, false otherwise | ||
| 2023 | /// | ||
| 2024 | inline static int IsSpace(char c) { return (c & 0x80) == 0 && ::isspace(c); } | ||
| 2025 | //---------------------------------------------------------------------------- | ||
| 2026 | |||
| 2027 | //============================================================================ | ||
| 2028 | /// @brief Checks given pointer in string is a UTF8 letter. | ||
| 2029 | /// | ||
| 2030 | /// @param[in] str Given character values to check, must be minimum array of 2 | ||
| 2031 | /// @return return -1 if not, else return the utf8 char length. | ||
| 2032 | /// | ||
| 2033 | inline static int IsUTF8Letter(const unsigned char* str) | ||
| 2034 | { | ||
| 2035 | // reference: | ||
| 2036 | // unicode -> utf8 table: http://www.utf8-chartable.de/ | ||
| 2037 | // latin characters in unicode: http://en.wikipedia.org/wiki/Latin_characters_in_Unicode | ||
| 2038 | unsigned char ch = str[0]; | ||
| 2039 | if (!ch) | ||
| 2040 | return -1; | ||
| 2041 | if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) | ||
| 2042 | return 1; | ||
| 2043 | if (!(ch & 0x80)) | ||
| 2044 | return -1; | ||
| 2045 | unsigned char ch2 = str[1]; | ||
| 2046 | if (!ch2) | ||
| 2047 | return -1; | ||
| 2048 | // check latin 1 letter table: http://en.wikipedia.org/wiki/C1_Controls_and_Latin-1_Supplement | ||
| 2049 | if (ch == 0xC3 && ch2 >= 0x80 && ch2 <= 0xBF && ch2 != 0x97 && ch2 != 0xB7) | ||
| 2050 | return 2; | ||
| 2051 | // check latin extended A table: http://en.wikipedia.org/wiki/Latin_Extended-A | ||
| 2052 | if (ch >= 0xC4 && ch <= 0xC7 && ch2 >= 0x80 && ch2 <= 0xBF) | ||
| 2053 | return 2; | ||
| 2054 | // check latin extended B table: http://en.wikipedia.org/wiki/Latin_Extended-B | ||
| 2055 | // and International Phonetic Alphabet: http://en.wikipedia.org/wiki/IPA_Extensions_(Unicode_block) | ||
| 2056 | if (((ch == 0xC8 || ch == 0xC9) && ch2 >= 0x80 && ch2 <= 0xBF) || | ||
| 2057 | (ch == 0xCA && ch2 >= 0x80 && ch2 <= 0xAF)) | ||
| 2058 | return 2; | ||
| 2059 | return -1; | ||
| 2060 | } | ||
| 2061 | //---------------------------------------------------------------------------- | ||
| 2062 | |||
| 2063 | //============================================================================ | ||
| 2064 | /// @brief Check whether a string is a natural number. | ||
| 2065 | /// | ||
| 2066 | /// Matches `[ \t]*[0-9]+[ \t]*` | ||
| 2067 | /// | ||
| 2068 | /// @param[in] str The string to check | ||
| 2069 | /// @return true if the string is a natural number, false otherwise. | ||
| 2070 | /// | ||
| 2071 | /// | ||
| 2072 | /// -------------------------------------------------------------------------- | ||
| 2073 | /// Example: | ||
| 2074 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 2075 | /// #include <kodi/tools/StringUtils.h> | ||
| 2076 | /// | ||
| 2077 | /// EXPECT_TRUE(kodi::tools::StringUtils::IsNaturalNumber("10")); | ||
| 2078 | /// EXPECT_TRUE(kodi::tools::StringUtils::IsNaturalNumber(" 10")); | ||
| 2079 | /// EXPECT_TRUE(kodi::tools::StringUtils::IsNaturalNumber("0")); | ||
| 2080 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber(" 1 0")); | ||
| 2081 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber("1.0")); | ||
| 2082 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber("1.1")); | ||
| 2083 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber("0x1")); | ||
| 2084 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber("blah")); | ||
| 2085 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber("120 h")); | ||
| 2086 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber(" ")); | ||
| 2087 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber("")); | ||
| 2088 | /// ~~~~~~~~~~~~~ | ||
| 2089 | /// | ||
| 2090 | inline static bool IsNaturalNumber(const std::string& str) | ||
| 2091 | { | ||
| 2092 | size_t i = 0, n = 0; | ||
| 2093 | // allow whitespace,digits,whitespace | ||
| 2094 | while (i < str.size() && isspace((unsigned char)str[i])) | ||
| 2095 | i++; | ||
| 2096 | while (i < str.size() && isdigit((unsigned char)str[i])) | ||
| 2097 | { | ||
| 2098 | i++; | ||
| 2099 | n++; | ||
| 2100 | } | ||
| 2101 | while (i < str.size() && isspace((unsigned char)str[i])) | ||
| 2102 | i++; | ||
| 2103 | return i == str.size() && n > 0; | ||
| 2104 | } | ||
| 2105 | //---------------------------------------------------------------------------- | ||
| 2106 | |||
| 2107 | //============================================================================ | ||
| 2108 | /// @brief Check whether a string is an integer. | ||
| 2109 | /// | ||
| 2110 | /// Matches `[ \t]*[\-]*[0-9]+[ \t]*` | ||
| 2111 | /// | ||
| 2112 | /// @param str The string to check | ||
| 2113 | /// @return true if the string is an integer, false otherwise. | ||
| 2114 | /// | ||
| 2115 | /// | ||
| 2116 | /// -------------------------------------------------------------------------- | ||
| 2117 | /// Example: | ||
| 2118 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 2119 | /// #include <kodi/tools/StringUtils.h> | ||
| 2120 | /// | ||
| 2121 | /// EXPECT_TRUE(kodi::tools::StringUtils::IsInteger("10")); | ||
| 2122 | /// EXPECT_TRUE(kodi::tools::StringUtils::IsInteger(" -10")); | ||
| 2123 | /// EXPECT_TRUE(kodi::tools::StringUtils::IsInteger("0")); | ||
| 2124 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger(" 1 0")); | ||
| 2125 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger("1.0")); | ||
| 2126 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger("1.1")); | ||
| 2127 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger("0x1")); | ||
| 2128 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger("blah")); | ||
| 2129 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger("120 h")); | ||
| 2130 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger(" ")); | ||
| 2131 | /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger("")); | ||
| 2132 | /// ~~~~~~~~~~~~~ | ||
| 2133 | /// | ||
| 2134 | inline static bool IsInteger(const std::string& str) | ||
| 2135 | { | ||
| 2136 | size_t i = 0, n = 0; | ||
| 2137 | // allow whitespace,-,digits,whitespace | ||
| 2138 | while (i < str.size() && isspace((unsigned char)str[i])) | ||
| 2139 | i++; | ||
| 2140 | if (i < str.size() && str[i] == '-') | ||
| 2141 | i++; | ||
| 2142 | while (i < str.size() && isdigit((unsigned char)str[i])) | ||
| 2143 | { | ||
| 2144 | i++; | ||
| 2145 | n++; | ||
| 2146 | } | ||
| 2147 | while (i < str.size() && isspace((unsigned char)str[i])) | ||
| 2148 | i++; | ||
| 2149 | return i == str.size() && n > 0; | ||
| 2150 | } | ||
| 2151 | //---------------------------------------------------------------------------- | ||
| 2152 | |||
| 2153 | //============================================================================ | ||
| 2154 | /// @brief Checks a character is ascii number. | ||
| 2155 | /// | ||
| 2156 | /// @param[in] chr Single character to test | ||
| 2157 | /// @return true if yes, false otherwise | ||
| 2158 | /// | ||
| 2159 | inline static bool IsAasciiDigit(char chr) // locale independent | ||
| 2160 | { | ||
| 2161 | return chr >= '0' && chr <= '9'; | ||
| 2162 | } | ||
| 2163 | //---------------------------------------------------------------------------- | ||
| 2164 | |||
| 2165 | //============================================================================ | ||
| 2166 | /// @brief Checks a character is ascii hexadecimal number. | ||
| 2167 | /// | ||
| 2168 | /// @param[in] chr Single character to test | ||
| 2169 | /// @return true if yes, false otherwise | ||
| 2170 | /// | ||
| 2171 | inline static bool IsAsciiXDigit(char chr) // locale independent | ||
| 2172 | { | ||
| 2173 | return (chr >= '0' && chr <= '9') || (chr >= 'a' && chr <= 'f') || (chr >= 'A' && chr <= 'F'); | ||
| 2174 | } | ||
| 2175 | //---------------------------------------------------------------------------- | ||
| 2176 | |||
| 2177 | //============================================================================ | ||
| 2178 | /// @brief Translate a character where defined as a numerical value (0-9) | ||
| 2179 | /// string to right integer. | ||
| 2180 | /// | ||
| 2181 | /// @param[in] chr Single character to translate | ||
| 2182 | /// @return | ||
| 2183 | /// | ||
| 2184 | inline static int AsciiDigitValue(char chr) // locale independent | ||
| 2185 | { | ||
| 2186 | if (!IsAasciiDigit(chr)) | ||
| 2187 | return -1; | ||
| 2188 | |||
| 2189 | return chr - '0'; | ||
| 2190 | } | ||
| 2191 | //---------------------------------------------------------------------------- | ||
| 2192 | |||
| 2193 | //============================================================================ | ||
| 2194 | /// @brief Translate a character where defined as a hexadecimal value string | ||
| 2195 | /// to right integer. | ||
| 2196 | /// | ||
| 2197 | /// @param[in] chr Single character to translate | ||
| 2198 | /// @return Corresponding integer value, e.g. character is "A" becomes | ||
| 2199 | /// returned as a integer with 10. | ||
| 2200 | /// | ||
| 2201 | inline static int AsciiXDigitValue(char chr) // locale independent | ||
| 2202 | { | ||
| 2203 | int v = AsciiDigitValue(chr); | ||
| 2204 | if (v >= 0) | ||
| 2205 | return v; | ||
| 2206 | if (chr >= 'a' && chr <= 'f') | ||
| 2207 | return chr - 'a' + 10; | ||
| 2208 | if (chr >= 'A' && chr <= 'F') | ||
| 2209 | return chr - 'A' + 10; | ||
| 2210 | |||
| 2211 | return -1; | ||
| 2212 | } | ||
| 2213 | //---------------------------------------------------------------------------- | ||
| 2214 | |||
| 2215 | //============================================================================ | ||
| 2216 | /// @brief Checks a character is ascii alphabetic lowercase. | ||
| 2217 | /// | ||
| 2218 | /// @param[in] chr Single character to test | ||
| 2219 | /// @return True if ascii uppercase letter, false otherwise | ||
| 2220 | /// | ||
| 2221 | inline static bool IsAsciiUppercaseLetter(char chr) // locale independent | ||
| 2222 | { | ||
| 2223 | return (chr >= 'A' && chr <= 'Z'); | ||
| 2224 | } | ||
| 2225 | //---------------------------------------------------------------------------- | ||
| 2226 | |||
| 2227 | //============================================================================ | ||
| 2228 | /// @brief Checks a character is ascii alphabetic lowercase. | ||
| 2229 | /// | ||
| 2230 | /// @param[in] chr Single character to test | ||
| 2231 | /// @return True if ascii lowercase letter, false otherwise | ||
| 2232 | /// | ||
| 2233 | inline static bool IsAsciiLowercaseLetter(char chr) // locale independent | ||
| 2234 | { | ||
| 2235 | return (chr >= 'a' && chr <= 'z'); | ||
| 2236 | } | ||
| 2237 | //---------------------------------------------------------------------------- | ||
| 2238 | |||
| 2239 | //============================================================================ | ||
| 2240 | /// @brief Checks a character is within ascii alphabetic and numerical fields. | ||
| 2241 | /// | ||
| 2242 | /// @param[in] chr Single character to test | ||
| 2243 | /// @return true if alphabetic / numerical ascii value | ||
| 2244 | /// | ||
| 2245 | inline static bool IsAsciiAlphaNum(char chr) // locale independent | ||
| 2246 | { | ||
| 2247 | return IsAsciiUppercaseLetter(chr) || IsAsciiLowercaseLetter(chr) || IsAasciiDigit(chr); | ||
| 2248 | } | ||
| 2249 | //---------------------------------------------------------------------------- | ||
| 2250 | |||
| 2251 | //============================================================================ | ||
| 2252 | /// @brief Check a string for another text. | ||
| 2253 | /// | ||
| 2254 | /// @param[in] str String to seach for keywords | ||
| 2255 | /// @param[in] keywords List of keywords to search in text | ||
| 2256 | /// @return true if string contains word in list | ||
| 2257 | /// | ||
| 2258 | inline static bool ContainsKeyword(const std::string& str, | ||
| 2259 | const std::vector<std::string>& keywords) | ||
| 2260 | { | ||
| 2261 | for (const auto& it : keywords) | ||
| 2262 | { | ||
| 2263 | if (str.find(it) != str.npos) | ||
| 2264 | return true; | ||
| 2265 | } | ||
| 2266 | return false; | ||
| 2267 | } | ||
| 2268 | //---------------------------------------------------------------------------- | ||
| 2269 | |||
| 2270 | /*!@}*/ | ||
| 2271 | |||
| 2272 | //---------------------------------------------------------------------------- | ||
| 2273 | /// @defgroup cpp_kodi_tools_StringUtils_SearchControl String search | ||
| 2274 | /// @ingroup cpp_kodi_tools_StringUtils | ||
| 2275 | /// @brief **To search a string**\n | ||
| 2276 | /// Various functions are defined in here which allow you to search through a | ||
| 2277 | /// text in different ways. | ||
| 2278 | /// | ||
| 2279 | /*!@{*/ | ||
| 2280 | |||
| 2281 | //============================================================================ | ||
| 2282 | /// @brief Search for a single word within a text. | ||
| 2283 | /// | ||
| 2284 | /// @param[in] str String to search within | ||
| 2285 | /// @param[in] wordLowerCase Word as lowercase to search | ||
| 2286 | /// @return Position in string where word is found, -1 (std::string::npos) if | ||
| 2287 | /// not found | ||
| 2288 | /// | ||
| 2289 | /// | ||
| 2290 | /// -------------------------------------------------------------------------- | ||
| 2291 | /// Example: | ||
| 2292 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 2293 | /// #include <kodi/tools/StringUtils.h> | ||
| 2294 | /// | ||
| 2295 | /// size_t ref, var; | ||
| 2296 | /// | ||
| 2297 | /// // The name "string" is alone within text and becomes found on position 5 | ||
| 2298 | /// ref = 5; | ||
| 2299 | /// var = kodi::tools::StringUtils::FindWords("test string", "string"); | ||
| 2300 | /// EXPECT_EQ(ref, var); | ||
| 2301 | /// | ||
| 2302 | /// // The 12 is included inside another word and then not found as it should alone (-1 return) | ||
| 2303 | /// ref = -1; | ||
| 2304 | /// var = kodi::tools::StringUtils::FindWords("apple2012", "12"); | ||
| 2305 | /// EXPECT_EQ(ref, var); | ||
| 2306 | /// ~~~~~~~~~~~~~ | ||
| 2307 | /// | ||
| 2308 | inline static size_t FindWords(const char* str, const char* wordLowerCase) | ||
| 2309 | { | ||
| 2310 | // NOTE: This assumes word is lowercase! | ||
| 2311 | const unsigned char* s = (const unsigned char*)str; | ||
| 2312 | do | ||
| 2313 | { | ||
| 2314 | // start with a compare | ||
| 2315 | const unsigned char* c = s; | ||
| 2316 | const unsigned char* w = (const unsigned char*)wordLowerCase; | ||
| 2317 | bool same = true; | ||
| 2318 | while (same && *c && *w) | ||
| 2319 | { | ||
| 2320 | unsigned char lc = *c++; | ||
| 2321 | if (lc >= 'A' && lc <= 'Z') | ||
| 2322 | lc += 'a' - 'A'; | ||
| 2323 | |||
| 2324 | if (lc != *w++) // different | ||
| 2325 | same = false; | ||
| 2326 | } | ||
| 2327 | if (same && *w == 0) // only the same if word has been exhausted | ||
| 2328 | return (const char*)s - str; | ||
| 2329 | |||
| 2330 | // otherwise, skip current word (composed by latin letters) or number | ||
| 2331 | int l; | ||
| 2332 | if (*s >= '0' && *s <= '9') | ||
| 2333 | { | ||
| 2334 | ++s; | ||
| 2335 | while (*s >= '0' && *s <= '9') | ||
| 2336 | ++s; | ||
| 2337 | } | ||
| 2338 | else if ((l = IsUTF8Letter(s)) > 0) | ||
| 2339 | { | ||
| 2340 | s += l; | ||
| 2341 | while ((l = IsUTF8Letter(s)) > 0) | ||
| 2342 | s += l; | ||
| 2343 | } | ||
| 2344 | else | ||
| 2345 | ++s; | ||
| 2346 | while (*s && *s == ' ') | ||
| 2347 | s++; | ||
| 2348 | |||
| 2349 | // and repeat until we're done | ||
| 2350 | } while (*s); | ||
| 2351 | |||
| 2352 | return std::string::npos; | ||
| 2353 | } | ||
| 2354 | //---------------------------------------------------------------------------- | ||
| 2355 | |||
| 2356 | //============================================================================ | ||
| 2357 | /// @brief Search a string for a given bracket and give its end position. | ||
| 2358 | /// | ||
| 2359 | /// @param[in] str String to search within | ||
| 2360 | /// @param[in] opener Begin character to start search | ||
| 2361 | /// @param[in] closer End character to end search | ||
| 2362 | /// @param[in] startPos [opt] Position to start search in string, 0 as default | ||
| 2363 | /// to start from begin | ||
| 2364 | /// @return End position where found, -1 if failed | ||
| 2365 | /// | ||
| 2366 | /// | ||
| 2367 | /// -------------------------------------------------------------------------- | ||
| 2368 | /// Example: | ||
| 2369 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 2370 | /// #include <kodi/tools/StringUtils.h> | ||
| 2371 | /// | ||
| 2372 | /// int ref, var; | ||
| 2373 | /// | ||
| 2374 | /// ref = 11; | ||
| 2375 | /// var = kodi::tools::StringUtils::FindEndBracket("atest testbb test", 'a', 'b'); | ||
| 2376 | /// EXPECT_EQ(ref, var); | ||
| 2377 | /// ~~~~~~~~~~~~~ | ||
| 2378 | /// | ||
| 2379 | inline static size_t FindEndBracket(const std::string& str, | ||
| 2380 | char opener, | ||
| 2381 | char closer, | ||
| 2382 | size_t startPos = 0) | ||
| 2383 | { | ||
| 2384 | size_t blocks = 1; | ||
| 2385 | for (size_t i = startPos; i < str.size(); i++) | ||
| 2386 | { | ||
| 2387 | if (str[i] == opener) | ||
| 2388 | blocks++; | ||
| 2389 | else if (str[i] == closer) | ||
| 2390 | { | ||
| 2391 | blocks--; | ||
| 2392 | if (!blocks) | ||
| 2393 | return i; | ||
| 2394 | } | ||
| 2395 | } | ||
| 2396 | |||
| 2397 | return std::string::npos; | ||
| 2398 | } | ||
| 2399 | //---------------------------------------------------------------------------- | ||
| 2400 | |||
| 2401 | //============================================================================ | ||
| 2402 | /// @brief Search a text and return the number of parts found as a number. | ||
| 2403 | /// | ||
| 2404 | /// @param[in] strInput Input string to search for | ||
| 2405 | /// @param[in] strFind String to search in input | ||
| 2406 | /// @return Amount how much the string is found | ||
| 2407 | /// | ||
| 2408 | /// | ||
| 2409 | /// -------------------------------------------------------------------------- | ||
| 2410 | /// Example: | ||
| 2411 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 2412 | /// #include <kodi/tools/StringUtils.h> | ||
| 2413 | /// | ||
| 2414 | /// EXPECT_EQ(3, kodi::tools::StringUtils::FindNumber("aabcaadeaa", "aa")); | ||
| 2415 | /// EXPECT_EQ(1, kodi::tools::StringUtils::FindNumber("aabcaadeaa", "b")); | ||
| 2416 | /// ~~~~~~~~~~~~~ | ||
| 2417 | /// | ||
| 2418 | inline static int FindNumber(const std::string& strInput, const std::string& strFind) | ||
| 2419 | { | ||
| 2420 | size_t pos = strInput.find(strFind, 0); | ||
| 2421 | int numfound = 0; | ||
| 2422 | while (pos != std::string::npos) | ||
| 2423 | { | ||
| 2424 | numfound++; | ||
| 2425 | pos = strInput.find(strFind, pos + 1); | ||
| 2426 | } | ||
| 2427 | return numfound; | ||
| 2428 | } | ||
| 2429 | //---------------------------------------------------------------------------- | ||
| 2430 | |||
| 2431 | /*!@}*/ | ||
| 2432 | |||
| 2433 | //---------------------------------------------------------------------------- | ||
| 2434 | /// @defgroup cpp_kodi_tools_StringUtils_ListControl String list | ||
| 2435 | /// @ingroup cpp_kodi_tools_StringUtils | ||
| 2436 | /// @brief **Creating lists using a string**\n | ||
| 2437 | /// With this, either simple vectors or lists defined by templates can be given | ||
| 2438 | /// for the respective divided text. | ||
| 2439 | /// | ||
| 2440 | /*!@{*/ | ||
| 2441 | |||
| 2442 | //============================================================================ | ||
| 2443 | /// @brief Concatenates the elements of a specified array or the members of a | ||
| 2444 | /// collection and uses the specified separator between each element or | ||
| 2445 | /// member. | ||
| 2446 | /// | ||
| 2447 | /// @param[in] strings An array of objects whose string representations are | ||
| 2448 | /// concatenated. | ||
| 2449 | /// @param[in] delimiter Delimiter to be used to join the input string | ||
| 2450 | /// @return A string consisting of the elements of values, separated by the | ||
| 2451 | /// separator character. | ||
| 2452 | /// | ||
| 2453 | /// | ||
| 2454 | /// -------------------------------------------------------------------------- | ||
| 2455 | /// Example: | ||
| 2456 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 2457 | /// #include <kodi/tools/StringUtils.h> | ||
| 2458 | /// | ||
| 2459 | /// std::string refstr, varstr; | ||
| 2460 | /// std::vector<std::string> strarray; | ||
| 2461 | /// | ||
| 2462 | /// strarray.emplace_back("a"); | ||
| 2463 | /// strarray.emplace_back("b"); | ||
| 2464 | /// strarray.emplace_back("c"); | ||
| 2465 | /// strarray.emplace_back("de"); | ||
| 2466 | /// strarray.emplace_back(","); | ||
| 2467 | /// strarray.emplace_back("fg"); | ||
| 2468 | /// strarray.emplace_back(","); | ||
| 2469 | /// refstr = "a,b,c,de,,,fg,,"; | ||
| 2470 | /// varstr = kodi::tools::StringUtils::Join(strarray, ","); | ||
| 2471 | /// EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 2472 | /// ~~~~~~~~~~~~~ | ||
| 2473 | /// | ||
| 2474 | template<typename CONTAINER> | ||
| 2475 | inline static std::string Join(const CONTAINER& strings, const std::string& delimiter) | ||
| 2476 | { | ||
| 2477 | std::string result; | ||
| 2478 | for (const auto& str : strings) | ||
| 2479 | result += str + delimiter; | ||
| 2480 | |||
| 2481 | if (!result.empty()) | ||
| 2482 | result.erase(result.size() - delimiter.size()); | ||
| 2483 | return result; | ||
| 2484 | } | ||
| 2485 | //---------------------------------------------------------------------------- | ||
| 2486 | |||
| 2487 | //============================================================================ | ||
| 2488 | /// @brief Splits the given input string using the given delimiter into | ||
| 2489 | /// separate strings. | ||
| 2490 | /// | ||
| 2491 | /// If the given input string is empty the result will be an empty array (not | ||
| 2492 | /// an array containing an empty string). | ||
| 2493 | /// | ||
| 2494 | /// @param[in] input Input string to be split | ||
| 2495 | /// @param[in] delimiter Delimiter to be used to split the input string | ||
| 2496 | /// @param[in] iMaxStrings [opt] Maximum number of resulting split strings | ||
| 2497 | /// @return List of splitted strings | ||
| 2498 | /// | ||
| 2499 | /// | ||
| 2500 | /// -------------------------------------------------------------------------- | ||
| 2501 | /// Example: | ||
| 2502 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 2503 | /// #include <kodi/tools/StringUtils.h> | ||
| 2504 | /// | ||
| 2505 | /// std::vector<std::string> varresults; | ||
| 2506 | /// | ||
| 2507 | /// varresults = kodi::tools::StringUtils::Split("g,h,ij,k,lm,,n", ","); | ||
| 2508 | /// EXPECT_STREQ("g", varresults.at(0).c_str()); | ||
| 2509 | /// EXPECT_STREQ("h", varresults.at(1).c_str()); | ||
| 2510 | /// EXPECT_STREQ("ij", varresults.at(2).c_str()); | ||
| 2511 | /// EXPECT_STREQ("k", varresults.at(3).c_str()); | ||
| 2512 | /// EXPECT_STREQ("lm", varresults.at(4).c_str()); | ||
| 2513 | /// EXPECT_STREQ("", varresults.at(5).c_str()); | ||
| 2514 | /// EXPECT_STREQ("n", varresults.at(6).c_str()); | ||
| 2515 | /// ~~~~~~~~~~~~~ | ||
| 2516 | /// | ||
| 2517 | inline static std::vector<std::string> Split(const std::string& input, | ||
| 2518 | const std::string& delimiter, | ||
| 2519 | unsigned int iMaxStrings = 0) | ||
| 2520 | { | ||
| 2521 | std::vector<std::string> result; | ||
| 2522 | SplitTo(std::back_inserter(result), input, delimiter, iMaxStrings); | ||
| 2523 | return result; | ||
| 2524 | } | ||
| 2525 | //---------------------------------------------------------------------------- | ||
| 2526 | |||
| 2527 | //============================================================================ | ||
| 2528 | /// @brief Splits the given input string using the given delimiter into | ||
| 2529 | /// separate strings. | ||
| 2530 | /// | ||
| 2531 | /// If the given input string is empty the result will be an empty array (not | ||
| 2532 | /// an array containing an empty string). | ||
| 2533 | /// | ||
| 2534 | /// @param[in] input Input string to be split | ||
| 2535 | /// @param[in] delimiter Delimiter to be used to split the input string | ||
| 2536 | /// @param[in] iMaxStrings [opt] Maximum number of resulting split strings | ||
| 2537 | /// @return List of splitted strings | ||
| 2538 | /// | ||
| 2539 | inline static std::vector<std::string> Split(const std::string& input, | ||
| 2540 | const char delimiter, | ||
| 2541 | int iMaxStrings = 0) | ||
| 2542 | { | ||
| 2543 | std::vector<std::string> result; | ||
| 2544 | SplitTo(std::back_inserter(result), input, delimiter, iMaxStrings); | ||
| 2545 | return result; | ||
| 2546 | } | ||
| 2547 | //---------------------------------------------------------------------------- | ||
| 2548 | |||
| 2549 | //============================================================================ | ||
| 2550 | /// @brief Splits the given input string using the given delimiter into | ||
| 2551 | /// separate strings. | ||
| 2552 | /// | ||
| 2553 | /// If the given input string is empty the result will be an empty array (not | ||
| 2554 | /// an array containing an empty string). | ||
| 2555 | /// | ||
| 2556 | /// @param[in] input Input string to be split | ||
| 2557 | /// @param[in] delimiters Delimiter strings to be used to split the input | ||
| 2558 | /// strings | ||
| 2559 | /// @return List of splitted strings | ||
| 2560 | /// | ||
| 2561 | inline static std::vector<std::string> Split(const std::string& input, | ||
| 2562 | const std::vector<std::string>& delimiters) | ||
| 2563 | { | ||
| 2564 | std::vector<std::string> result; | ||
| 2565 | SplitTo(std::back_inserter(result), input, delimiters); | ||
| 2566 | return result; | ||
| 2567 | } | ||
| 2568 | //---------------------------------------------------------------------------- | ||
| 2569 | |||
| 2570 | //============================================================================ | ||
| 2571 | /// @brief Splits the given input string using the given delimiter into | ||
| 2572 | /// separate strings. | ||
| 2573 | /// | ||
| 2574 | /// If the given input string is empty nothing will be put into the target | ||
| 2575 | /// iterator. | ||
| 2576 | /// | ||
| 2577 | /// @param[in] d_first The beginning of the destination range | ||
| 2578 | /// @param[in] input Input string to be split | ||
| 2579 | /// @param[in] delimiter Delimiter to be used to split the input string | ||
| 2580 | /// @param[in] iMaxStrings [opt] Maximum number of resulting split strings | ||
| 2581 | /// @return Output iterator to the element in the destination range, one past | ||
| 2582 | /// the last element that was put there | ||
| 2583 | /// | ||
| 2584 | template<typename OutputIt> | ||
| 2585 | inline static OutputIt SplitTo(OutputIt d_first, | ||
| 2586 | const std::string& input, | ||
| 2587 | const std::string& delimiter, | ||
| 2588 | unsigned int iMaxStrings = 0) | ||
| 2589 | { | ||
| 2590 | OutputIt dest = d_first; | ||
| 2591 | |||
| 2592 | if (input.empty()) | ||
| 2593 | return dest; | ||
| 2594 | if (delimiter.empty()) | ||
| 2595 | { | ||
| 2596 | *d_first++ = input; | ||
| 2597 | return dest; | ||
| 2598 | } | ||
| 2599 | |||
| 2600 | const size_t delimLen = delimiter.length(); | ||
| 2601 | size_t nextDelim; | ||
| 2602 | size_t textPos = 0; | ||
| 2603 | do | ||
| 2604 | { | ||
| 2605 | if (--iMaxStrings == 0) | ||
| 2606 | { | ||
| 2607 | *dest++ = input.substr(textPos); | ||
| 2608 | break; | ||
| 2609 | } | ||
| 2610 | nextDelim = input.find(delimiter, textPos); | ||
| 2611 | *dest++ = input.substr(textPos, nextDelim - textPos); | ||
| 2612 | textPos = nextDelim + delimLen; | ||
| 2613 | } while (nextDelim != std::string::npos); | ||
| 2614 | |||
| 2615 | return dest; | ||
| 2616 | } | ||
| 2617 | //---------------------------------------------------------------------------- | ||
| 2618 | |||
| 2619 | //============================================================================ | ||
| 2620 | /// @brief Splits the given input string using the given delimiter into | ||
| 2621 | /// separate strings. | ||
| 2622 | /// | ||
| 2623 | /// If the given input string is empty nothing will be put into the target | ||
| 2624 | /// iterator. | ||
| 2625 | /// | ||
| 2626 | /// @param[in] d_first The beginning of the destination range | ||
| 2627 | /// @param[in] input Input string to be split | ||
| 2628 | /// @param[in] delimiter Delimiter to be used to split the input string | ||
| 2629 | /// @param[in] iMaxStrings [opt] Maximum number of resulting split strings | ||
| 2630 | /// @return Output iterator to the element in the destination range, one past | ||
| 2631 | /// the last element that was put there | ||
| 2632 | /// | ||
| 2633 | template<typename OutputIt> | ||
| 2634 | inline static OutputIt SplitTo(OutputIt d_first, | ||
| 2635 | const std::string& input, | ||
| 2636 | const char delimiter, | ||
| 2637 | int iMaxStrings = 0) | ||
| 2638 | { | ||
| 2639 | return SplitTo(d_first, input, std::string(1, delimiter), iMaxStrings); | ||
| 2640 | } | ||
| 2641 | //---------------------------------------------------------------------------- | ||
| 2642 | |||
| 2643 | //============================================================================ | ||
| 2644 | /// @brief Splits the given input string using the given delimiter into | ||
| 2645 | /// separate strings. | ||
| 2646 | /// | ||
| 2647 | /// If the given input string is empty nothing will be put into the target | ||
| 2648 | /// iterator. | ||
| 2649 | /// | ||
| 2650 | /// @param[in] d_first The beginning of the destination range | ||
| 2651 | /// @param[in] input Input string to be split | ||
| 2652 | /// @param[in] delimiters Delimiter strings to be used to split the input | ||
| 2653 | /// strings | ||
| 2654 | /// @return Output iterator to the element in the destination range, one past | ||
| 2655 | /// the last element that was put there | ||
| 2656 | /// | ||
| 2657 | template<typename OutputIt> | ||
| 2658 | inline static OutputIt SplitTo(OutputIt d_first, | ||
| 2659 | const std::string& input, | ||
| 2660 | const std::vector<std::string>& delimiters) | ||
| 2661 | { | ||
| 2662 | OutputIt dest = d_first; | ||
| 2663 | if (input.empty()) | ||
| 2664 | return dest; | ||
| 2665 | |||
| 2666 | if (delimiters.empty()) | ||
| 2667 | { | ||
| 2668 | *dest++ = input; | ||
| 2669 | return dest; | ||
| 2670 | } | ||
| 2671 | std::string str = input; | ||
| 2672 | for (size_t di = 1; di < delimiters.size(); di++) | ||
| 2673 | StringUtils::Replace(str, delimiters[di], delimiters[0]); | ||
| 2674 | return SplitTo(dest, str, delimiters[0]); | ||
| 2675 | } | ||
| 2676 | //---------------------------------------------------------------------------- | ||
| 2677 | |||
| 2678 | //============================================================================ | ||
| 2679 | /// @brief Splits the given input strings using the given delimiters into | ||
| 2680 | /// further separate strings. | ||
| 2681 | /// | ||
| 2682 | /// If the given input string vector is empty the result will be an empty | ||
| 2683 | /// array (not an array containing an empty string). | ||
| 2684 | /// | ||
| 2685 | /// Delimiter strings are applied in order, so once the (optional) maximum | ||
| 2686 | /// number of items is produced no other delimiters are applied. This produces | ||
| 2687 | /// different results to applying all delimiters at once e.g. "a/b#c/d" | ||
| 2688 | /// becomes "a", "b#c", "d" rather than "a", "b", "c/d" | ||
| 2689 | /// | ||
| 2690 | /// @param[in] input Input vector of strings each to be split | ||
| 2691 | /// @param[in] delimiters Delimiter strings to be used to split the input | ||
| 2692 | /// strings | ||
| 2693 | /// @param[in] iMaxStrings [opt] Maximum number of resulting split strings | ||
| 2694 | /// @return List of splitted strings | ||
| 2695 | /// | ||
| 2696 | inline static std::vector<std::string> SplitMulti(const std::vector<std::string>& input, | ||
| 2697 | const std::vector<std::string>& delimiters, | ||
| 2698 | unsigned int iMaxStrings = 0) | ||
| 2699 | { | ||
| 2700 | if (input.empty()) | ||
| 2701 | return std::vector<std::string>(); | ||
| 2702 | |||
| 2703 | std::vector<std::string> results(input); | ||
| 2704 | |||
| 2705 | if (delimiters.empty() || (iMaxStrings > 0 && iMaxStrings <= input.size())) | ||
| 2706 | return results; | ||
| 2707 | |||
| 2708 | std::vector<std::string> strings1; | ||
| 2709 | if (iMaxStrings == 0) | ||
| 2710 | { | ||
| 2711 | for (size_t di = 0; di < delimiters.size(); di++) | ||
| 2712 | { | ||
| 2713 | for (size_t i = 0; i < results.size(); i++) | ||
| 2714 | { | ||
| 2715 | std::vector<std::string> substrings = StringUtils::Split(results[i], delimiters[di]); | ||
| 2716 | for (size_t j = 0; j < substrings.size(); j++) | ||
| 2717 | strings1.push_back(substrings[j]); | ||
| 2718 | } | ||
| 2719 | results = strings1; | ||
| 2720 | strings1.clear(); | ||
| 2721 | } | ||
| 2722 | return results; | ||
| 2723 | } | ||
| 2724 | |||
| 2725 | // Control the number of strings input is split into, keeping the original strings. | ||
| 2726 | // Note iMaxStrings > input.size() | ||
| 2727 | size_t iNew = iMaxStrings - results.size(); | ||
| 2728 | for (size_t di = 0; di < delimiters.size(); di++) | ||
| 2729 | { | ||
| 2730 | for (size_t i = 0; i < results.size(); i++) | ||
| 2731 | { | ||
| 2732 | if (iNew > 0) | ||
| 2733 | { | ||
| 2734 | std::vector<std::string> substrings = | ||
| 2735 | StringUtils::Split(results[i], delimiters[di], static_cast<int>(iNew + 1)); | ||
| 2736 | iNew = iNew - substrings.size() + 1; | ||
| 2737 | for (size_t j = 0; j < substrings.size(); j++) | ||
| 2738 | strings1.push_back(substrings[j]); | ||
| 2739 | } | ||
| 2740 | else | ||
| 2741 | strings1.push_back(results[i]); | ||
| 2742 | } | ||
| 2743 | results = strings1; | ||
| 2744 | iNew = iMaxStrings - results.size(); | ||
| 2745 | strings1.clear(); | ||
| 2746 | if ((iNew <= 0)) | ||
| 2747 | break; //Stop trying any more delimiters | ||
| 2748 | } | ||
| 2749 | return results; | ||
| 2750 | } | ||
| 2751 | //---------------------------------------------------------------------------- | ||
| 2752 | |||
| 2753 | //============================================================================ | ||
| 2754 | /// @brief Split a string by the specified delimiters. | ||
| 2755 | /// | ||
| 2756 | /// Splits a string using one or more delimiting characters, ignoring empty | ||
| 2757 | /// tokens. | ||
| 2758 | /// | ||
| 2759 | /// Differs from Split() in two ways: | ||
| 2760 | /// 1. The delimiters are treated as individual characters, rather than a single delimiting string. | ||
| 2761 | /// 2. Empty tokens are ignored. | ||
| 2762 | /// | ||
| 2763 | /// | ||
| 2764 | /// @param[in] input String to split | ||
| 2765 | /// @param[in] delimiters Delimiters | ||
| 2766 | /// @return A vector of tokens | ||
| 2767 | /// | ||
| 2768 | inline static std::vector<std::string> Tokenize(const std::string& input, | ||
| 2769 | const std::string& delimiters) | ||
| 2770 | { | ||
| 2771 | std::vector<std::string> tokens; | ||
| 2772 | Tokenize(input, tokens, delimiters); | ||
| 2773 | return tokens; | ||
| 2774 | } | ||
| 2775 | //---------------------------------------------------------------------------- | ||
| 2776 | |||
| 2777 | //============================================================================ | ||
| 2778 | /// @brief Tokenizing a string denotes splitting a string with respect to a | ||
| 2779 | /// delimiter. | ||
| 2780 | /// | ||
| 2781 | /// @param[in] input String to split | ||
| 2782 | /// @param[out] tokens A vector of tokens | ||
| 2783 | /// @param[in] delimiters Delimiters | ||
| 2784 | /// | ||
| 2785 | inline static void Tokenize(const std::string& input, | ||
| 2786 | std::vector<std::string>& tokens, | ||
| 2787 | const std::string& delimiters) | ||
| 2788 | { | ||
| 2789 | tokens.clear(); | ||
| 2790 | // Skip delimiters at beginning. | ||
| 2791 | std::string::size_type dataPos = input.find_first_not_of(delimiters); | ||
| 2792 | while (dataPos != std::string::npos) | ||
| 2793 | { | ||
| 2794 | // Find next delimiter | ||
| 2795 | const std::string::size_type nextDelimPos = input.find_first_of(delimiters, dataPos); | ||
| 2796 | // Found a token, add it to the vector. | ||
| 2797 | tokens.push_back(input.substr(dataPos, nextDelimPos - dataPos)); | ||
| 2798 | // Skip delimiters. Note the "not_of" | ||
| 2799 | dataPos = input.find_first_not_of(delimiters, nextDelimPos); | ||
| 2800 | } | ||
| 2801 | } | ||
| 2802 | //---------------------------------------------------------------------------- | ||
| 2803 | |||
| 2804 | //============================================================================ | ||
| 2805 | /// @brief Tokenizing a string denotes splitting a string with respect to a | ||
| 2806 | /// delimiter. | ||
| 2807 | /// | ||
| 2808 | /// @param[in] input String to split | ||
| 2809 | /// @param[in] delimiter Delimiters | ||
| 2810 | /// @return A vector of tokens | ||
| 2811 | /// | ||
| 2812 | inline static std::vector<std::string> Tokenize(const std::string& input, const char delimiter) | ||
| 2813 | { | ||
| 2814 | std::vector<std::string> tokens; | ||
| 2815 | Tokenize(input, tokens, delimiter); | ||
| 2816 | return tokens; | ||
| 2817 | } | ||
| 2818 | //---------------------------------------------------------------------------- | ||
| 2819 | |||
| 2820 | //============================================================================ | ||
| 2821 | /// @brief Tokenizing a string denotes splitting a string with respect to a | ||
| 2822 | /// delimiter. | ||
| 2823 | /// | ||
| 2824 | /// @param[in] input String to split | ||
| 2825 | /// @param[out] tokens List of | ||
| 2826 | /// @param[in] delimiter Delimiters | ||
| 2827 | /// | ||
| 2828 | inline static void Tokenize(const std::string& input, | ||
| 2829 | std::vector<std::string>& tokens, | ||
| 2830 | const char delimiter) | ||
| 2831 | { | ||
| 2832 | tokens.clear(); | ||
| 2833 | // Skip delimiters at beginning. | ||
| 2834 | std::string::size_type dataPos = input.find_first_not_of(delimiter); | ||
| 2835 | while (dataPos != std::string::npos) | ||
| 2836 | { | ||
| 2837 | // Find next delimiter | ||
| 2838 | const std::string::size_type nextDelimPos = input.find(delimiter, dataPos); | ||
| 2839 | // Found a token, add it to the vector. | ||
| 2840 | tokens.push_back(input.substr(dataPos, nextDelimPos - dataPos)); | ||
| 2841 | // Skip delimiters. Note the "not_of" | ||
| 2842 | dataPos = input.find_first_not_of(delimiter, nextDelimPos); | ||
| 2843 | } | ||
| 2844 | } | ||
| 2845 | //---------------------------------------------------------------------------- | ||
| 2846 | |||
| 2847 | /*!@}*/ | ||
| 2848 | |||
| 2849 | //---------------------------------------------------------------------------- | ||
| 2850 | /// @defgroup cpp_kodi_tools_StringUtils_TimeControl Time value processing | ||
| 2851 | /// @ingroup cpp_kodi_tools_StringUtils | ||
| 2852 | /// @brief **String time formats**\n | ||
| 2853 | /// This is used to process the respective time formats in text fields. | ||
| 2854 | /*!@{*/ | ||
| 2855 | |||
| 2856 | //============================================================================ | ||
| 2857 | /// @brief Converts a time string to the respective integer value. | ||
| 2858 | /// | ||
| 2859 | /// @param[in] timeString String with time.\n | ||
| 2860 | /// Following types are possible: | ||
| 2861 | /// - "MM min" (integer number with "min" on end) | ||
| 2862 | /// - "HH:MM:SS" | ||
| 2863 | /// @return Time in seconds | ||
| 2864 | /// | ||
| 2865 | /// | ||
| 2866 | /// -------------------------------------------------------------------------- | ||
| 2867 | /// Example: | ||
| 2868 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 2869 | /// #include <kodi/tools/StringUtils.h> | ||
| 2870 | /// | ||
| 2871 | /// EXPECT_EQ(77455, kodi::tools::StringUtils::TimeStringToSeconds("21:30:55")); | ||
| 2872 | /// EXPECT_EQ(7*60, kodi::tools::StringUtils::TimeStringToSeconds("7 min")); | ||
| 2873 | /// EXPECT_EQ(7*60, kodi::tools::StringUtils::TimeStringToSeconds("7 min\t")); | ||
| 2874 | /// EXPECT_EQ(154*60, kodi::tools::StringUtils::TimeStringToSeconds(" 154 min")); | ||
| 2875 | /// EXPECT_EQ(1*60+1, kodi::tools::StringUtils::TimeStringToSeconds("1:01")); | ||
| 2876 | /// EXPECT_EQ(4*60+3, kodi::tools::StringUtils::TimeStringToSeconds("4:03")); | ||
| 2877 | /// EXPECT_EQ(2*3600+4*60+3, kodi::tools::StringUtils::TimeStringToSeconds("2:04:03")); | ||
| 2878 | /// EXPECT_EQ(2*3600+4*60+3, kodi::tools::StringUtils::TimeStringToSeconds(" 2:4:3")); | ||
| 2879 | /// EXPECT_EQ(2*3600+4*60+3, kodi::tools::StringUtils::TimeStringToSeconds(" \t\t 02:04:03 \n ")); | ||
| 2880 | /// EXPECT_EQ(1*3600+5*60+2, kodi::tools::StringUtils::TimeStringToSeconds("01:05:02:04:03 \n ")); | ||
| 2881 | /// EXPECT_EQ(0, kodi::tools::StringUtils::TimeStringToSeconds("blah")); | ||
| 2882 | /// EXPECT_EQ(0, kodi::tools::StringUtils::TimeStringToSeconds("ля-ля")); | ||
| 2883 | /// ~~~~~~~~~~~~~ | ||
| 2884 | /// | ||
| 2885 | inline static long TimeStringToSeconds(const std::string& timeString) | ||
| 2886 | { | ||
| 2887 | std::string strCopy(timeString); | ||
| 2888 | StringUtils::Trim(strCopy); | ||
| 2889 | if (StringUtils::EndsWithNoCase(strCopy, " min")) | ||
| 2890 | { | ||
| 2891 | // this is imdb format of "XXX min" | ||
| 2892 | return 60 * atoi(strCopy.c_str()); | ||
| 2893 | } | ||
| 2894 | else | ||
| 2895 | { | ||
| 2896 | std::vector<std::string> secs = StringUtils::Split(strCopy, ':'); | ||
| 2897 | int timeInSecs = 0; | ||
| 2898 | for (unsigned int i = 0; i < 3 && i < secs.size(); i++) | ||
| 2899 | { | ||
| 2900 | timeInSecs *= 60; | ||
| 2901 | timeInSecs += atoi(secs[i].c_str()); | ||
| 2902 | } | ||
| 2903 | return timeInSecs; | ||
| 2904 | } | ||
| 2905 | } | ||
| 2906 | //---------------------------------------------------------------------------- | ||
| 2907 | |||
| 2908 | //============================================================================ | ||
| 2909 | /// @brief Convert a time in seconds to a string based on the given time | ||
| 2910 | /// format. | ||
| 2911 | /// | ||
| 2912 | /// @param[in] seconds time in seconds | ||
| 2913 | /// @param[in] format [opt] The format we want the time in | ||
| 2914 | /// @return The formatted time | ||
| 2915 | /// | ||
| 2916 | /// @sa TIME_FORMAT | ||
| 2917 | /// | ||
| 2918 | /// | ||
| 2919 | /// -------------------------------------------------------------------------- | ||
| 2920 | /// Example: | ||
| 2921 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 2922 | /// #include <kodi/tools/StringUtils.h> | ||
| 2923 | /// | ||
| 2924 | /// std::string ref, var; | ||
| 2925 | /// | ||
| 2926 | /// ref = "21:30:55"; | ||
| 2927 | /// var = kodi::tools::StringUtils::SecondsToTimeString(77455); | ||
| 2928 | /// EXPECT_STREQ(ref.c_str(), var.c_str()); | ||
| 2929 | /// ~~~~~~~~~~~~~ | ||
| 2930 | /// | ||
| 2931 | inline static std::string SecondsToTimeString(long seconds, | ||
| 2932 | TIME_FORMAT format = TIME_FORMAT_GUESS) | ||
| 2933 | { | ||
| 2934 | bool isNegative = seconds < 0; | ||
| 2935 | seconds = std::abs(seconds); | ||
| 2936 | |||
| 2937 | std::string strHMS; | ||
| 2938 | if (format == TIME_FORMAT_SECS) | ||
| 2939 | strHMS = StringUtils::Format("%i", seconds); | ||
| 2940 | else if (format == TIME_FORMAT_MINS) | ||
| 2941 | strHMS = StringUtils::Format("%i", lrintf(static_cast<float>(seconds) / 60.0f)); | ||
| 2942 | else if (format == TIME_FORMAT_HOURS) | ||
| 2943 | strHMS = StringUtils::Format("%i", lrintf(static_cast<float>(seconds) / 3600.0f)); | ||
| 2944 | else if (format & TIME_FORMAT_M) | ||
| 2945 | strHMS += StringUtils::Format("%i", seconds % 3600 / 60); | ||
| 2946 | else | ||
| 2947 | { | ||
| 2948 | int hh = seconds / 3600; | ||
| 2949 | seconds = seconds % 3600; | ||
| 2950 | int mm = seconds / 60; | ||
| 2951 | int ss = seconds % 60; | ||
| 2952 | |||
| 2953 | if (format == TIME_FORMAT_GUESS) | ||
| 2954 | format = (hh >= 1) ? TIME_FORMAT_HH_MM_SS : TIME_FORMAT_MM_SS; | ||
| 2955 | if (format & TIME_FORMAT_HH) | ||
| 2956 | strHMS += StringUtils::Format("%2.2i", hh); | ||
| 2957 | else if (format & TIME_FORMAT_H) | ||
| 2958 | strHMS += StringUtils::Format("%i", hh); | ||
| 2959 | if (format & TIME_FORMAT_MM) | ||
| 2960 | strHMS += StringUtils::Format(strHMS.empty() ? "%2.2i" : ":%2.2i", mm); | ||
| 2961 | if (format & TIME_FORMAT_SS) | ||
| 2962 | strHMS += StringUtils::Format(strHMS.empty() ? "%2.2i" : ":%2.2i", ss); | ||
| 2963 | } | ||
| 2964 | |||
| 2965 | if (isNegative) | ||
| 2966 | strHMS = "-" + strHMS; | ||
| 2967 | |||
| 2968 | return strHMS; | ||
| 2969 | } | ||
| 2970 | //---------------------------------------------------------------------------- | ||
| 2971 | |||
| 2972 | //============================================================================ | ||
| 2973 | /// @brief Converts a string in the format YYYYMMDD to the corresponding | ||
| 2974 | /// integer value. | ||
| 2975 | /// | ||
| 2976 | /// @param[in] dateString The date in the associated format, possible values | ||
| 2977 | /// are: | ||
| 2978 | /// - DD (for days only) | ||
| 2979 | /// - MM-DD (for days with month) | ||
| 2980 | /// - YYYY-MM-DD (for years, then month and last days) | ||
| 2981 | /// @return Corresponding integer, e.g. "2020-12-24" return as integer value | ||
| 2982 | /// 20201224 | ||
| 2983 | /// | ||
| 2984 | /// | ||
| 2985 | /// -------------------------------------------------------------------------- | ||
| 2986 | /// Example: | ||
| 2987 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 2988 | /// #include <kodi/tools/StringUtils.h> | ||
| 2989 | /// | ||
| 2990 | /// int ref, var; | ||
| 2991 | /// | ||
| 2992 | /// ref = 20120706; | ||
| 2993 | /// var = kodi::tools::StringUtils::DateStringToYYYYMMDD("2012-07-06"); | ||
| 2994 | /// EXPECT_EQ(ref, var); | ||
| 2995 | /// ~~~~~~~~~~~~~ | ||
| 2996 | /// | ||
| 2997 | inline static int DateStringToYYYYMMDD(const std::string& dateString) | ||
| 2998 | { | ||
| 2999 | std::vector<std::string> days = StringUtils::Split(dateString, '-'); | ||
| 3000 | if (days.size() == 1) | ||
| 3001 | return atoi(days[0].c_str()); | ||
| 3002 | else if (days.size() == 2) | ||
| 3003 | return atoi(days[0].c_str()) * 100 + atoi(days[1].c_str()); | ||
| 3004 | else if (days.size() == 3) | ||
| 3005 | return atoi(days[0].c_str()) * 10000 + atoi(days[1].c_str()) * 100 + atoi(days[2].c_str()); | ||
| 3006 | else | ||
| 3007 | return -1; | ||
| 3008 | } | ||
| 3009 | //---------------------------------------------------------------------------- | ||
| 3010 | |||
| 3011 | /*!@}*/ | ||
| 3012 | |||
| 3013 | private: | ||
| 3014 | inline static int compareWchar(const void* a, const void* b) | ||
| 3015 | { | ||
| 3016 | if (*static_cast<const wchar_t*>(a) < *static_cast<const wchar_t*>(b)) | ||
| 3017 | return -1; | ||
| 3018 | else if (*static_cast<const wchar_t*>(a) > *static_cast<const wchar_t*>(b)) | ||
| 3019 | return 1; | ||
| 3020 | return 0; | ||
| 3021 | } | ||
| 3022 | |||
| 3023 | inline static wchar_t tolowerUnicode(const wchar_t& c) | ||
| 3024 | { | ||
| 3025 | wchar_t* p = | ||
| 3026 | static_cast<wchar_t*>(bsearch(&c, unicode_uppers, sizeof(unicode_uppers) / sizeof(wchar_t), | ||
| 3027 | sizeof(wchar_t), compareWchar)); | ||
| 3028 | if (p) | ||
| 3029 | return *(unicode_lowers + (p - unicode_uppers)); | ||
| 3030 | |||
| 3031 | return c; | ||
| 3032 | } | ||
| 3033 | |||
| 3034 | inline static wchar_t toupperUnicode(const wchar_t& c) | ||
| 3035 | { | ||
| 3036 | wchar_t* p = | ||
| 3037 | static_cast<wchar_t*>(bsearch(&c, unicode_lowers, sizeof(unicode_lowers) / sizeof(wchar_t), | ||
| 3038 | sizeof(wchar_t), compareWchar)); | ||
| 3039 | if (p) | ||
| 3040 | return *(unicode_uppers + (p - unicode_lowers)); | ||
| 3041 | |||
| 3042 | return c; | ||
| 3043 | } | ||
| 3044 | |||
| 3045 | static uint32_t UTF8ToUnicode(const unsigned char* z, int nKey, unsigned char& bytes) | ||
| 3046 | { | ||
| 3047 | // Lookup table used decode the first byte of a multi-byte UTF8 character | ||
| 3048 | // clang-format off | ||
| 3049 | static const unsigned char utf8Trans1[] = { | ||
| 3050 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, | ||
| 3051 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, | ||
| 3052 | 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, | ||
| 3053 | 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, | ||
| 3054 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, | ||
| 3055 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, | ||
| 3056 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, | ||
| 3057 | 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00, | ||
| 3058 | }; | ||
| 3059 | // clang-format on | ||
| 3060 | |||
| 3061 | uint32_t c; | ||
| 3062 | bytes = 0; | ||
| 3063 | c = z[0]; | ||
| 3064 | if (c >= 0xc0) | ||
| 3065 | { | ||
| 3066 | c = utf8Trans1[c - 0xc0]; | ||
| 3067 | int index = 1; | ||
| 3068 | while (index < nKey && (z[index] & 0xc0) == 0x80) | ||
| 3069 | { | ||
| 3070 | c = (c << 6) + (0x3f & z[index]); | ||
| 3071 | index++; | ||
| 3072 | } | ||
| 3073 | if (c < 0x80 || (c & 0xFFFFF800) == 0xD800 || (c & 0xFFFFFFFE) == 0xFFFE) | ||
| 3074 | c = 0xFFFD; | ||
| 3075 | bytes = static_cast<unsigned char>(index - 1); | ||
| 3076 | } | ||
| 3077 | return c; | ||
| 3078 | } | ||
| 3079 | }; | ||
| 3080 | ///@} | ||
| 3081 | //------------------------------------------------------------------------------ | ||
| 3082 | |||
| 3083 | } /* namespace tools */ | ||
| 3084 | } /* namespace kodi */ | ||
| 3085 | |||
| 3086 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/tools/Thread.h b/xbmc/addons/kodi-dev-kit/include/kodi/tools/Thread.h new file mode 100644 index 0000000..4cae13e --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/tools/Thread.h | |||
| @@ -0,0 +1,399 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifdef __cplusplus | ||
| 12 | |||
| 13 | #include "../General.h" | ||
| 14 | |||
| 15 | #include <chrono> | ||
| 16 | #include <condition_variable> | ||
| 17 | #include <future> | ||
| 18 | #include <mutex> | ||
| 19 | #include <thread> | ||
| 20 | |||
| 21 | namespace kodi | ||
| 22 | { | ||
| 23 | namespace tools | ||
| 24 | { | ||
| 25 | |||
| 26 | //============================================================================== | ||
| 27 | /// @defgroup cpp_kodi_tools_CThread class CThread | ||
| 28 | /// @ingroup cpp_kodi_tools | ||
| 29 | /// @brief **Helper class to represent threads of execution**\n | ||
| 30 | /// An execution thread is a sequence of instructions that can run concurrently | ||
| 31 | /// with other such sequences in multithreaded environments while sharing the | ||
| 32 | /// same address space. | ||
| 33 | /// | ||
| 34 | /// Is intended to reduce any code work of C++ on addons and to have them faster | ||
| 35 | /// to use. | ||
| 36 | /// | ||
| 37 | /// His code uses the support of platform-independent thread system introduced | ||
| 38 | /// with C++11. | ||
| 39 | /// | ||
| 40 | /// ---------------------------------------------------------------------------- | ||
| 41 | /// | ||
| 42 | /// **Example:** | ||
| 43 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 44 | /// #include <kodi/tools/Thread.h> | ||
| 45 | /// #include <kodi/AddonBase.h> | ||
| 46 | /// | ||
| 47 | /// class ATTRIBUTE_HIDDEN CTestAddon | ||
| 48 | /// : public kodi::addon::CAddonBase, | ||
| 49 | /// public kodi::tools::CThread | ||
| 50 | /// { | ||
| 51 | /// public: | ||
| 52 | /// CTestAddon() = default; | ||
| 53 | /// | ||
| 54 | /// ADDON_STATUS Create() override; | ||
| 55 | /// | ||
| 56 | /// void Process() override; | ||
| 57 | /// }; | ||
| 58 | /// | ||
| 59 | /// ADDON_STATUS CTestAddon::Create() | ||
| 60 | /// { | ||
| 61 | /// kodi::Log(ADDON_LOG_INFO, "Starting thread"); | ||
| 62 | /// CreateThread(); | ||
| 63 | /// | ||
| 64 | /// Sleep(4000); | ||
| 65 | /// | ||
| 66 | /// kodi::Log(ADDON_LOG_INFO, "Stopping thread"); | ||
| 67 | /// // This added as example and also becomes stopped by class destructor | ||
| 68 | /// StopThread(); | ||
| 69 | /// | ||
| 70 | /// return ADDON_STATUS_OK; | ||
| 71 | /// } | ||
| 72 | /// | ||
| 73 | /// void CTestAddon::Process() | ||
| 74 | /// { | ||
| 75 | /// kodi::Log(ADDON_LOG_INFO, "Thread started"); | ||
| 76 | /// | ||
| 77 | /// while (!m_threadStop) | ||
| 78 | /// { | ||
| 79 | /// kodi::Log(ADDON_LOG_INFO, "Hello World"); | ||
| 80 | /// Sleep(1000); | ||
| 81 | /// } | ||
| 82 | /// | ||
| 83 | /// kodi::Log(ADDON_LOG_INFO, "Thread ended"); | ||
| 84 | /// } | ||
| 85 | /// | ||
| 86 | /// ADDONCREATOR(CTestAddon) | ||
| 87 | /// ~~~~~~~~~~~~~ | ||
| 88 | /// | ||
| 89 | ///@{ | ||
| 90 | class CThread | ||
| 91 | { | ||
| 92 | public: | ||
| 93 | //============================================================================ | ||
| 94 | /// @ingroup cpp_kodi_tools_CThread | ||
| 95 | /// @brief Class constructor. | ||
| 96 | /// | ||
| 97 | CThread() : m_threadStop(false) {} | ||
| 98 | //---------------------------------------------------------------------------- | ||
| 99 | |||
| 100 | //============================================================================ | ||
| 101 | /// @ingroup cpp_kodi_tools_CThread | ||
| 102 | /// @brief Class destructor. | ||
| 103 | /// | ||
| 104 | virtual ~CThread() | ||
| 105 | { | ||
| 106 | StopThread(); | ||
| 107 | if (m_thread != nullptr) | ||
| 108 | { | ||
| 109 | m_thread->detach(); | ||
| 110 | delete m_thread; | ||
| 111 | } | ||
| 112 | } | ||
| 113 | //---------------------------------------------------------------------------- | ||
| 114 | |||
| 115 | //============================================================================ | ||
| 116 | /// @ingroup cpp_kodi_tools_CThread | ||
| 117 | /// @brief Check auto delete is enabled on this thread class. | ||
| 118 | /// | ||
| 119 | /// @return true if auto delete is used, false otherwise | ||
| 120 | /// | ||
| 121 | bool IsAutoDelete() const { return m_autoDelete; } | ||
| 122 | //---------------------------------------------------------------------------- | ||
| 123 | |||
| 124 | //============================================================================ | ||
| 125 | /// @ingroup cpp_kodi_tools_CThread | ||
| 126 | /// @brief Check caller is on this running thread. | ||
| 127 | /// | ||
| 128 | /// @return true if called from thread inside the class, false if from another | ||
| 129 | /// thread | ||
| 130 | /// | ||
| 131 | bool IsCurrentThread() const { return m_threadId == std::this_thread::get_id(); } | ||
| 132 | //---------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //============================================================================ | ||
| 135 | /// @ingroup cpp_kodi_tools_CThread | ||
| 136 | /// @brief Check thread inside this class is running and active. | ||
| 137 | /// | ||
| 138 | /// @note This function should be used from outside and not within process to | ||
| 139 | /// check thread is active. Use use atomic bool @ref m_threadStop for this. | ||
| 140 | /// | ||
| 141 | /// @return true if running, false if not | ||
| 142 | /// | ||
| 143 | bool IsRunning() const | ||
| 144 | { | ||
| 145 | if (m_thread != nullptr) | ||
| 146 | { | ||
| 147 | // it's possible that the thread exited on it's own without a call to StopThread. If so then | ||
| 148 | // the promise should be fulfilled. | ||
| 149 | std::future_status stat = m_future.wait_for(std::chrono::milliseconds(0)); | ||
| 150 | // a status of 'ready' means the future contains the value so the thread has exited | ||
| 151 | // since the thread can't exit without setting the future. | ||
| 152 | if (stat == std::future_status::ready) // this is an indication the thread has exited. | ||
| 153 | return false; | ||
| 154 | return true; // otherwise the thread is still active. | ||
| 155 | } | ||
| 156 | else | ||
| 157 | return false; | ||
| 158 | } | ||
| 159 | //---------------------------------------------------------------------------- | ||
| 160 | |||
| 161 | //============================================================================ | ||
| 162 | /// @ingroup cpp_kodi_tools_CThread | ||
| 163 | /// @brief Create a new thread defined by this class on child. | ||
| 164 | /// | ||
| 165 | /// This starts then @ref Process() where is available on the child by addon. | ||
| 166 | /// | ||
| 167 | /// @param[in] autoDelete To set thread to delete itself after end, default is | ||
| 168 | /// false | ||
| 169 | /// | ||
| 170 | void CreateThread(bool autoDelete = false) | ||
| 171 | { | ||
| 172 | if (m_thread != nullptr) | ||
| 173 | { | ||
| 174 | // if the thread exited on it's own, without a call to StopThread, then we can get here | ||
| 175 | // incorrectly. We should be able to determine this by checking the promise. | ||
| 176 | std::future_status stat = m_future.wait_for(std::chrono::milliseconds(0)); | ||
| 177 | // a status of 'ready' means the future contains the value so the thread has exited | ||
| 178 | // since the thread can't exit without setting the future. | ||
| 179 | if (stat == std::future_status::ready) // this is an indication the thread has exited. | ||
| 180 | StopThread(true); // so let's just clean up | ||
| 181 | else | ||
| 182 | { // otherwise we have a problem. | ||
| 183 | kodi::Log(ADDON_LOG_FATAL, "%s - fatal error creating thread - old thread id not null", | ||
| 184 | __func__); | ||
| 185 | exit(1); | ||
| 186 | } | ||
| 187 | } | ||
| 188 | |||
| 189 | m_autoDelete = autoDelete; | ||
| 190 | m_threadStop = false; | ||
| 191 | m_startEvent.notify_all(); | ||
| 192 | m_stopEvent.notify_all(); | ||
| 193 | |||
| 194 | std::promise<bool> prom; | ||
| 195 | m_future = prom.get_future(); | ||
| 196 | |||
| 197 | { | ||
| 198 | // The std::thread internals must be set prior to the lambda doing | ||
| 199 | // any work. This will cause the lambda to wait until m_thread | ||
| 200 | // is fully initialized. Interestingly, using a std::atomic doesn't | ||
| 201 | // have the appropriate memory barrier behavior to accomplish the | ||
| 202 | // same thing so a full system mutex needs to be used. | ||
| 203 | std::unique_lock<std::recursive_mutex> lock(m_threadMutex); | ||
| 204 | m_thread = new std::thread( | ||
| 205 | [](CThread* thread, std::promise<bool> promise) { | ||
| 206 | try | ||
| 207 | { | ||
| 208 | { | ||
| 209 | // Wait for the pThread->m_thread internals to be set. Otherwise we could | ||
| 210 | // get to a place where we're reading, say, the thread id inside this | ||
| 211 | // lambda's call stack prior to the thread that kicked off this lambda | ||
| 212 | // having it set. Once this lock is released, the CThread::Create function | ||
| 213 | // that kicked this off is done so everything should be set. | ||
| 214 | std::unique_lock<std::recursive_mutex> lock(thread->m_threadMutex); | ||
| 215 | } | ||
| 216 | |||
| 217 | thread->m_threadId = std::this_thread::get_id(); | ||
| 218 | std::stringstream ss; | ||
| 219 | ss << thread->m_threadId; | ||
| 220 | std::string id = ss.str(); | ||
| 221 | bool autodelete = thread->m_autoDelete; | ||
| 222 | |||
| 223 | kodi::Log(ADDON_LOG_DEBUG, "Thread %s start, auto delete: %s", id.c_str(), | ||
| 224 | (autodelete ? "true" : "false")); | ||
| 225 | |||
| 226 | thread->m_running = true; | ||
| 227 | thread->m_startEvent.notify_one(); | ||
| 228 | |||
| 229 | thread->Process(); | ||
| 230 | |||
| 231 | if (autodelete) | ||
| 232 | { | ||
| 233 | kodi::Log(ADDON_LOG_DEBUG, "Thread %s terminating (autodelete)", id.c_str()); | ||
| 234 | delete thread; | ||
| 235 | thread = nullptr; | ||
| 236 | } | ||
| 237 | else | ||
| 238 | kodi::Log(ADDON_LOG_DEBUG, "Thread %s terminating", id.c_str()); | ||
| 239 | } | ||
| 240 | catch (const std::exception& e) | ||
| 241 | { | ||
| 242 | kodi::Log(ADDON_LOG_DEBUG, "Thread Terminating with Exception: %s", e.what()); | ||
| 243 | } | ||
| 244 | catch (...) | ||
| 245 | { | ||
| 246 | kodi::Log(ADDON_LOG_DEBUG, "Thread Terminating with Exception"); | ||
| 247 | } | ||
| 248 | |||
| 249 | promise.set_value(true); | ||
| 250 | }, | ||
| 251 | this, std::move(prom)); | ||
| 252 | |||
| 253 | m_startEvent.wait(lock); | ||
| 254 | } | ||
| 255 | } | ||
| 256 | //---------------------------------------------------------------------------- | ||
| 257 | |||
| 258 | //============================================================================ | ||
| 259 | /// @ingroup cpp_kodi_tools_CThread | ||
| 260 | /// @brief Stop a running thread. | ||
| 261 | /// | ||
| 262 | /// @param[in] wait As true (default) to wait until thread is finished and | ||
| 263 | /// stopped, as false the function return directly and thread | ||
| 264 | /// becomes independently stopped. | ||
| 265 | /// | ||
| 266 | void StopThread(bool wait = true) | ||
| 267 | { | ||
| 268 | std::unique_lock<std::recursive_mutex> lock(m_threadMutex); | ||
| 269 | |||
| 270 | if (m_threadStop) | ||
| 271 | return; | ||
| 272 | |||
| 273 | if (m_thread && !m_running) | ||
| 274 | m_startEvent.wait(lock); | ||
| 275 | m_running = false; | ||
| 276 | m_threadStop = true; | ||
| 277 | m_stopEvent.notify_one(); | ||
| 278 | |||
| 279 | std::thread* lthread = m_thread; | ||
| 280 | if (lthread != nullptr && wait && !IsCurrentThread()) | ||
| 281 | { | ||
| 282 | lock.unlock(); | ||
| 283 | if (lthread->joinable()) | ||
| 284 | lthread->join(); | ||
| 285 | delete m_thread; | ||
| 286 | m_thread = nullptr; | ||
| 287 | m_threadId = std::thread::id(); | ||
| 288 | } | ||
| 289 | } | ||
| 290 | //---------------------------------------------------------------------------- | ||
| 291 | |||
| 292 | //============================================================================ | ||
| 293 | /// @ingroup cpp_kodi_tools_CThread | ||
| 294 | /// @brief Thread sleep with given amount of milliseconds. | ||
| 295 | /// | ||
| 296 | /// This makes a sleep in the thread with a given time value. If it is called | ||
| 297 | /// within the process itself, it is also checked whether the thread is | ||
| 298 | /// terminated and the sleep process is thereby interrupted. | ||
| 299 | /// | ||
| 300 | /// If the external point calls this, only a regular sleep is used, which runs | ||
| 301 | /// through completely. | ||
| 302 | /// | ||
| 303 | /// @param[in] milliseconds Time to sleep | ||
| 304 | /// | ||
| 305 | void Sleep(uint32_t milliseconds) | ||
| 306 | { | ||
| 307 | if (milliseconds > 10 && IsCurrentThread()) | ||
| 308 | { | ||
| 309 | std::unique_lock<std::recursive_mutex> lock(m_threadMutex); | ||
| 310 | m_stopEvent.wait_for(lock, std::chrono::milliseconds(milliseconds)); | ||
| 311 | } | ||
| 312 | else | ||
| 313 | { | ||
| 314 | std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); | ||
| 315 | } | ||
| 316 | } | ||
| 317 | //---------------------------------------------------------------------------- | ||
| 318 | |||
| 319 | //============================================================================ | ||
| 320 | /// @ingroup cpp_kodi_tools_CThread | ||
| 321 | /// @brief The function returns when the thread execution has completed or | ||
| 322 | /// timing is reached in milliseconds beforehand | ||
| 323 | /// | ||
| 324 | /// This synchronizes the moment this function returns with the completion of | ||
| 325 | /// all operations on the thread. | ||
| 326 | /// | ||
| 327 | /// @param[in] milliseconds Time to wait for join | ||
| 328 | /// | ||
| 329 | bool Join(unsigned int milliseconds) | ||
| 330 | { | ||
| 331 | std::unique_lock<std::recursive_mutex> lock(m_threadMutex); | ||
| 332 | std::thread* lthread = m_thread; | ||
| 333 | if (lthread != nullptr) | ||
| 334 | { | ||
| 335 | if (IsCurrentThread()) | ||
| 336 | return false; | ||
| 337 | |||
| 338 | { | ||
| 339 | m_threadMutex.unlock(); // don't hold the thread lock while we're waiting | ||
| 340 | std::future_status stat = m_future.wait_for(std::chrono::milliseconds(milliseconds)); | ||
| 341 | if (stat != std::future_status::ready) | ||
| 342 | return false; | ||
| 343 | m_threadMutex.lock(); | ||
| 344 | } | ||
| 345 | |||
| 346 | // it's possible it's already joined since we released the lock above. | ||
| 347 | if (lthread->joinable()) | ||
| 348 | m_thread->join(); | ||
| 349 | return true; | ||
| 350 | } | ||
| 351 | else | ||
| 352 | return false; | ||
| 353 | } | ||
| 354 | //---------------------------------------------------------------------------- | ||
| 355 | |||
| 356 | protected: | ||
| 357 | //============================================================================ | ||
| 358 | /// @ingroup cpp_kodi_tools_CThread | ||
| 359 | /// @brief The function to be added by the addon as a child to carry out the | ||
| 360 | /// process thread. | ||
| 361 | /// | ||
| 362 | /// Use @ref m_threadStop to check about active of thread and want stopped from | ||
| 363 | /// external place. | ||
| 364 | /// | ||
| 365 | /// @note This function is necessary and must be implemented by the addon. | ||
| 366 | /// | ||
| 367 | virtual void Process() = 0; | ||
| 368 | //---------------------------------------------------------------------------- | ||
| 369 | |||
| 370 | //============================================================================ | ||
| 371 | /// @ingroup cpp_kodi_tools_CThread | ||
| 372 | /// @brief Atomic bool to indicate thread is active. | ||
| 373 | /// | ||
| 374 | /// This should be used in @ref Process() to check the activity of the thread and, | ||
| 375 | /// if true, to terminate the process. | ||
| 376 | /// | ||
| 377 | /// - <b>`false`</b>: Thread active and should be run | ||
| 378 | /// - <b>`true`</b>: Thread ends and should be stopped | ||
| 379 | /// | ||
| 380 | std::atomic<bool> m_threadStop; | ||
| 381 | //---------------------------------------------------------------------------- | ||
| 382 | |||
| 383 | private: | ||
| 384 | bool m_autoDelete = false; | ||
| 385 | bool m_running = false; | ||
| 386 | std::condition_variable_any m_stopEvent; | ||
| 387 | std::condition_variable_any m_startEvent; | ||
| 388 | std::recursive_mutex m_threadMutex; | ||
| 389 | std::thread::id m_threadId; | ||
| 390 | std::thread* m_thread = nullptr; | ||
| 391 | std::future<bool> m_future; | ||
| 392 | }; | ||
| 393 | ///@} | ||
| 394 | //------------------------------------------------------------------------------ | ||
| 395 | |||
| 396 | } /* namespace tools */ | ||
| 397 | } /* namespace kodi */ | ||
| 398 | |||
| 399 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/tools/Timer.h b/xbmc/addons/kodi-dev-kit/include/kodi/tools/Timer.h new file mode 100644 index 0000000..0e0ced7 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/tools/Timer.h | |||
| @@ -0,0 +1,315 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #ifdef __cplusplus | ||
| 12 | |||
| 13 | #include "Thread.h" | ||
| 14 | |||
| 15 | #include <functional> | ||
| 16 | |||
| 17 | namespace kodi | ||
| 18 | { | ||
| 19 | namespace tools | ||
| 20 | { | ||
| 21 | |||
| 22 | //============================================================================== | ||
| 23 | /// @defgroup cpp_kodi_tools_CTimer class CTimer | ||
| 24 | /// @ingroup cpp_kodi_tools | ||
| 25 | /// @brief **Time interval management**\n | ||
| 26 | /// Class which enables a time interval to be called up by a given function or | ||
| 27 | /// class by means of a thread. | ||
| 28 | /// | ||
| 29 | /// His code uses the support of platform-independent thread system introduced | ||
| 30 | /// with C++11. | ||
| 31 | /// | ||
| 32 | /// | ||
| 33 | /// ---------------------------------------------------------------------------- | ||
| 34 | /// | ||
| 35 | /// **Example:** | ||
| 36 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 37 | /// #include <kodi/tools/Timer.h> | ||
| 38 | /// | ||
| 39 | /// class ATTRIBUTE_HIDDEN CExample | ||
| 40 | /// { | ||
| 41 | /// public: | ||
| 42 | /// CExample() : m_timer([this](){TimerCall();}) | ||
| 43 | /// { | ||
| 44 | /// m_timer.Start(5000, true); // let call continuously all 5 seconds | ||
| 45 | /// } | ||
| 46 | /// | ||
| 47 | /// void TimerCall() | ||
| 48 | /// { | ||
| 49 | /// fprintf(stderr, "Hello World\n"); | ||
| 50 | /// } | ||
| 51 | /// | ||
| 52 | /// private: | ||
| 53 | /// kodi::tools::CTimer m_timer; | ||
| 54 | /// }; | ||
| 55 | /// ~~~~~~~~~~~~~ | ||
| 56 | /// | ||
| 57 | ///@{ | ||
| 58 | class CTimer : protected CThread | ||
| 59 | { | ||
| 60 | public: | ||
| 61 | class ITimerCallback; | ||
| 62 | |||
| 63 | //============================================================================ | ||
| 64 | /// @ingroup cpp_kodi_tools_CTimer | ||
| 65 | /// @brief Class constructor to pass individual other class as callback. | ||
| 66 | /// | ||
| 67 | /// @param[in] callback Child class of parent @ref ITimerCallback with | ||
| 68 | /// implemented function @ref ITimerCallback::OnTimeout(). | ||
| 69 | /// | ||
| 70 | explicit CTimer(kodi::tools::CTimer::ITimerCallback* callback) | ||
| 71 | : CTimer(std::bind(&ITimerCallback::OnTimeout, callback)) | ||
| 72 | { | ||
| 73 | } | ||
| 74 | //---------------------------------------------------------------------------- | ||
| 75 | |||
| 76 | //============================================================================ | ||
| 77 | /// @ingroup cpp_kodi_tools_CTimer | ||
| 78 | /// @brief Class constructor to pass individual function as callback. | ||
| 79 | /// | ||
| 80 | /// @param[in] callback Function to pass as callback about timeout. | ||
| 81 | /// | ||
| 82 | /// **Callback function style:** | ||
| 83 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 84 | /// void TimerCallback() | ||
| 85 | /// { | ||
| 86 | /// } | ||
| 87 | /// ~~~~~~~~~~~~~ | ||
| 88 | explicit CTimer(std::function<void()> const& callback) : m_callback(callback) {} | ||
| 89 | //---------------------------------------------------------------------------- | ||
| 90 | |||
| 91 | //============================================================================ | ||
| 92 | /// @ingroup cpp_kodi_tools_CTimer | ||
| 93 | /// @brief Class destructor. | ||
| 94 | /// | ||
| 95 | ~CTimer() override { Stop(true); } | ||
| 96 | //---------------------------------------------------------------------------- | ||
| 97 | |||
| 98 | //============================================================================ | ||
| 99 | /// @ingroup cpp_kodi_tools_CTimer | ||
| 100 | /// @brief Start the timer by given time in milliseconds to make his call | ||
| 101 | /// by arrive of them. | ||
| 102 | /// | ||
| 103 | /// If interval is activated, it calls the associated callback function | ||
| 104 | /// continuously in the given interval. | ||
| 105 | /// | ||
| 106 | /// @param[in] timeout Timeout in milliseconds | ||
| 107 | /// @param[in] interval [opt] To run continuously if true, false only one time | ||
| 108 | /// and default | ||
| 109 | /// @return True if successfully done, false if not (callback missing, | ||
| 110 | /// timeout = 0 or was already running. | ||
| 111 | /// | ||
| 112 | bool Start(uint64_t timeout, bool interval = false) | ||
| 113 | { | ||
| 114 | using namespace std::chrono; | ||
| 115 | |||
| 116 | if (m_callback == nullptr || timeout == 0 || IsRunning()) | ||
| 117 | return false; | ||
| 118 | |||
| 119 | m_timeout = milliseconds(timeout); | ||
| 120 | m_interval = interval; | ||
| 121 | |||
| 122 | CreateThread(); | ||
| 123 | return true; | ||
| 124 | } | ||
| 125 | //---------------------------------------------------------------------------- | ||
| 126 | |||
| 127 | //============================================================================ | ||
| 128 | /// @ingroup cpp_kodi_tools_CTimer | ||
| 129 | /// @brief Stop the timer if it is active. | ||
| 130 | /// | ||
| 131 | /// @param[in] wait [opt] Wait until timer is stopped, false is default and | ||
| 132 | /// call unblocked | ||
| 133 | /// @return True if timer was active and was stopped, false if already was | ||
| 134 | /// stopped. | ||
| 135 | /// | ||
| 136 | bool Stop(bool wait = false) | ||
| 137 | { | ||
| 138 | if (!IsRunning()) | ||
| 139 | return false; | ||
| 140 | |||
| 141 | m_threadStop = true; | ||
| 142 | m_eventTimeout.notify_all(); | ||
| 143 | StopThread(wait); | ||
| 144 | |||
| 145 | return true; | ||
| 146 | } | ||
| 147 | //---------------------------------------------------------------------------- | ||
| 148 | |||
| 149 | //============================================================================ | ||
| 150 | /// @ingroup cpp_kodi_tools_CTimer | ||
| 151 | /// @brief Restart timer complete by stop and restart his thread again. | ||
| 152 | /// | ||
| 153 | /// @note Restart only possible as long the timer was running and not done his | ||
| 154 | /// work. | ||
| 155 | /// | ||
| 156 | /// @return True if start was successfully done, on error, or if was already | ||
| 157 | /// finished returned as false | ||
| 158 | /// | ||
| 159 | bool Restart() | ||
| 160 | { | ||
| 161 | using namespace std::chrono; | ||
| 162 | |||
| 163 | if (!IsRunning()) | ||
| 164 | return false; | ||
| 165 | |||
| 166 | Stop(true); | ||
| 167 | return Start(duration_cast<milliseconds>(m_timeout).count(), m_interval); | ||
| 168 | } | ||
| 169 | //---------------------------------------------------------------------------- | ||
| 170 | |||
| 171 | //============================================================================ | ||
| 172 | /// @ingroup cpp_kodi_tools_CTimer | ||
| 173 | /// @brief Restart the timer with new timeout without touch of his thread. | ||
| 174 | /// | ||
| 175 | /// @param[in] timeout Time as milliseconds to wait for next call | ||
| 176 | /// | ||
| 177 | void RestartAsync(uint64_t timeout) | ||
| 178 | { | ||
| 179 | using namespace std::chrono; | ||
| 180 | |||
| 181 | m_timeout = milliseconds(timeout); | ||
| 182 | const auto now = system_clock::now(); | ||
| 183 | m_endTime = now.time_since_epoch() + m_timeout; | ||
| 184 | m_eventTimeout.notify_all(); | ||
| 185 | } | ||
| 186 | //---------------------------------------------------------------------------- | ||
| 187 | |||
| 188 | //============================================================================ | ||
| 189 | /// @ingroup cpp_kodi_tools_CTimer | ||
| 190 | /// @brief Check timer is still active to wait for next call. | ||
| 191 | /// | ||
| 192 | /// @return True if active, false if all his work done and no more running | ||
| 193 | /// | ||
| 194 | bool IsRunning() const { return CThread::IsRunning(); } | ||
| 195 | //---------------------------------------------------------------------------- | ||
| 196 | |||
| 197 | //============================================================================ | ||
| 198 | /// @ingroup cpp_kodi_tools_CTimer | ||
| 199 | /// @brief Get elapsed time as floating point of timer as seconds. | ||
| 200 | /// | ||
| 201 | /// @return Elapsed time | ||
| 202 | /// | ||
| 203 | float GetElapsedSeconds() const { return GetElapsedMilliseconds() / 1000.0f; } | ||
| 204 | //---------------------------------------------------------------------------- | ||
| 205 | |||
| 206 | //============================================================================ | ||
| 207 | /// @ingroup cpp_kodi_tools_CTimer | ||
| 208 | /// @brief Get elapsed time as floating point of timer as milliseconds. | ||
| 209 | /// | ||
| 210 | /// @return Elapsed time | ||
| 211 | /// | ||
| 212 | float GetElapsedMilliseconds() const | ||
| 213 | { | ||
| 214 | using namespace std::chrono; | ||
| 215 | |||
| 216 | if (!IsRunning()) | ||
| 217 | return 0.0f; | ||
| 218 | |||
| 219 | const auto now = system_clock::now(); | ||
| 220 | return static_cast<float>(duration_cast<milliseconds>(now.time_since_epoch() - (m_endTime - m_timeout)).count()); | ||
| 221 | } | ||
| 222 | //---------------------------------------------------------------------------- | ||
| 223 | |||
| 224 | //============================================================================ | ||
| 225 | /// @defgroup cpp_kodi_tools_CTimer_CB class ITimerCallback | ||
| 226 | /// @ingroup cpp_kodi_tools_CTimer | ||
| 227 | /// @brief **Callback class of timer**\n | ||
| 228 | /// To give on contructor by @ref CTimer(kodi::tools::CTimer::ITimerCallback* callback) | ||
| 229 | /// | ||
| 230 | class ITimerCallback | ||
| 231 | { | ||
| 232 | public: | ||
| 233 | //========================================================================== | ||
| 234 | /// @ingroup cpp_kodi_tools_CTimer_CB | ||
| 235 | /// @brief Class destructor. | ||
| 236 | /// | ||
| 237 | virtual ~ITimerCallback() = default; | ||
| 238 | //-------------------------------------------------------------------------- | ||
| 239 | |||
| 240 | //========================================================================== | ||
| 241 | /// @ingroup cpp_kodi_tools_CTimer_CB | ||
| 242 | /// @brief Callback function to implement if constuctor @ref CTimer(kodi::tools::CTimer::ITimerCallback* callback) | ||
| 243 | /// is used and this as parent on related class | ||
| 244 | /// | ||
| 245 | /// ---------------------------------------------------------------------------- | ||
| 246 | /// | ||
| 247 | /// **Example:** | ||
| 248 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 249 | /// #include <kodi/tools/Timer.h> | ||
| 250 | /// | ||
| 251 | /// class CExample : public kodi::tools::CTimer, | ||
| 252 | /// private kodi::tools::CTimer::ITimerCallback | ||
| 253 | /// { | ||
| 254 | /// public: | ||
| 255 | /// CExample() : kodi::tools::CTimer(this) | ||
| 256 | /// { | ||
| 257 | /// } | ||
| 258 | /// | ||
| 259 | /// void OnTimeout() override | ||
| 260 | /// { | ||
| 261 | /// // Some work | ||
| 262 | /// } | ||
| 263 | /// }; | ||
| 264 | /// | ||
| 265 | /// ~~~~~~~~~~~~~ | ||
| 266 | /// | ||
| 267 | virtual void OnTimeout() = 0; | ||
| 268 | //-------------------------------------------------------------------------- | ||
| 269 | }; | ||
| 270 | //---------------------------------------------------------------------------- | ||
| 271 | |||
| 272 | protected: | ||
| 273 | void Process() override | ||
| 274 | { | ||
| 275 | using namespace std::chrono; | ||
| 276 | |||
| 277 | while (!m_threadStop) | ||
| 278 | { | ||
| 279 | auto currentTime = system_clock::now(); | ||
| 280 | m_endTime = currentTime.time_since_epoch() + m_timeout; | ||
| 281 | |||
| 282 | // wait the necessary time | ||
| 283 | std::mutex mutex; | ||
| 284 | std::unique_lock<std::mutex> lock(mutex); | ||
| 285 | const auto waitTime = duration_cast<milliseconds>(m_endTime - currentTime.time_since_epoch()); | ||
| 286 | if (m_eventTimeout.wait_for(lock, waitTime) == std::cv_status::timeout) | ||
| 287 | { | ||
| 288 | currentTime = system_clock::now(); | ||
| 289 | if (m_endTime.count() <= currentTime.time_since_epoch().count()) | ||
| 290 | { | ||
| 291 | // execute OnTimeout() callback | ||
| 292 | m_callback(); | ||
| 293 | |||
| 294 | // continue if this is an interval timer, or if it was restarted during callback | ||
| 295 | if (!m_interval && m_endTime.count() <= currentTime.time_since_epoch().count()) | ||
| 296 | break; | ||
| 297 | } | ||
| 298 | } | ||
| 299 | } | ||
| 300 | } | ||
| 301 | |||
| 302 | private: | ||
| 303 | bool m_interval = false; | ||
| 304 | std::function<void()> m_callback; | ||
| 305 | std::chrono::system_clock::duration m_timeout; | ||
| 306 | std::chrono::system_clock::duration m_endTime; | ||
| 307 | std::condition_variable_any m_eventTimeout; | ||
| 308 | }; | ||
| 309 | ///@} | ||
| 310 | //------------------------------------------------------------------------------ | ||
| 311 | |||
| 312 | } /* namespace tools */ | ||
| 313 | } /* namespace kodi */ | ||
| 314 | |||
| 315 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h b/xbmc/addons/kodi-dev-kit/include/kodi/versions.h index 041e22b..e632f5a 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/versions.h | |||
| @@ -46,10 +46,11 @@ | |||
| 46 | #define ADDON_GLOBAL_VERSION_GENERAL_XML_ID "kodi.binary.global.general" | 46 | #define ADDON_GLOBAL_VERSION_GENERAL_XML_ID "kodi.binary.global.general" |
| 47 | #define ADDON_GLOBAL_VERSION_GENERAL_DEPENDS "General.h" | 47 | #define ADDON_GLOBAL_VERSION_GENERAL_DEPENDS "General.h" |
| 48 | 48 | ||
| 49 | #define ADDON_GLOBAL_VERSION_GUI "5.14.1" | 49 | #define ADDON_GLOBAL_VERSION_GUI "5.15.0" |
| 50 | #define ADDON_GLOBAL_VERSION_GUI_MIN "5.14.0" | 50 | #define ADDON_GLOBAL_VERSION_GUI_MIN "5.15.0" |
| 51 | #define ADDON_GLOBAL_VERSION_GUI_XML_ID "kodi.binary.global.gui" | 51 | #define ADDON_GLOBAL_VERSION_GUI_XML_ID "kodi.binary.global.gui" |
| 52 | #define ADDON_GLOBAL_VERSION_GUI_DEPENDS "ActionIDs.h" \ | 52 | #define ADDON_GLOBAL_VERSION_GUI_DEPENDS "c-api/gui/input/action_ids.h" \ |
| 53 | "c-api/gui/" \ | ||
| 53 | "gui/" | 54 | "gui/" |
| 54 | 55 | ||
| 55 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE "1.1.1" | 56 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE "1.1.1" |
| @@ -58,7 +59,7 @@ | |||
| 58 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE_DEPENDS "AudioEngine.h" \ | 59 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE_DEPENDS "AudioEngine.h" \ |
| 59 | "c-api/audio_engine.h" | 60 | "c-api/audio_engine.h" |
| 60 | 61 | ||
| 61 | #define ADDON_GLOBAL_VERSION_FILESYSTEM "1.1.4" | 62 | #define ADDON_GLOBAL_VERSION_FILESYSTEM "1.1.6" |
| 62 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_MIN "1.1.0" | 63 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_MIN "1.1.0" |
| 63 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_XML_ID "kodi.binary.global.filesystem" | 64 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_XML_ID "kodi.binary.global.filesystem" |
| 64 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_DEPENDS "Filesystem.h" \ | 65 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_DEPENDS "Filesystem.h" \ |
| @@ -72,23 +73,29 @@ | |||
| 72 | #define ADDON_GLOBAL_VERSION_NETWORK_DEPENDS "Network.h" \ | 73 | #define ADDON_GLOBAL_VERSION_NETWORK_DEPENDS "Network.h" \ |
| 73 | "c-api/network.h" | 74 | "c-api/network.h" |
| 74 | 75 | ||
| 75 | #define ADDON_GLOBAL_VERSION_TOOLS "1.0.1" | 76 | #define ADDON_GLOBAL_VERSION_TOOLS "1.0.4" |
| 76 | #define ADDON_GLOBAL_VERSION_TOOLS_MIN "1.0.0" | 77 | #define ADDON_GLOBAL_VERSION_TOOLS_MIN "1.0.0" |
| 77 | #define ADDON_GLOBAL_VERSION_TOOLS_XML_ID "kodi.binary.global.tools" | 78 | #define ADDON_GLOBAL_VERSION_TOOLS_XML_ID "kodi.binary.global.tools" |
| 78 | #define ADDON_GLOBAL_VERSION_TOOLS_DEPENDS "tools/DllHelper.h" | 79 | #define ADDON_GLOBAL_VERSION_TOOLS_DEPENDS "tools/DllHelper.h" \ |
| 79 | 80 | "tools/EndTime.h" \ | |
| 80 | #define ADDON_INSTANCE_VERSION_AUDIODECODER "2.0.2" | 81 | "tools/StringUtils.h" \ |
| 81 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_MIN "2.0.1" | 82 | "tools/Thread.h" \ |
| 83 | "tools/Timer.h" | ||
| 84 | |||
| 85 | #define ADDON_INSTANCE_VERSION_AUDIODECODER "3.0.0" | ||
| 86 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_MIN "3.0.0" | ||
| 82 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_XML_ID "kodi.binary.instance.audiodecoder" | 87 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_XML_ID "kodi.binary.instance.audiodecoder" |
| 83 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_DEPENDS "addon-instance/AudioDecoder.h" | 88 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_DEPENDS "c-api/addon-instance/audio_decoder.h" \ |
| 89 | "addon-instance/AudioDecoder.h" | ||
| 84 | 90 | ||
| 85 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER "2.0.2" | 91 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER "2.1.0" |
| 86 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_MIN "2.0.1" | 92 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_MIN "2.1.0" |
| 87 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_XML_ID "kodi.binary.instance.audioencoder" | 93 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_XML_ID "kodi.binary.instance.audioencoder" |
| 88 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_DEPENDS "addon-instance/AudioEncoder.h" | 94 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_DEPENDS "c-api/addon-instance/audio_encoder.h" \ |
| 95 | "addon-instance/AudioEncoder.h" | ||
| 89 | 96 | ||
| 90 | #define ADDON_INSTANCE_VERSION_GAME "2.0.2" | 97 | #define ADDON_INSTANCE_VERSION_GAME "2.1.0" |
| 91 | #define ADDON_INSTANCE_VERSION_GAME_MIN "2.0.1" | 98 | #define ADDON_INSTANCE_VERSION_GAME_MIN "2.1.0" |
| 92 | #define ADDON_INSTANCE_VERSION_GAME_XML_ID "kodi.binary.instance.game" | 99 | #define ADDON_INSTANCE_VERSION_GAME_XML_ID "kodi.binary.instance.game" |
| 93 | #define ADDON_INSTANCE_VERSION_GAME_DEPENDS "addon-instance/Game.h" | 100 | #define ADDON_INSTANCE_VERSION_GAME_DEPENDS "addon-instance/Game.h" |
| 94 | 101 | ||
| @@ -97,13 +104,13 @@ | |||
| 97 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER_XML_ID "kodi.binary.instance.imagedecoder" | 104 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER_XML_ID "kodi.binary.instance.imagedecoder" |
| 98 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER_DEPENDS "addon-instance/ImageDecoder.h" | 105 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER_DEPENDS "addon-instance/ImageDecoder.h" |
| 99 | 106 | ||
| 100 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM "2.3.3" | 107 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM "2.3.4" |
| 101 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_MIN "2.3.1" | 108 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_MIN "2.3.4" |
| 102 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_XML_ID "kodi.binary.instance.inputstream" | 109 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_XML_ID "kodi.binary.instance.inputstream" |
| 103 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_DEPENDS "addon-instance/Inputstream.h" | 110 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_DEPENDS "addon-instance/Inputstream.h" |
| 104 | 111 | ||
| 105 | #define ADDON_INSTANCE_VERSION_PERIPHERAL "1.3.9" | 112 | #define ADDON_INSTANCE_VERSION_PERIPHERAL "2.0.0" |
| 106 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_MIN "1.3.8" | 113 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_MIN "2.0.0" |
| 107 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_XML_ID "kodi.binary.instance.peripheral" | 114 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_XML_ID "kodi.binary.instance.peripheral" |
| 108 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_DEPENDS "addon-instance/Peripheral.h" \ | 115 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_DEPENDS "addon-instance/Peripheral.h" \ |
| 109 | "addon-instance/PeripheralUtils.h" | 116 | "addon-instance/PeripheralUtils.h" |
| @@ -133,23 +140,26 @@ | |||
| 133 | "addon-instance/pvr/Stream.h" \ | 140 | "addon-instance/pvr/Stream.h" \ |
| 134 | "addon-instance/pvr/Timers.h" | 141 | "addon-instance/pvr/Timers.h" |
| 135 | 142 | ||
| 136 | #define ADDON_INSTANCE_VERSION_SCREENSAVER "2.0.2" | 143 | #define ADDON_INSTANCE_VERSION_SCREENSAVER "2.1.0" |
| 137 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_MIN "2.0.1" | 144 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_MIN "2.1.0" |
| 138 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_XML_ID "kodi.binary.instance.screensaver" | 145 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_XML_ID "kodi.binary.instance.screensaver" |
| 139 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_DEPENDS "addon-instance/Screensaver.h" | 146 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_DEPENDS "c-api/addon-instance/screensaver.h" \ |
| 147 | "addon-instance/Screensaver.h" | ||
| 140 | 148 | ||
| 141 | #define ADDON_INSTANCE_VERSION_VFS "2.3.2" | 149 | #define ADDON_INSTANCE_VERSION_VFS "3.0.0" |
| 142 | #define ADDON_INSTANCE_VERSION_VFS_MIN "2.3.1" | 150 | #define ADDON_INSTANCE_VERSION_VFS_MIN "3.0.0" |
| 143 | #define ADDON_INSTANCE_VERSION_VFS_XML_ID "kodi.binary.instance.vfs" | 151 | #define ADDON_INSTANCE_VERSION_VFS_XML_ID "kodi.binary.instance.vfs" |
| 144 | #define ADDON_INSTANCE_VERSION_VFS_DEPENDS "addon-instance/VFS.h" | 152 | #define ADDON_INSTANCE_VERSION_VFS_DEPENDS "c-api/addon-instance/vfs.h" \ |
| 153 | "addon-instance/VFS.h" | ||
| 145 | 154 | ||
| 146 | #define ADDON_INSTANCE_VERSION_VISUALIZATION "2.0.4" | 155 | #define ADDON_INSTANCE_VERSION_VISUALIZATION "3.0.0" |
| 147 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_MIN "2.0.3" | 156 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_MIN "3.0.0" |
| 148 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_XML_ID "kodi.binary.instance.visualization" | 157 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_XML_ID "kodi.binary.instance.visualization" |
| 149 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_DEPENDS "addon-instance/Visualization.h" | 158 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_DEPENDS "addon-instance/Visualization.h" \ |
| 159 | "c-api/addon-instance/visualization.h" | ||
| 150 | 160 | ||
| 151 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC "1.0.3" | 161 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC "1.0.4" |
| 152 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC_MIN "1.0.2" | 162 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC_MIN "1.0.4" |
| 153 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC_XML_ID "kodi.binary.instance.videocodec" | 163 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC_XML_ID "kodi.binary.instance.videocodec" |
| 154 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC_DEPENDS "addon-instance/VideoCodec.h" \ | 164 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC_DEPENDS "addon-instance/VideoCodec.h" \ |
| 155 | "StreamCodec.h" \ | 165 | "StreamCodec.h" \ |
