diff options
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h')
| -rw-r--r-- | xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h | 310 |
1 files changed, 309 insertions, 1 deletions
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 index 39baae7..85cd7bc 100644 --- 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 | |||
| @@ -28,6 +28,11 @@ extern "C" | |||
| 28 | 28 | ||
| 29 | struct AddonInstance_Screensaver; | 29 | struct AddonInstance_Screensaver; |
| 30 | 30 | ||
| 31 | /*! | ||
| 32 | * @brief Screensaver properties | ||
| 33 | * | ||
| 34 | * Not to be used outside this header. | ||
| 35 | */ | ||
| 31 | typedef struct AddonProps_Screensaver | 36 | typedef struct AddonProps_Screensaver |
| 32 | { | 37 | { |
| 33 | void *device; | 38 | void *device; |
| @@ -41,11 +46,21 @@ typedef struct AddonProps_Screensaver | |||
| 41 | const char *profile; | 46 | const char *profile; |
| 42 | } AddonProps_Screensaver; | 47 | } AddonProps_Screensaver; |
| 43 | 48 | ||
| 49 | /*! | ||
| 50 | * @brief Screensaver callbacks | ||
| 51 | * | ||
| 52 | * Not to be used outside this header. | ||
| 53 | */ | ||
| 44 | typedef struct AddonToKodiFuncTable_Screensaver | 54 | typedef struct AddonToKodiFuncTable_Screensaver |
| 45 | { | 55 | { |
| 46 | KODI_HANDLE kodiInstance; | 56 | KODI_HANDLE kodiInstance; |
| 47 | } AddonToKodiFuncTable_Screensaver; | 57 | } AddonToKodiFuncTable_Screensaver; |
| 48 | 58 | ||
| 59 | /*! | ||
| 60 | * @brief Screensaver function hooks | ||
| 61 | * | ||
| 62 | * Not to be used outside this header. | ||
| 63 | */ | ||
| 49 | typedef struct KodiToAddonFuncTable_Screensaver | 64 | typedef struct KodiToAddonFuncTable_Screensaver |
| 50 | { | 65 | { |
| 51 | kodi::addon::CInstanceScreensaver* addonInstance; | 66 | kodi::addon::CInstanceScreensaver* addonInstance; |
| @@ -54,6 +69,11 @@ typedef struct KodiToAddonFuncTable_Screensaver | |||
| 54 | void (__cdecl* Render) (AddonInstance_Screensaver* instance); | 69 | void (__cdecl* Render) (AddonInstance_Screensaver* instance); |
| 55 | } KodiToAddonFuncTable_Screensaver; | 70 | } KodiToAddonFuncTable_Screensaver; |
| 56 | 71 | ||
| 72 | /*! | ||
| 73 | * @brief Screensaver instance | ||
| 74 | * | ||
| 75 | * Not to be used outside this header. | ||
| 76 | */ | ||
| 57 | typedef struct AddonInstance_Screensaver | 77 | typedef struct AddonInstance_Screensaver |
| 58 | { | 78 | { |
| 59 | AddonProps_Screensaver props; | 79 | AddonProps_Screensaver props; |
| @@ -68,9 +88,157 @@ namespace kodi | |||
| 68 | namespace addon | 88 | namespace addon |
| 69 | { | 89 | { |
| 70 | 90 | ||
| 91 | //============================================================================ | ||
| 92 | /// | ||
| 93 | /// \addtogroup cpp_kodi_addon_screensaver | ||
| 94 | /// @brief \cpp_class{ kodi::addon::CInstanceScreensaver } | ||
| 95 | /// **Screensaver add-on instance** | ||
| 96 | /// | ||
| 97 | /// A screensaver is a Kodi addon that fills the screen with moving images or | ||
| 98 | /// patterns when the computer is not in use. Initially designed to prevent | ||
| 99 | /// phosphor burn-in on CRT and plasma computer monitors (hence the name), | ||
| 100 | /// screensavers are now used primarily for entertainment, security or to | ||
| 101 | /// display system status information. | ||
| 102 | /// | ||
| 103 | /// Include the header \ref ScreenSaver.h "#include <kodi/addon-instance/ScreenSaver.h>" | ||
| 104 | /// to use this class. | ||
| 105 | /// | ||
| 106 | /// This interface allows the creating of screensavers for Kodi, based upon | ||
| 107 | /// **DirectX** or/and **OpenGL** rendering with `C++` code. | ||
| 108 | /// | ||
| 109 | /// The interface is small and easy usable. It has three functions: | ||
| 110 | /// | ||
| 111 | /// * <b><c>Start()</c></b> - Called on creation | ||
| 112 | /// * <b><c>Render()</c></b> - Called at render time | ||
| 113 | /// * <b><c>Stop()</c></b> - Called when the screensaver has no work | ||
| 114 | /// | ||
| 115 | /// Additionally, there are several \ref cpp_kodi_addon_screensaver_CB "other functions" | ||
| 116 | /// available in which the child class can ask about the current hardware, | ||
| 117 | /// including the device, display and several other parts. | ||
| 118 | /// | ||
| 119 | /// | ||
| 120 | /// -------------------------------------------------------------------------- | ||
| 121 | /// | ||
| 122 | /// | ||
| 123 | /// **Here is an example of the minimum required code to start a screensaver:** | ||
| 124 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 125 | /// #include <kodi/addon-instance/Screensaver.h> | ||
| 126 | /// | ||
| 127 | /// class CMyScreenSaver : public kodi::addon::CAddonBase, | ||
| 128 | /// public kodi::addon::CInstanceScreensaver | ||
| 129 | /// { | ||
| 130 | /// public: | ||
| 131 | /// CMyScreenSaver(); | ||
| 132 | /// | ||
| 133 | /// bool Start() override; | ||
| 134 | /// void Render() override; | ||
| 135 | /// }; | ||
| 136 | /// | ||
| 137 | /// CMyScreenSaver::CMyScreenSaver() | ||
| 138 | /// { | ||
| 139 | /// ... | ||
| 140 | /// } | ||
| 141 | /// | ||
| 142 | /// bool CMyScreenSaver::Start() | ||
| 143 | /// { | ||
| 144 | /// ... | ||
| 145 | /// return true; | ||
| 146 | /// } | ||
| 147 | /// | ||
| 148 | /// void CMyScreenSaver::Render() | ||
| 149 | /// { | ||
| 150 | /// ... | ||
| 151 | /// } | ||
| 152 | /// | ||
| 153 | /// ADDONCREATOR(CMyScreenSaver) | ||
| 154 | /// ~~~~~~~~~~~~~ | ||
| 155 | /// | ||
| 156 | /// | ||
| 157 | /// -------------------------------------------------------------------------- | ||
| 158 | /// | ||
| 159 | /// | ||
| 160 | /// **Here is another example where the screensaver is used together with | ||
| 161 | /// other instance types:** | ||
| 162 | /// | ||
| 163 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 164 | /// #include <kodi/addon-instance/Screensaver.h> | ||
| 165 | /// | ||
| 166 | /// class CMyScreenSaver : public ::kodi::addon::CInstanceScreensaver | ||
| 167 | /// { | ||
| 168 | /// public: | ||
| 169 | /// CMyScreenSaver(KODI_HANDLE instance); | ||
| 170 | /// | ||
| 171 | /// bool Start() override; | ||
| 172 | /// void Render() override; | ||
| 173 | /// }; | ||
| 174 | /// | ||
| 175 | /// CMyScreenSaver::CMyScreenSaver(KODI_HANDLE instance) | ||
| 176 | /// : CInstanceScreensaver(instance) | ||
| 177 | /// { | ||
| 178 | /// ... | ||
| 179 | /// } | ||
| 180 | /// | ||
| 181 | /// bool CMyScreenSaver::Start() | ||
| 182 | /// { | ||
| 183 | /// ... | ||
| 184 | /// return true; | ||
| 185 | /// } | ||
| 186 | /// | ||
| 187 | /// void CMyScreenSaver::Render() | ||
| 188 | /// { | ||
| 189 | /// ... | ||
| 190 | /// } | ||
| 191 | /// | ||
| 192 | /// | ||
| 193 | /// /*----------------------------------------------------------------------*/ | ||
| 194 | /// | ||
| 195 | /// class CMyAddon : public ::kodi::addon::CAddonBase | ||
| 196 | /// { | ||
| 197 | /// public: | ||
| 198 | /// CMyAddon() { } | ||
| 199 | /// ADDON_STATUS CreateInstance(int instanceType, | ||
| 200 | /// std::string instanceID, | ||
| 201 | /// KODI_HANDLE instance, | ||
| 202 | /// KODI_HANDLE& addonInstance) override; | ||
| 203 | /// }; | ||
| 204 | /// | ||
| 205 | /// /* If you use only one instance in your add-on, can be instanceType and | ||
| 206 | /// * instanceID ignored */ | ||
| 207 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 208 | /// std::string instanceID, | ||
| 209 | /// KODI_HANDLE instance, | ||
| 210 | /// KODI_HANDLE& addonInstance) | ||
| 211 | /// { | ||
| 212 | /// if (instanceType == ADDON_INSTANCE_SCREENSAVER) | ||
| 213 | /// { | ||
| 214 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my Screensaver"); | ||
| 215 | /// addonInstance = new CMyScreenSaver(instance); | ||
| 216 | /// return ADDON_STATUS_OK; | ||
| 217 | /// } | ||
| 218 | /// else if (...) | ||
| 219 | /// { | ||
| 220 | /// ... | ||
| 221 | /// } | ||
| 222 | /// return ADDON_STATUS_UNKNOWN; | ||
| 223 | /// } | ||
| 224 | /// | ||
| 225 | /// ADDONCREATOR(CMyAddon) | ||
| 226 | /// ~~~~~~~~~~~~~ | ||
| 227 | /// | ||
| 228 | /// The destruction of the example class `CMyScreenSaver` is called from | ||
| 229 | /// Kodi's header. Manually deleting the add-on instance is not required. | ||
| 230 | /// | ||
| 231 | //---------------------------------------------------------------------------- | ||
| 71 | class CInstanceScreensaver : public IAddonInstance | 232 | class CInstanceScreensaver : public IAddonInstance |
| 72 | { | 233 | { |
| 73 | public: | 234 | public: |
| 235 | //========================================================================== | ||
| 236 | /// | ||
| 237 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 238 | /// @brief Screensaver class constructor | ||
| 239 | /// | ||
| 240 | /// Used by an add-on that only supports screensavers. | ||
| 241 | /// | ||
| 74 | CInstanceScreensaver() | 242 | CInstanceScreensaver() |
| 75 | : IAddonInstance(ADDON_INSTANCE_SCREENSAVER) | 243 | : IAddonInstance(ADDON_INSTANCE_SCREENSAVER) |
| 76 | { | 244 | { |
| @@ -80,7 +248,19 @@ namespace addon | |||
| 80 | SetAddonStruct(CAddonBase::m_interface->firstKodiInstance); | 248 | SetAddonStruct(CAddonBase::m_interface->firstKodiInstance); |
| 81 | CAddonBase::m_interface->globalSingleInstance = this; | 249 | CAddonBase::m_interface->globalSingleInstance = this; |
| 82 | } | 250 | } |
| 251 | //-------------------------------------------------------------------------- | ||
| 83 | 252 | ||
| 253 | //========================================================================== | ||
| 254 | /// | ||
| 255 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 256 | /// @brief Screensaver class constructor used to support multiple instance | ||
| 257 | /// types | ||
| 258 | /// | ||
| 259 | /// @param[in] instance The instance value given to | ||
| 260 | /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>. | ||
| 261 | /// | ||
| 262 | /// @warning Only use `instance` from the CreateInstance call | ||
| 263 | /// | ||
| 84 | CInstanceScreensaver(KODI_HANDLE instance) | 264 | CInstanceScreensaver(KODI_HANDLE instance) |
| 85 | : IAddonInstance(ADDON_INSTANCE_SCREENSAVER) | 265 | : IAddonInstance(ADDON_INSTANCE_SCREENSAVER) |
| 86 | { | 266 | { |
| @@ -89,22 +269,150 @@ namespace addon | |||
| 89 | 269 | ||
| 90 | SetAddonStruct(instance); | 270 | SetAddonStruct(instance); |
| 91 | } | 271 | } |
| 272 | //-------------------------------------------------------------------------- | ||
| 92 | 273 | ||
| 93 | virtual ~CInstanceScreensaver() { } | 274 | //========================================================================== |
| 275 | /// | ||
| 276 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 277 | /// @brief Destructor | ||
| 278 | /// | ||
| 279 | ~CInstanceScreensaver() override = default; | ||
| 280 | //-------------------------------------------------------------------------- | ||
| 94 | 281 | ||
| 282 | //========================================================================== | ||
| 283 | /// | ||
| 284 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 285 | /// @brief Used to notify the screensaver that it has been started | ||
| 286 | /// | ||
| 287 | /// @return true if the screensaver was started | ||
| 288 | /// successfully, false otherwise | ||
| 289 | /// | ||
| 95 | virtual bool Start() { return true; } | 290 | virtual bool Start() { return true; } |
| 291 | //-------------------------------------------------------------------------- | ||
| 292 | |||
| 293 | //========================================================================== | ||
| 294 | /// | ||
| 295 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 296 | /// @brief Used to inform the screensaver that the rendering control was | ||
| 297 | /// stopped | ||
| 298 | /// | ||
| 96 | virtual void Stop() {} | 299 | virtual void Stop() {} |
| 300 | //-------------------------------------------------------------------------- | ||
| 301 | |||
| 302 | //========================================================================== | ||
| 303 | /// | ||
| 304 | /// @ingroup cpp_kodi_addon_screensaver | ||
| 305 | /// @brief Used to indicate when the add-on should render | ||
| 306 | /// | ||
| 97 | virtual void Render() {} | 307 | virtual void Render() {} |
| 308 | //-------------------------------------------------------------------------- | ||
| 98 | 309 | ||
| 310 | //========================================================================== | ||
| 311 | /// | ||
| 312 | /// \defgroup cpp_kodi_addon_screensaver_CB Information functions | ||
| 313 | /// \ingroup cpp_kodi_addon_screensaver | ||
| 314 | /// @brief **To get info about the device, display and several other parts** | ||
| 315 | /// | ||
| 316 | //@{ | ||
| 317 | |||
| 318 | //========================================================================== | ||
| 319 | /// | ||
| 320 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 321 | /// @brief Device that represents the display adapter | ||
| 322 | /// | ||
| 323 | /// @return A pointer to the device | ||
| 324 | /// | ||
| 325 | /// @note This is only available on **DirectX**, It us unused (`nullptr`) on | ||
| 326 | /// **OpenGL** | ||
| 327 | /// | ||
| 99 | inline void* Device() { return m_instanceData->props.device; } | 328 | inline void* Device() { return m_instanceData->props.device; } |
| 329 | //-------------------------------------------------------------------------- | ||
| 330 | |||
| 331 | //========================================================================== | ||
| 332 | /// | ||
| 333 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 334 | /// @brief Returns the X position of the rendering window | ||
| 335 | /// | ||
| 336 | /// @return The X position, in pixels | ||
| 337 | /// | ||
| 100 | inline int X() { return m_instanceData->props.x; } | 338 | inline int X() { return m_instanceData->props.x; } |
| 339 | //-------------------------------------------------------------------------- | ||
| 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 | /// | ||
| 101 | inline int Y() { return m_instanceData->props.y; } | 348 | inline int Y() { return m_instanceData->props.y; } |
| 349 | //-------------------------------------------------------------------------- | ||
| 350 | |||
| 351 | //========================================================================== | ||
| 352 | /// | ||
| 353 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 354 | /// @brief Returns the width of the rendering window | ||
| 355 | /// | ||
| 356 | /// @return The width, in pixels | ||
| 357 | /// | ||
| 102 | inline int Width() { return m_instanceData->props.width; } | 358 | inline int Width() { return m_instanceData->props.width; } |
| 359 | //-------------------------------------------------------------------------- | ||
| 360 | |||
| 361 | //========================================================================== | ||
| 362 | /// | ||
| 363 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 364 | /// @brief Returns the height of the rendering window | ||
| 365 | /// | ||
| 366 | /// @return The height, in pixels | ||
| 367 | /// | ||
| 103 | inline int Height() { return m_instanceData->props.height; } | 368 | inline int Height() { return m_instanceData->props.height; } |
| 369 | //-------------------------------------------------------------------------- | ||
| 370 | |||
| 371 | //========================================================================== | ||
| 372 | /// | ||
| 373 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 374 | /// @brief Pixel aspect ratio (often abbreviated PAR) is a ratio that | ||
| 375 | /// describes how the width of a pixel compares to the height of that pixel. | ||
| 376 | /// | ||
| 377 | /// @return The pixel aspect ratio used by the display | ||
| 378 | /// | ||
| 104 | inline float PixelRatio() { return m_instanceData->props.pixelRatio; } | 379 | inline float PixelRatio() { return m_instanceData->props.pixelRatio; } |
| 380 | //-------------------------------------------------------------------------- | ||
| 381 | |||
| 382 | //========================================================================== | ||
| 383 | /// | ||
| 384 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 385 | /// @brief Used to get the name of the add-on defined in `addon.xml` | ||
| 386 | /// | ||
| 387 | /// @return The add-on name | ||
| 388 | /// | ||
| 105 | inline std::string Name() { return m_instanceData->props.name; } | 389 | inline std::string Name() { return m_instanceData->props.name; } |
| 390 | //-------------------------------------------------------------------------- | ||
| 391 | |||
| 392 | //========================================================================== | ||
| 393 | /// | ||
| 394 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 395 | /// @brief Used to get the full path where the add-on is installed | ||
| 396 | /// | ||
| 397 | /// @return The add-on installation path | ||
| 398 | /// | ||
| 106 | inline std::string Presets() { return m_instanceData->props.presets; } | 399 | inline std::string Presets() { return m_instanceData->props.presets; } |
| 400 | //-------------------------------------------------------------------------- | ||
| 401 | |||
| 402 | //========================================================================== | ||
| 403 | /// | ||
| 404 | /// @ingroup cpp_kodi_addon_screensaver_CB | ||
| 405 | /// @brief Used to get the full path to the add-on's user profile | ||
| 406 | /// | ||
| 407 | /// @note The trailing folder (consisting of the add-on's ID) is not created | ||
| 408 | /// by default. If it is needed, you must call kodi::vfs::CreateDirectory() | ||
| 409 | /// to create the folder. | ||
| 410 | /// | ||
| 411 | /// @return Path to the user profile | ||
| 412 | /// | ||
| 107 | inline std::string Profile() { return m_instanceData->props.profile; } | 413 | inline std::string Profile() { return m_instanceData->props.profile; } |
| 414 | //-------------------------------------------------------------------------- | ||
| 415 | //@} | ||
| 108 | 416 | ||
| 109 | private: | 417 | private: |
| 110 | void SetAddonStruct(KODI_HANDLE instance) | 418 | void SetAddonStruct(KODI_HANDLE instance) |
