From 1e5bdca69f7676b2dbcd64f0f44f31b12b337b7c Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 13 Dec 2016 13:45:04 +0100 Subject: sync with upstream --- xbmc/addons/addon-bindings.mk | 5 + .../include/kodi/kodi_game_callbacks.h | 161 +++++++ .../include/kodi/kodi_game_dll.h | 287 ++++++++++++ .../include/kodi/kodi_game_types.h | 487 +++++++++++++++++++++ .../include/kodi/kodi_inputstream_dll.h | 2 +- .../include/kodi/kodi_inputstream_types.h | 11 +- .../include/kodi/kodi_peripheral_types.h | 3 +- .../kodi-addon-dev-kit/include/kodi/libKODI_game.h | 238 ++++++++++ .../include/kodi/libKODI_guilib.h | 6 - .../include/kodi/libKODI_inputstream.h | 96 ++-- .../include/kodi/libXBMC_addon.h | 43 ++ .../kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h | 211 +++------ .../kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h | 2 +- .../include/kodi/xbmc_pvr_types.h | 6 +- xbmc/input/XBMC_vkeys.h | 286 ++++++++++++ 15 files changed, 1616 insertions(+), 228 deletions(-) create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_callbacks.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h create mode 100644 xbmc/input/XBMC_vkeys.h (limited to 'xbmc') diff --git a/xbmc/addons/addon-bindings.mk b/xbmc/addons/addon-bindings.mk index 6bfed36..788b50e 100644 --- a/xbmc/addons/addon-bindings.mk +++ b/xbmc/addons/addon-bindings.mk @@ -13,6 +13,9 @@ BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_types.h BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audioengine_types.h BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_codec_types.h BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h +BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_callbacks.h +BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h +BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_callbacks.h @@ -30,6 +33,7 @@ BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_types.h BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_adsp.h +BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_peripheral.h @@ -38,3 +42,4 @@ BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_codec.h BINDINGS+=xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h BINDINGS+=xbmc/cores/AudioEngine/Utils/AEChannelData.h BINDINGS+=xbmc/filesystem/IFileTypes.h +BINDINGS+=xbmc/input/XBMC_vkeys.h diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_callbacks.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_callbacks.h new file mode 100644 index 0000000..6057f46 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_callbacks.h @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2014-2016 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this Program; see the file COPYING. If not, see + * . + * + */ +#ifndef KODI_GAME_CALLBACKS_H_ +#define KODI_GAME_CALLBACKS_H_ + +#include "kodi_game_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct CB_GameLib +{ + // --- Game callbacks -------------------------------------------------------- + + /*! + * \brief Requests the frontend to stop the current game + */ + void (*CloseGame)(void* addonData); + + /*! + * \brief Create a video stream for pixel data + * + * \param format The type of pixel data accepted by this stream + * \param width The frame width + * \param height The frame height + * \param rotation The rotation (counter-clockwise) of the video frames + * + * \return 0 on success or -1 if a video stream is already created + */ + int (*OpenPixelStream)(void* addonData, GAME_PIXEL_FORMAT format, unsigned int width, unsigned int height, GAME_VIDEO_ROTATION rotation); + + /*! + * \brief Create a video stream for encoded video data + * + * \param codec The video format accepted by this stream + * + * \return 0 on success or -1 if a video stream is already created + */ + int (*OpenVideoStream)(void* addonData, GAME_VIDEO_CODEC codec); + + /*! + * \brief Create an audio stream for PCM audio data + * + * \param format The type of audio data accepted by this stream + * \param channel_map The channel layout terminated by GAME_CH_NULL + * + * \return 0 on success or -1 if an audio stream is already created + */ + int (*OpenPCMStream)(void* addonData, GAME_PCM_FORMAT format, const GAME_AUDIO_CHANNEL* channel_map); + + /*! + * \brief Create an audio stream for encoded audio data + * + * \param codec The audio format accepted by this stream + * \param channel_map The channel layout terminated by GAME_CH_NULL + * + * \return 0 on success or -1 if an audio stream is already created + */ + int(*OpenAudioStream)(void* addonData, GAME_AUDIO_CODEC codec, const GAME_AUDIO_CHANNEL* channel_map); + + /*! + * \brief Add a data packet to an audio or video stream + * + * \param stream The target stream + * \param data The data packet + * \param size The size of the data + */ + void (*AddStreamData)(void* addonData, GAME_STREAM_TYPE stream, const uint8_t* data, unsigned int size); + + /*! + * \brief Free the specified stream + * + * \param stream The stream to close + */ + void (*CloseStream)(void* addonData, GAME_STREAM_TYPE stream); + + // -- Hardware rendering callbacks ------------------------------------------- + + /*! + * \brief Enable hardware rendering + * + * \param hw_info A struct of properties for the hardware rendering system + */ + void (*EnableHardwareRendering)(void* addonData, const game_hw_info* hw_info); + + /*! + * \brief Get the framebuffer for rendering + * + * \return The framebuffer + */ + uintptr_t (*HwGetCurrentFramebuffer)(void* addonData); + + /*! + * \brief Get a symbol from the hardware context + * + * \param symbol The symbol's name + * + * \return A function pointer for the specified symbol + */ + game_proc_address_t (*HwGetProcAddress)(void* addonData, const char* symbol); + + /*! + * \brief Called when a frame is being rendered + */ + void (*RenderFrame)(void* addonData); + + // --- Input callbacks ------------------------------------------------------- + + /*! + * \brief Begin reporting events for the specified joystick port + * + * \param port The zero-indexed port number + * + * \return true if the port was opened, false otherwise + */ + bool (*OpenPort)(void* addonData, unsigned int port); + + /*! + * \brief End reporting events for the specified port + * + * \param port The port number passed to OpenPort() + */ + void (*ClosePort)(void* addonData, unsigned int port); + + /*! + * \brief Notify the port of an input event + * + * \param event The input event + * + * Input events can arrive for the following sources: + * - GAME_INPUT_EVENT_MOTOR + * + * \return true if the event was handled, false otherwise + */ + bool (*InputEvent)(void* addonData, const game_input_event* event); + +} CB_GameLib; + +#ifdef __cplusplus +} +#endif + +#endif // KODI_GAME_CALLBACKS_H_ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h new file mode 100644 index 0000000..247f24b --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h @@ -0,0 +1,287 @@ +/* + * Copyright (C) 2014-2016 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this Program; see the file COPYING. If not, see + * . + * + */ +#ifndef KODI_GAME_DLL_H_ +#define KODI_GAME_DLL_H_ + +#include "kodi_game_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// --- Game API operations ----------------------------------------------------- + +/*! + * \brief Return GAME_API_VERSION_STRING + * + * The add-on is backwards compatible with the frontend if this API version is + * is at least the frontend's minimum API version. + * + * \return Must be GAME_API_VERSION_STRING + */ +const char* GetGameAPIVersion(void); + +/*! + * \brief Return GAME_MIN_API_VERSION_STRING + * + * The add-on is forwards compatible with the frontend if this minimum version + * is no more than the frontend's API version. + * + * \return Must be GAME_MIN_API_VERSION_STRING + */ +const char* GetMininumGameAPIVersion(void); + +// --- Game operations --------------------------------------------------------- + +/*! + * \brief Load a game + * + * \param url The URL to load + * + * return the error, or GAME_ERROR_NO_ERROR if the game was loaded + */ +GAME_ERROR LoadGame(const char* url); + +/*! + * \brief Load a game that requires multiple files + * + * \param type The game stype + * \param urls An array of urls + * \param urlCount The number of urls in the array + * + * \return the error, or GAME_ERROR_NO_ERROR if the game was loaded + */ +GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const char** urls, size_t urlCount); + +/*! + * \brief Begin playing without a game file + * + * If the add-on supports standalone mode, it must add the + * tag to the extension point in addon.xml: + * + * false + * + * \return the error, or GAME_ERROR_NO_ERROR if the game add-on was loaded + */ +GAME_ERROR LoadStandalone(void); + +/*! + * \brief Unload the current game + * + * \return the error, or GAME_ERROR_NO_ERROR if the game was unloaded + */ +/*! Unloads a currently loaded game */ +GAME_ERROR UnloadGame(void); + +/*! + * \brief Get information about the loaded game + * + * \param info The info structure to fill + * + * \return the error, or GAME_ERROR_NO_ERROR if info was filled + */ +GAME_ERROR GetGameInfo(game_system_av_info* info); + +/*! + * \brief Get region of the loaded game + * + * \return the region, or GAME_REGION_UNKNOWN if unknown or no game is loaded + */ +GAME_REGION GetRegion(void); + +/*! + * \brief Return true if the client requires the frontend to provide a game loop + * + * The game loop is a thread that calls RunFrame() in a loop at a rate + * determined by the playback speed and the client's FPS. + * + * \return true if the frontend should provide a game loop, false otherwise + */ +bool RequiresGameLoop(void); + +/*! + * \brief Run a single frame for add-ons that use a game loop + * + * \return the error, or GAME_ERROR_NO_ERROR if there was no error + */ +GAME_ERROR RunFrame(void); + +/*! + * \brief Reset the current game + * + * \return the error, or GAME_ERROR_NO_ERROR if the game was reset + */ +GAME_ERROR Reset(void); + +// --- Hardware rendering operations ------------------------------------------- + +/*! + * \brief Invalidates the current HW context and reinitializes GPU resources + * + * Any GL state is lost, and must not be deinitialized explicitly. + * + * \return the error, or GAME_ERROR_NO_ERROR if the HW context was reset + */ +GAME_ERROR HwContextReset(void); + +/*! + * \brief Called before the context is destroyed + * + * Resources can be deinitialized at this step. + * + * \return the error, or GAME_ERROR_NO_ERROR if the HW context was destroyed + */ +GAME_ERROR HwContextDestroy(void); + +// --- Input operations -------------------------------------------------------- + +/*! + * \brief Notify the add-on of a status change on an open port + * + * Ports can be opened using the OpenPort() callback + * + * \param port Non-negative for a joystick port, or GAME_INPUT_PORT value otherwise + * \param collected True if a controller was connected, false if disconnected + * \param controller The connected controller + */ +void UpdatePort(int port, bool connected, const game_controller* controller); + +/*! + * \brief Check if input is accepted for a feature on the controller + * + * If only a subset of the controller profile is used, this can return false + * for unsupported features to not absorb their input. + * + * If the entire controller profile is used, this should always return true. + * + * \param controller_id The ID of the controller profile + * \param feature_name The name of a feature in that profile + * \return true if input is accepted for the feature, false otherwise + */ +bool HasFeature(const char* controller_id, const char* feature_name); + +/*! + * \brief Notify the add-on of an input event + * + * \param event The input event + * + * \return true if the event was handled, false otherwise + */ +bool InputEvent(const game_input_event* event); + +// --- Serialization operations ------------------------------------------------ + +/*! + * \brief Get the number of bytes required to serialize the game + * + * \return the number of bytes, or 0 if serialization is not supported + */ +size_t SerializeSize(void); + +/*! + * \brief Serialize the state of the game + * + * \param data The buffer receiving the serialized game data + * \param size The size of the buffer + * + * \return the error, or GAME_ERROR_NO_ERROR if the game was serialized into the buffer + */ +GAME_ERROR Serialize(uint8_t* data, size_t size); + +/*! + * \brief Deserialize the game from the given state + * + * \param data A buffer containing the game's new state + * \param size The size of the buffer + * + * \return the error, or GAME_ERROR_NO_ERROR if the game deserialized + */ +GAME_ERROR Deserialize(const uint8_t* data, size_t size); + +// --- Cheat operations -------------------------------------------------------- + +/*! + * \brief Reset the cheat system + * + * \return the error, or GAME_ERROR_NO_ERROR if the cheat system was reset + */ +GAME_ERROR CheatReset(void); + +/*! + * \brief Get a region of memory + * + * \param type The type of memory to retrieve + * \param data Set to the region of memory; must remain valid until UnloadGame() is called + * \param size Set to the size of the region of memory + * + * \return the error, or GAME_ERROR_NO_ERROR if data was set to a valid buffer + */ +GAME_ERROR GetMemory(GAME_MEMORY type, const uint8_t** data, size_t* size); + +/*! + * \brief Set a cheat code + * + * \param index + * \param enabled + * \param code + * + * \return the error, or GAME_ERROR_NO_ERROR if the cheat was set + */ +GAME_ERROR SetCheat(unsigned int index, bool enabled, const char* code); + +// --- Add-on helper implementation -------------------------------------------- + +/*! + * \brief Called by Kodi to assign the function pointers of this add-on to pClient + * + * Note that get_addon() is defined here, so it will be available in all + * compiled game clients. + */ +void __declspec(dllexport) get_addon(GameClient* pClient) +{ + pClient->GetGameAPIVersion = GetGameAPIVersion; + pClient->GetMininumGameAPIVersion = GetMininumGameAPIVersion; + pClient->LoadGame = LoadGame; + pClient->LoadGameSpecial = LoadGameSpecial; + pClient->LoadStandalone = LoadStandalone; + pClient->UnloadGame = UnloadGame; + pClient->GetGameInfo = GetGameInfo; + pClient->GetRegion = GetRegion; + pClient->RequiresGameLoop = RequiresGameLoop; + pClient->RunFrame = RunFrame; + pClient->Reset = Reset; + pClient->HwContextReset = HwContextReset; + pClient->HwContextDestroy = HwContextDestroy; + pClient->UpdatePort = UpdatePort; + pClient->HasFeature = HasFeature; + pClient->InputEvent = InputEvent; + pClient->SerializeSize = SerializeSize; + pClient->Serialize = Serialize; + pClient->Deserialize = Deserialize; + pClient->CheatReset = CheatReset; + pClient->GetMemory = GetMemory; + pClient->SetCheat = SetCheat; +} + +#ifdef __cplusplus +} +#endif + +#endif // KODI_GAME_DLL_H_ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h new file mode 100644 index 0000000..fa2762d --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h @@ -0,0 +1,487 @@ +/* + * Copyright (C) 2014-2016 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this Program; see the file COPYING. If not, see + * . + * + */ +#ifndef KODI_GAME_TYPES_H_ +#define KODI_GAME_TYPES_H_ + +/* current game API version */ +#define GAME_API_VERSION "1.0.28" + +/* min. game API version */ +#define GAME_MIN_API_VERSION "1.0.28" + +#include +#include + +#ifdef TARGET_WINDOWS + #include +#else + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __declspec + #define __declspec(X) + #endif +#endif + +#undef ATTRIBUTE_PACKED +#undef PRAGMA_PACK_BEGIN +#undef PRAGMA_PACK_END + +#if defined(__GNUC__) + #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) + #define ATTRIBUTE_PACKED __attribute__ ((packed)) + #define PRAGMA_PACK 0 + #endif +#endif + +#if !defined(ATTRIBUTE_PACKED) + #define ATTRIBUTE_PACKED + #define PRAGMA_PACK 1 +#endif + +#ifdef BUILD_KODI_ADDON +#include "XBMC_vkeys.h" +#else +#include "input/XBMC_vkeys.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*! Game add-on error codes */ +typedef enum GAME_ERROR +{ + GAME_ERROR_NO_ERROR, // no error occurred + GAME_ERROR_UNKNOWN, // an unknown error occurred + GAME_ERROR_NOT_IMPLEMENTED, // the method that the frontend called is not implemented + GAME_ERROR_REJECTED, // the command was rejected by the game client + GAME_ERROR_INVALID_PARAMETERS, // the parameters of the method that was called are invalid for this operation + GAME_ERROR_FAILED, // the command failed + GAME_ERROR_NOT_LOADED, // no game is loaded + GAME_ERROR_RESTRICTED, // game requires restricted resources +} GAME_ERROR; + +typedef enum GAME_STREAM_TYPE +{ + GAME_STREAM_UNKNOWN, + GAME_STREAM_AUDIO, + GAME_STREAM_VIDEO, +} GAME_STREAM_TYPE; + +typedef enum GAME_PIXEL_FORMAT +{ + GAME_PIXEL_FORMAT_UNKNOWN, + GAME_PIXEL_FORMAT_YUV420P, + GAME_PIXEL_FORMAT_0RGB8888, + GAME_PIXEL_FORMAT_RGB565, + GAME_PIXEL_FORMAT_0RGB1555, +} GAME_PIXEL_FORMAT; + +typedef enum GAME_VIDEO_CODEC +{ + GAME_VIDEO_CODEC_UNKNOWN, + GAME_VIDEO_CODEC_H264, + GAME_VIDEO_CODEC_THEORA, +} GAME_VIDEO_CODEC; + +typedef enum GAME_VIDEO_ROTATION // Counter-clockwise +{ + GAME_VIDEO_ROTATION_0, + GAME_VIDEO_ROTATION_90, + GAME_VIDEO_ROTATION_180, + GAME_VIDEO_ROTATION_270, +} GAME_VIDEO_ROTATION; + +typedef enum GAME_PCM_FORMAT +{ + GAME_PCM_FORMAT_UNKNOWN, + GAME_PCM_FORMAT_S16NE, +} GAME_PCM_FORMAT; + +typedef enum GAME_AUDIO_CODEC +{ + GAME_AUDIO_CODEC_UNKNOWN, + GAME_AUDIO_CODEC_OPUS, +} GAME_AUDIO_CODEC; + +typedef enum GAME_AUDIO_CHANNEL +{ + GAME_CH_NULL, // Channel list terminator + GAME_CH_FL, + GAME_CH_FR, + GAME_CH_FC, + GAME_CH_LFE, + GAME_CH_BL, + GAME_CH_BR, + GAME_CH_FLOC, + GAME_CH_FROC, + GAME_CH_BC, + GAME_CH_SL, + GAME_CH_SR, + GAME_CH_TFL, + GAME_CH_TFR, + GAME_CH_TFC, + GAME_CH_TC, + GAME_CH_TBL, + GAME_CH_TBR, + GAME_CH_TBC, + GAME_CH_BLOC, + GAME_CH_BROC, +} GAME_AUDIO_CHANNEL; + +// TODO +typedef enum GAME_HW_FRAME_BUFFER +{ + GAME_HW_FRAME_BUFFER_VALID, // Pass this to game_video_refresh if rendering to hardware + GAME_HW_FRAME_BUFFER_DUPLICATE, // Passing NULL to game_video_refresh is still a frame dupe as normal + GAME_HW_FRAME_BUFFER_RENDER, +} GAME_HW_FRAME_BUFFER; + +typedef enum GAME_HW_CONTEXT_TYPE +{ + GAME_HW_CONTEXT_NONE, + GAME_HW_CONTEXT_OPENGL, // OpenGL 2.x. Latest version available before 3.x+. Driver can choose to use latest compatibility context + GAME_HW_CONTEXT_OPENGLES2, // GLES 2.0 + GAME_HW_CONTEXT_OPENGL_CORE, // Modern desktop core GL context. Use major/minor fields to set GL version + GAME_HW_CONTEXT_OPENGLES3, // GLES 3.0 +} GAME_HW_CONTEXT_TYPE; + +typedef enum GAME_INPUT_PORT +{ + GAME_INPUT_PORT_JOYSTICK_START = 0, // Non-negative values are for joystick ports + GAME_INPUT_PORT_KEYBOARD = -1, + GAME_INPUT_PORT_MOUSE = -2, +} GAME_INPUT_PORT; + +typedef enum GAME_INPUT_EVENT_SOURCE +{ + GAME_INPUT_EVENT_DIGITAL_BUTTON, + GAME_INPUT_EVENT_ANALOG_BUTTON, + GAME_INPUT_EVENT_ANALOG_STICK, + GAME_INPUT_EVENT_ACCELEROMETER, + GAME_INPUT_EVENT_KEY, + GAME_INPUT_EVENT_RELATIVE_POINTER, + GAME_INPUT_EVENT_ABSOLUTE_POINTER, + GAME_INPUT_EVENT_MOTOR, +} GAME_INPUT_EVENT_SOURCE; + +typedef enum GAME_KEY_MOD +{ + GAME_KEY_MOD_NONE = 0x00, + + GAME_KEY_MOD_SHIFT = 0x01, + GAME_KEY_MOD_CTRL = 0x02, + GAME_KEY_MOD_ALT = 0x04, + GAME_KEY_MOD_RALT = 0x08, + GAME_KEY_MOD_META = 0x10, + + GAME_KEY_MOD_NUMLOCK = 0x20, + GAME_KEY_MOD_CAPSLOCK = 0x40, + GAME_KEY_MOD_SCROLLOCK = 0x80, +} GAME_KEY_MOD; + +/*! Returned from game_get_region() */ +typedef enum GAME_REGION +{ + GAME_REGION_UNKNOWN, + GAME_REGION_NTSC, + GAME_REGION_PAL, +} GAME_REGION; + +/*! +* Special game types passed into game_load_game_special(). Only used when +* multiple ROMs are required. +*/ +typedef enum SPECIAL_GAME_TYPE +{ + SPECIAL_GAME_TYPE_BSX, + SPECIAL_GAME_TYPE_BSX_SLOTTED, + SPECIAL_GAME_TYPE_SUFAMI_TURBO, + SPECIAL_GAME_TYPE_SUPER_GAME_BOY, +} SPECIAL_GAME_TYPE; + +typedef enum GAME_MEMORY +{ + /*! + * Passed to game_get_memory_data/size(). If the memory type doesn't apply + * to the implementation NULL/0 can be returned. + */ + GAME_MEMORY_MASK = 0xff, + + /*! + * Regular save ram. This ram is usually found on a game cartridge, backed + * up by a battery. If save game data is too complex for a single memory + * buffer, the SYSTEM_DIRECTORY environment callback can be used. + */ + GAME_MEMORY_SAVE_RAM = 0, + + /*! + * Some games have a built-in clock to keep track of time. This memory is + * usually just a couple of bytes to keep track of time. + */ + GAME_MEMORY_RTC = 1, + + /*! System ram lets a frontend peek into a game systems main RAM */ + GAME_MEMORY_SYSTEM_RAM = 2, + + /*! Video ram lets a frontend peek into a game systems video RAM (VRAM) */ + GAME_MEMORY_VIDEO_RAM = 3, + + /*! Special memory types */ + GAME_MEMORY_SNES_BSX_RAM = ((1 << 8) | GAME_MEMORY_SAVE_RAM), + GAME_MEMORY_SNES_BSX_PRAM = ((2 << 8) | GAME_MEMORY_SAVE_RAM), + GAME_MEMORY_SNES_SUFAMI_TURBO_A_RAM= ((3 << 8) | GAME_MEMORY_SAVE_RAM), + GAME_MEMORY_SNES_SUFAMI_TURBO_B_RAM= ((4 << 8) | GAME_MEMORY_SAVE_RAM), + GAME_MEMORY_SNES_GAME_BOY_RAM = ((5 << 8) | GAME_MEMORY_SAVE_RAM), + GAME_MEMORY_SNES_GAME_BOY_RTC = ((6 << 8) | GAME_MEMORY_RTC), +} GAME_MEMORY; + +/*! ID values for SIMD CPU features */ +typedef enum GAME_SIMD +{ + GAME_SIMD_SSE = (1 << 0), + GAME_SIMD_SSE2 = (1 << 1), + GAME_SIMD_VMX = (1 << 2), + GAME_SIMD_VMX128 = (1 << 3), + GAME_SIMD_AVX = (1 << 4), + GAME_SIMD_NEON = (1 << 5), + GAME_SIMD_SSE3 = (1 << 6), + GAME_SIMD_SSSE3 = (1 << 7), + GAME_SIMD_MMX = (1 << 8), + GAME_SIMD_MMXEXT = (1 << 9), + GAME_SIMD_SSE4 = (1 << 10), + GAME_SIMD_SSE42 = (1 << 11), + GAME_SIMD_AVX2 = (1 << 12), + GAME_SIMD_VFPU = (1 << 13), +} GAME_SIMD; + +typedef enum GAME_ROTATION +{ + GAME_ROTATION_0_CW, + GAME_ROTATION_90_CW, + GAME_ROTATION_180_CW, + GAME_ROTATION_270_CW, +} GAME_ROTATION; + +typedef struct game_controller +{ + const char* controller_id; + unsigned int digital_button_count; + unsigned int analog_button_count; + unsigned int analog_stick_count; + unsigned int accelerometer_count; + unsigned int key_count; + unsigned int rel_pointer_count; + unsigned int abs_pointer_count; + unsigned int motor_count; +} ATTRIBUTE_PACKED game_controller; + +typedef struct game_digital_button_event +{ + bool pressed; +} ATTRIBUTE_PACKED game_digital_button_event; + +typedef struct game_analog_button_event +{ + float magnitude; +} ATTRIBUTE_PACKED game_analog_button_event; + +typedef struct game_analog_stick_event +{ + float x; + float y; +} ATTRIBUTE_PACKED game_analog_stick_event; + +typedef struct game_accelerometer_event +{ + float x; + float y; + float z; +} ATTRIBUTE_PACKED game_accelerometer_event; + +typedef struct game_key_event +{ + bool pressed; + XBMCVKey character; + GAME_KEY_MOD modifiers; +} ATTRIBUTE_PACKED game_key_event; + +typedef struct game_rel_pointer_event +{ + int x; + int y; +} ATTRIBUTE_PACKED game_rel_pointer_event; + +typedef struct game_abs_pointer_event +{ + bool pressed; + float x; + float y; +} ATTRIBUTE_PACKED game_abs_pointer_event; + +typedef struct game_motor_event +{ + float magnitude; +} ATTRIBUTE_PACKED game_motor_event; + +typedef struct game_input_event +{ + GAME_INPUT_EVENT_SOURCE type; + int port; + const char* controller_id; + const char* feature_name; + union + { + struct game_digital_button_event digital_button; + struct game_analog_button_event analog_button; + struct game_analog_stick_event analog_stick; + struct game_accelerometer_event accelerometer; + struct game_key_event key; + struct game_rel_pointer_event rel_pointer; + struct game_abs_pointer_event abs_pointer; + struct game_motor_event motor; + }; +} ATTRIBUTE_PACKED game_input_event; + +struct game_geometry +{ + unsigned base_width; // Nominal video width of game + unsigned base_height; // Nominal video height of game + unsigned max_width; // Maximum possible width of game + unsigned max_height; // Maximum possible height of game + float aspect_ratio; // Nominal aspect ratio of game. If aspect_ratio is <= 0.0, + // an aspect ratio of base_width / base_height is assumed. + // A frontend could override this setting if desired. +}; + +struct game_system_timing +{ + double fps; // FPS of video content. + double sample_rate; // Sampling rate of audio. +}; + +struct game_system_av_info +{ + struct game_geometry geometry; + struct game_system_timing timing; +}; + +typedef void (*game_proc_address_t)(void); + +struct game_hw_info +{ + GAME_HW_CONTEXT_TYPE context_type; // Which API to use. Set by game client + bool depth; // Set if render buffers should have depth component attached + bool stencil; // Set if stencil buffers should be attached + // If depth and stencil are true, a packed 24/8 buffer will be added. Only attaching stencil is invalid and will be ignored + bool bottom_left_origin; // Use conventional bottom-left origin convention. Is false, standard top-left origin semantics are used + unsigned version_major; // Major version number for core GL context + unsigned version_minor; // Minor version number for core GL context + bool cache_context; // If this is true, the frontend will go very far to avoid resetting context in scenarios like toggling fullscreen, etc. + // The reset callback might still be called in extreme situations such as if the context is lost beyond recovery + // For optimal stability, set this to false, and allow context to be reset at any time + bool debug_context; // Creates a debug context +}; + +/*! Properties passed to the ADDON_Create() method of a game client */ +typedef struct game_client_properties +{ + /*! + * The path of the game client being loaded. + */ + const char* game_client_dll_path; + + /*! + * Paths to proxy DLLs used to load the game client. + */ + const char** proxy_dll_paths; + + /*! + * Number of proxy DLL paths provided. + */ + unsigned int proxy_dll_count; + + /*! + * The "system" directories of the frontend. These directories can be used to + * store system-specific ROMs such as BIOSes, configuration data, etc. + */ + const char** resource_directories; + + /*! + * Number of resource directories provided + */ + unsigned int resource_directory_count; + + /*! + * The writable directory of the frontend. This directory can be used to store + * SRAM, memory cards, high scores, etc, if the game client cannot use the + * regular memory interface, GetMemoryData(). + */ + const char* profile_directory; + + /*! + * The value of the property from addon.xml + */ + bool supports_vfs; + + /*! + * The extensions in the property from addon.xml + */ + const char** extensions; + + /*! + * Number of extensions provided + */ + unsigned int extension_count; +} game_client_properties; + +/*! Structure to transfer the methods from kodi_game_dll.h to Kodi */ +typedef struct GameClient +{ + const char* (__cdecl* GetGameAPIVersion)(void); + const char* (__cdecl* GetMininumGameAPIVersion)(void); + GAME_ERROR (__cdecl* LoadGame)(const char*); + GAME_ERROR (__cdecl* LoadGameSpecial)(SPECIAL_GAME_TYPE, const char**, size_t); + GAME_ERROR (__cdecl* LoadStandalone)(void); + GAME_ERROR (__cdecl* UnloadGame)(void); + GAME_ERROR (__cdecl* GetGameInfo)(game_system_av_info*); + GAME_REGION (__cdecl* GetRegion)(void); + bool (__cdecl* RequiresGameLoop)(void); + GAME_ERROR (__cdecl* RunFrame)(void); + GAME_ERROR (__cdecl* Reset)(void); + GAME_ERROR (__cdecl* HwContextReset)(void); + GAME_ERROR (__cdecl* HwContextDestroy)(void); + void (__cdecl* UpdatePort)(int, bool, const game_controller*); + bool (__cdecl* HasFeature)(const char* controller_id, const char* feature_name); + bool (__cdecl* InputEvent)(const game_input_event*); + size_t (__cdecl* SerializeSize)(void); + GAME_ERROR (__cdecl* Serialize)(uint8_t*, size_t); + GAME_ERROR (__cdecl* Deserialize)(const uint8_t*, size_t); + GAME_ERROR (__cdecl* CheatReset)(void); + GAME_ERROR (__cdecl* GetMemory)(GAME_MEMORY, const uint8_t**, size_t*); + GAME_ERROR (__cdecl* SetCheat)(unsigned int, bool, const char*); +} GameClient; + +#ifdef __cplusplus +} +#endif + +#endif // KODI_GAME_TYPES_H_ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h index 3721971..8dc49c0 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h @@ -122,7 +122,7 @@ extern "C" * @return True if the seek operation was possible * @remarks Optional, and only used if addon has its own demuxer. */ - bool DemuxSeekTime(int time, bool backwards, double *startpts); + bool DemuxSeekTime(double time, bool backwards, double *startpts); /*! * Notify the InputStream addon/demuxer that XBMC wishes to change playback speed diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h index ad47bb5..46e9d03 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h @@ -20,9 +20,16 @@ * */ +#ifdef TARGET_WINDOWS +#include +#else #ifndef __cdecl #define __cdecl #endif +#ifndef __declspec +#define __declspec(X) +#endif +#endif #ifdef BUILD_KODI_ADDON #include "DVDDemuxPacket.h" @@ -31,7 +38,7 @@ #endif /* current API version */ -#define INPUTSTREAM_API_VERSION "1.0.5" +#define INPUTSTREAM_API_VERSION "1.0.6" extern "C" { @@ -140,7 +147,7 @@ extern "C" { void (__cdecl* DemuxAbort)(void); void (__cdecl* DemuxFlush)(void); DemuxPacket* (__cdecl* DemuxRead)(void); - bool (__cdecl* DemuxSeekTime)(int, bool, double*); + bool (__cdecl* DemuxSeekTime)(double, bool, double*); void (__cdecl* DemuxSetSpeed)(int); void (__cdecl* SetVideoResolution)(int, int); diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h index 2df5622..d7c4282 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h @@ -51,7 +51,7 @@ #endif /* current Peripheral API version */ -#define PERIPHERAL_API_VERSION "1.2.0" +#define PERIPHERAL_API_VERSION "1.2.1" /* min. Peripheral API version */ #define PERIPHERAL_MIN_API_VERSION "1.2.0" @@ -84,6 +84,7 @@ extern "C" { PERIPHERAL_TYPE_UNKNOWN, PERIPHERAL_TYPE_JOYSTICK, + PERIPHERAL_TYPE_KEYBOARD, } PERIPHERAL_TYPE; typedef struct PERIPHERAL_INFO diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h new file mode 100644 index 0000000..b5a46dd --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h @@ -0,0 +1,238 @@ +/* + * Copyright (C) 2014-2016 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this Program; see the file COPYING. If not, see + * . + * + */ +#pragma once + +#include "libXBMC_addon.h" +#include "kodi_game_callbacks.h" + +#include +#include + +#if defined(ANDROID) + #include +#endif + +#ifdef _WIN32 + #define GAME_HELPER_DLL "\\library.kodi.game\\libKODI_game" ADDON_HELPER_EXT +#else + #define GAME_HELPER_DLL_NAME "libKODI_game-" ADDON_HELPER_ARCH ADDON_HELPER_EXT + #define GAME_HELPER_DLL "/library.kodi.game/" GAME_HELPER_DLL_NAME +#endif + +#define GAME_REGISTER_SYMBOL(dll, functionPtr) \ + CHelper_libKODI_game::RegisterSymbol(dll, functionPtr, #functionPtr) + +class CHelper_libKODI_game +{ +public: + CHelper_libKODI_game(void) : + GAME_register_me(nullptr), + GAME_unregister_me(nullptr), + GAME_close_game(nullptr), + GAME_open_pixel_stream(nullptr), + GAME_open_video_stream(nullptr), + GAME_open_pcm_stream(nullptr), + GAME_open_audio_stream(nullptr), + GAME_add_stream_data(nullptr), + GAME_close_stream(nullptr), + GAME_enable_hardware_rendering(nullptr), + GAME_hw_get_current_framebuffer(nullptr), + GAME_hw_get_proc_address(nullptr), + GAME_render_frame(nullptr), + GAME_open_port(nullptr), + GAME_close_port(nullptr), + GAME_input_event(nullptr), + m_handle(nullptr), + m_callbacks(nullptr), + m_libKODI_game(nullptr) + { + } + + ~CHelper_libKODI_game(void) + { + if (m_libKODI_game) + { + GAME_unregister_me(m_handle, m_callbacks); + dlclose(m_libKODI_game); + } + } + + template + static bool RegisterSymbol(void* dll, T& functionPtr, const char* strFunctionPtr) + { + return (functionPtr = (T)dlsym(dll, strFunctionPtr)) != NULL; + } + + /*! + * @brief Resolve all callback methods + * @param handle Pointer to the add-on + * @return True when all methods were resolved, false otherwise. + */ + bool RegisterMe(void* handle) + { + m_handle = handle; + + std::string libBasePath; + libBasePath = ((cb_array*)m_handle)->libBasePath; + libBasePath += GAME_HELPER_DLL; + +#if defined(ANDROID) + struct stat st; + if (stat(libBasePath.c_str(),&st) != 0) + { + std::string tempbin = getenv("XBMC_ANDROID_LIBS"); + libBasePath = tempbin + "/" + GAME_HELPER_DLL_NAME; + } +#endif + + m_libKODI_game = dlopen(libBasePath.c_str(), RTLD_LAZY); + if (m_libKODI_game == NULL) + { + fprintf(stderr, "Unable to load %s\n", dlerror()); + return false; + } + + try + { + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_register_me)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_unregister_me)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_close_game)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_pixel_stream)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_video_stream)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_pcm_stream)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_audio_stream)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_add_stream_data)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_close_stream)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_enable_hardware_rendering)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_hw_get_current_framebuffer)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_hw_get_proc_address)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_render_frame)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_port)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_close_port)) throw false; + if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_input_event)) throw false; + } + catch (const bool& bSuccess) + { + fprintf(stderr, "ERROR: Unable to assign function %s\n", dlerror()); + return bSuccess; + } + + m_callbacks = GAME_register_me(m_handle); + return m_callbacks != NULL; + } + + void CloseGame(void) + { + return GAME_close_game(m_handle, m_callbacks); + } + + bool OpenPixelStream(GAME_PIXEL_FORMAT format, unsigned int width, unsigned int height, GAME_VIDEO_ROTATION rotation) + { + return GAME_open_pixel_stream(m_handle, m_callbacks, format, width, height, rotation) == 0; + } + + bool OpenVideoStream(GAME_VIDEO_CODEC codec) + { + return GAME_open_video_stream(m_handle, m_callbacks, codec) == 0; + } + + bool OpenPCMStream(GAME_PCM_FORMAT format, const GAME_AUDIO_CHANNEL* channel_map) + { + return GAME_open_pcm_stream(m_handle, m_callbacks, format, channel_map) == 0; + } + + bool OpenAudioStream(GAME_AUDIO_CODEC codec, const GAME_AUDIO_CHANNEL* channel_map) + { + return GAME_open_audio_stream(m_handle, m_callbacks, codec, channel_map) == 0; + } + + void AddStreamData(GAME_STREAM_TYPE stream, const uint8_t* data, unsigned int size) + { + GAME_add_stream_data(m_handle, m_callbacks, stream, data, size); + } + + void CloseStream(GAME_STREAM_TYPE stream) + { + GAME_close_stream(m_handle, m_callbacks, stream); + } + + void EnableHardwareRendering(const struct game_hw_info* hw_info) + { + return GAME_enable_hardware_rendering(m_handle, m_callbacks, hw_info); + } + + uintptr_t HwGetCurrentFramebuffer(void) + { + return GAME_hw_get_current_framebuffer(m_handle, m_callbacks); + } + + game_proc_address_t HwGetProcAddress(const char* sym) + { + return GAME_hw_get_proc_address(m_handle, m_callbacks, sym); + } + + void RenderFrame() + { + return GAME_render_frame(m_handle, m_callbacks); + } + + bool OpenPort(unsigned int port) + { + return GAME_open_port(m_handle, m_callbacks, port); + } + + void ClosePort(unsigned int port) + { + return GAME_close_port(m_handle, m_callbacks, port); + } + + bool InputEvent(const game_input_event& event) + { + return GAME_input_event(m_handle, m_callbacks, &event); + } + +protected: + CB_GameLib* (*GAME_register_me)(void* handle); + void (*GAME_unregister_me)(void* handle, CB_GameLib* cb); + void (*GAME_close_game)(void* handle, CB_GameLib* cb); + int (*GAME_open_pixel_stream)(void* handle, CB_GameLib* cb, GAME_PIXEL_FORMAT, unsigned int, unsigned int, GAME_VIDEO_ROTATION); + int (*GAME_open_video_stream)(void* handle, CB_GameLib* cb, GAME_VIDEO_CODEC); + int (*GAME_open_pcm_stream)(void* handle, CB_GameLib* cb, GAME_PCM_FORMAT, const GAME_AUDIO_CHANNEL*); + int (*GAME_open_audio_stream)(void* handle, CB_GameLib* cb, GAME_AUDIO_CODEC, const GAME_AUDIO_CHANNEL*); + int (*GAME_add_stream_data)(void* handle, CB_GameLib* cb, GAME_STREAM_TYPE, const uint8_t*, unsigned int); + int (*GAME_close_stream)(void* handle, CB_GameLib* cb, GAME_STREAM_TYPE); + void (*GAME_enable_hardware_rendering)(void* handle, CB_GameLib* cb, const struct game_hw_info*); + uintptr_t (*GAME_hw_get_current_framebuffer)(void* handle, CB_GameLib* cb); + game_proc_address_t (*GAME_hw_get_proc_address)(void* handle, CB_GameLib* cb, const char*); + void (*GAME_render_frame)(void* handle, CB_GameLib* cb); + bool (*GAME_open_port)(void* handle, CB_GameLib* cb, unsigned int); + void (*GAME_close_port)(void* handle, CB_GameLib* cb, unsigned int); + bool (*GAME_input_event)(void* handle, CB_GameLib* cb, const game_input_event* event); + +private: + void* m_handle; + CB_GameLib* m_callbacks; + void* m_libKODI_game; + + struct cb_array + { + const char* libBasePath; + }; +}; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h index 3fe12c9..b699fa0 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h @@ -615,7 +615,6 @@ public: private: CAddonGUIWindow *m_Window; - int m_ControlId; GUIHANDLE m_SpinHandle; void *m_Handle; void *m_cb; @@ -634,7 +633,6 @@ public: private: CAddonGUIWindow *m_Window; - int m_ControlId; GUIHANDLE m_ButtonHandle; void *m_Handle; void *m_cb; @@ -654,7 +652,6 @@ public: private: CAddonGUIWindow *m_Window; - int m_ControlId; GUIHANDLE m_ProgressHandle; void *m_Handle; void *m_cb; @@ -684,7 +681,6 @@ public: private: CAddonGUIWindow *m_Window; - int m_ControlId; GUIHANDLE m_SliderHandle; void *m_Handle; void *m_cb; @@ -715,7 +711,6 @@ public: private: CAddonGUIWindow *m_Window; - int m_ControlId; GUIHANDLE m_SettingsSliderHandle; void *m_Handle; void *m_cb; @@ -825,7 +820,6 @@ public: private: CAddonGUIWindow *m_Window; - int m_ControlId; GUIHANDLE m_RenderingHandle; void *m_Handle; void *m_cb; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h index a6e83cb..c55a42b 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h @@ -33,27 +33,40 @@ #include "cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h" #endif -#define INPUTSTREAM_HELPER_DLL KODI_DLL("inputstream") -#define INPUTSTREAM_HELPER_DLL_NAME KODI_DLL_NAME("inputstream") - /* current input stream API version */ #define KODI_INPUTSTREAM_API_VERSION "1.0.0" +namespace KodiAPI +{ +namespace V1 +{ +namespace InputStream +{ + +typedef struct CB_INPUTSTREAMLib +{ + void (*FreeDemuxPacket)(void *addonData, DemuxPacket* pPacket); + DemuxPacket* (*AllocateDemuxPacket)(void *addonData, int iDataSize); +} CB_INPUTSTREAMLib; + +} /* namespace InputStream */ +} /* namespace V1 */ +} /* namespace KodiAPI */ + class CHelper_libKODI_inputstream { public: CHelper_libKODI_inputstream(void) { - m_libKODI_inputstream = nullptr; m_Handle = nullptr; + m_Callbacks = nullptr; } ~CHelper_libKODI_inputstream(void) { - if (m_libKODI_inputstream) + if (m_Handle && m_Callbacks) { - INPUTSTREAM_unregister_me(m_Handle, m_Callbacks); - dlclose(m_libKODI_inputstream); + m_Handle->INPUTSTREAMLib_UnRegisterMe(m_Handle->addonData, m_Callbacks); } } @@ -64,52 +77,12 @@ public: */ bool RegisterMe(void* handle) { - m_Handle = handle; - - std::string libBasePath; - libBasePath = ((cb_array*)m_Handle)->libPath; - libBasePath += INPUTSTREAM_HELPER_DLL; - - m_libKODI_inputstream = dlopen(libBasePath.c_str(), RTLD_LAZY); - if (m_libKODI_inputstream == nullptr) - { - fprintf(stderr, "Unable to load %s\n", dlerror()); - return false; - } - - INPUTSTREAM_register_me = (void* (*)(void *HANDLE)) - dlsym(m_libKODI_inputstream, "INPUTSTREAM_register_me"); - if (INPUTSTREAM_register_me == nullptr) - { - fprintf(stderr, "Unable to assign function %s\n", dlerror()); - return false; - } + m_Handle = static_cast(handle); + if (m_Handle) + m_Callbacks = (KodiAPI::V1::InputStream::CB_INPUTSTREAMLib*)m_Handle->INPUTSTREAMLib_RegisterMe(m_Handle->addonData); + if (!m_Callbacks) + fprintf(stderr, "libKODI_inputstream-ERROR: InputStream_RegisterMe can't get callback table from Kodi !!!\n"); - INPUTSTREAM_unregister_me = (void (*)(void* HANDLE, void* CB)) - dlsym(m_libKODI_inputstream, "INPUTSTREAM_unregister_me"); - if (INPUTSTREAM_unregister_me == nullptr) - { - fprintf(stderr, "Unable to assign function %s\n", dlerror()); - return false; - } - - INPUTSTREAM_free_demux_packet = (void (*)(void* HANDLE, void* CB, DemuxPacket* pPacket)) - dlsym(m_libKODI_inputstream, "INPUTSTREAM_free_demux_packet"); - if (INPUTSTREAM_free_demux_packet == NULL) - { - fprintf(stderr, "Unable to assign function %s\n", dlerror()); - return false; - } - - INPUTSTREAM_allocate_demux_packet = (DemuxPacket* (*)(void* HANDLE, void* CB, int iDataSize)) - dlsym(m_libKODI_inputstream, "INPUTSTREAM_allocate_demux_packet"); - if (INPUTSTREAM_allocate_demux_packet == NULL) - { - fprintf(stderr, "Unable to assign function %s\n", dlerror()); - return false; - } - - m_Callbacks = INPUTSTREAM_register_me(m_Handle); return m_Callbacks != nullptr; } @@ -120,7 +93,7 @@ public: */ DemuxPacket* AllocateDemuxPacket(int iDataSize) { - return INPUTSTREAM_allocate_demux_packet(m_Handle, m_Callbacks, iDataSize); + return m_Callbacks->AllocateDemuxPacket(m_Handle->addonData, iDataSize); } /*! @@ -129,21 +102,10 @@ public: */ void FreeDemuxPacket(DemuxPacket* pPacket) { - return INPUTSTREAM_free_demux_packet(m_Handle, m_Callbacks, pPacket); + return m_Callbacks->FreeDemuxPacket(m_Handle->addonData, pPacket); } -protected: - void* (*INPUTSTREAM_register_me)(void*); - void (*INPUTSTREAM_unregister_me)(void*, void*); - void (*INPUTSTREAM_free_demux_packet)(void*, void*, DemuxPacket*); - DemuxPacket* (*INPUTSTREAM_allocate_demux_packet)(void*, void*, int); - private: - void* m_libKODI_inputstream; - void* m_Handle; - void* m_Callbacks; - struct cb_array - { - const char* libPath; - }; + AddonCB* m_Handle; + KodiAPI::V1::InputStream::CB_INPUTSTREAMLib* m_Callbacks; }; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h index 70bd19b..d9f72c1 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h @@ -116,6 +116,49 @@ typedef intptr_t ssize_t; /* current addon API version */ #define KODI_ADDON_API_VERSION "1.0.0" +typedef void* (*KODIAddOnLib_RegisterMe)(void *addonData); +typedef void (*KODIAddOnLib_UnRegisterMe)(void *addonData, void *cbTable); +typedef void* (*KODIAudioEngineLib_RegisterMe)(void *addonData); +typedef void (*KODIAudioEngineLib_UnRegisterMe)(void *addonData, void *cbTable); +typedef void* (*KODIGUILib_RegisterMe)(void *addonData); +typedef void (*KODIGUILib_UnRegisterMe)(void *addonData, void *cbTable); +typedef void* (*KODIPVRLib_RegisterMe)(void *addonData); +typedef void (*KODIPVRLib_UnRegisterMe)(void *addonData, void *cbTable); +typedef void* (*KODIADSPLib_RegisterMe)(void *addonData); +typedef void (*KODIADSPLib_UnRegisterMe)(void *addonData, void *cbTable); +typedef void* (*KODICodecLib_RegisterMe)(void *addonData); +typedef void (*KODICodecLib_UnRegisterMe)(void *addonData, void *cbTable); +typedef void* (*KODIINPUTSTREAMLib_RegisterMe)(void *addonData); +typedef void (*KODIINPUTSTREAMLib_UnRegisterMe)(void *addonData, void *cbTable); +typedef void* (*KODIPeripheralLib_RegisterMe)(void *addonData); +typedef void (*KODIPeripheralLib_UnRegisterMe)(void *addonData, void *cbTable); +typedef void* (*KODIGameLib_RegisterMe)(void *addonData); +typedef void (*KODIGameLib_UnRegisterMe)(void *addonData, void *cbTable); + +typedef struct AddonCB +{ + const char* libBasePath; ///< Never, never change this!!! + void* addonData; + KODIAddOnLib_RegisterMe AddOnLib_RegisterMe; + KODIAddOnLib_UnRegisterMe AddOnLib_UnRegisterMe; + KODIAudioEngineLib_RegisterMe AudioEngineLib_RegisterMe; + KODIAudioEngineLib_UnRegisterMe AudioEngineLib_UnRegisterMe; + KODICodecLib_RegisterMe CodecLib_RegisterMe; + KODICodecLib_UnRegisterMe CodecLib_UnRegisterMe; + KODIGUILib_RegisterMe GUILib_RegisterMe; + KODIGUILib_UnRegisterMe GUILib_UnRegisterMe; + KODIPVRLib_RegisterMe PVRLib_RegisterMe; + KODIPVRLib_UnRegisterMe PVRLib_UnRegisterMe; + KODIADSPLib_RegisterMe ADSPLib_RegisterMe; + KODIADSPLib_UnRegisterMe ADSPLib_UnRegisterMe; + KODIINPUTSTREAMLib_RegisterMe INPUTSTREAMLib_RegisterMe; + KODIINPUTSTREAMLib_UnRegisterMe INPUTSTREAMLib_UnRegisterMe; + KODIPeripheralLib_RegisterMe PeripheralLib_RegisterMe; + KODIPeripheralLib_UnRegisterMe PeripheralLib_UnRegisterMe; + KODIGameLib_RegisterMe GameLib_RegisterMe; + KODIGameLib_UnRegisterMe GameLib_UnRegisterMe; +} AddonCB; + namespace ADDON { typedef enum addon_log diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h index a769328..3ae30a7 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h @@ -27,29 +27,60 @@ #include "xbmc_pvr_types.h" #include "libXBMC_addon.h" -#define PVR_HELPER_DLL_NAME XBMC_DLL_NAME("pvr") -#define PVR_HELPER_DLL XBMC_DLL("pvr") - #define DVD_TIME_BASE 1000000 //! @todo original definition is in DVDClock.h #define DVD_NOPTS_VALUE 0xFFF0000000000000 +namespace KodiAPI +{ +namespace V1 +{ +namespace PVR +{ + +typedef struct CB_PVRLib +{ + void (*TransferEpgEntry)(void *userData, const ADDON_HANDLE handle, const EPG_TAG *epgentry); + void (*TransferChannelEntry)(void *userData, const ADDON_HANDLE handle, const PVR_CHANNEL *chan); + void (*TransferTimerEntry)(void *userData, const ADDON_HANDLE handle, const PVR_TIMER *timer); + void (*TransferRecordingEntry)(void *userData, const ADDON_HANDLE handle, const PVR_RECORDING *recording); + void (*AddMenuHook)(void *addonData, PVR_MENUHOOK *hook); + void (*Recording)(void *addonData, const char *Name, const char *FileName, bool On); + void (*TriggerChannelUpdate)(void *addonData); + void (*TriggerTimerUpdate)(void *addonData); + void (*TriggerRecordingUpdate)(void *addonData); + void (*TriggerChannelGroupsUpdate)(void *addonData); + void (*TriggerEpgUpdate)(void *addonData, unsigned int iChannelUid); + + void (*TransferChannelGroup)(void *addonData, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP *group); + void (*TransferChannelGroupMember)(void *addonData, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER *member); + + void (*FreeDemuxPacket)(void *addonData, DemuxPacket* pPacket); + DemuxPacket* (*AllocateDemuxPacket)(void *addonData, int iDataSize); + + void (*ConnectionStateChange)(void* addonData, const char* strConnectionString, PVR_CONNECTION_STATE newState, const char *strMessage); + void (*EpgEventStateChange)(void* addonData, EPG_TAG* tag, unsigned int iUniqueChannelId, EPG_EVENT_STATE newState); +} CB_PVRLib; + +} /* namespace PVR */ +} /* namespace V1 */ +} /* namespace KodiAPI */ + class CHelper_libXBMC_pvr { public: CHelper_libXBMC_pvr(void) { - m_libXBMC_pvr = NULL; - m_Handle = NULL; + m_Handle = nullptr; + m_Callbacks = nullptr; } ~CHelper_libXBMC_pvr(void) { - if (m_libXBMC_pvr) + if (m_Handle && m_Callbacks) { - PVR_unregister_me(m_Handle, m_Callbacks); - dlclose(m_libXBMC_pvr); + m_Handle->PVRLib_UnRegisterMe(m_Handle->addonData, m_Callbacks); } } @@ -60,98 +91,12 @@ public: */ bool RegisterMe(void* handle) { - m_Handle = handle; - - std::string libBasePath; - libBasePath = ((cb_array*)m_Handle)->libPath; - libBasePath += PVR_HELPER_DLL; - - m_libXBMC_pvr = dlopen(libBasePath.c_str(), RTLD_LAZY); - if (m_libXBMC_pvr == NULL) - { - fprintf(stderr, "Unable to load %s\n", dlerror()); - return false; - } - - PVR_register_me = (void* (*)(void *HANDLE)) - dlsym(m_libXBMC_pvr, "PVR_register_me"); - if (PVR_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_unregister_me = (void (*)(void* HANDLE, void* CB)) - dlsym(m_libXBMC_pvr, "PVR_unregister_me"); - if (PVR_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_transfer_epg_entry = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const EPG_TAG *epgentry)) - dlsym(m_libXBMC_pvr, "PVR_transfer_epg_entry"); - if (PVR_transfer_epg_entry == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_transfer_channel_entry = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_CHANNEL *chan)) - dlsym(m_libXBMC_pvr, "PVR_transfer_channel_entry"); - if (PVR_transfer_channel_entry == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_transfer_timer_entry = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_TIMER *timer)) - dlsym(m_libXBMC_pvr, "PVR_transfer_timer_entry"); - if (PVR_transfer_timer_entry == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_transfer_recording_entry = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_RECORDING *recording)) - dlsym(m_libXBMC_pvr, "PVR_transfer_recording_entry"); - if (PVR_transfer_recording_entry == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_add_menu_hook = (void (*)(void* HANDLE, void* CB, PVR_MENUHOOK *hook)) - dlsym(m_libXBMC_pvr, "PVR_add_menu_hook"); - if (PVR_add_menu_hook == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_recording = (void (*)(void* HANDLE, void* CB, const char *Name, const char *FileName, bool On)) - dlsym(m_libXBMC_pvr, "PVR_recording"); - if (PVR_recording == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_trigger_timer_update = (void (*)(void* HANDLE, void* CB)) - dlsym(m_libXBMC_pvr, "PVR_trigger_timer_update"); - if (PVR_trigger_timer_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_trigger_recording_update = (void (*)(void* HANDLE, void* CB)) - dlsym(m_libXBMC_pvr, "PVR_trigger_recording_update"); - if (PVR_trigger_recording_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_trigger_channel_update = (void (*)(void* HANDLE, void* CB)) - dlsym(m_libXBMC_pvr, "PVR_trigger_channel_update"); - if (PVR_trigger_channel_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_trigger_channel_groups_update = (void (*)(void* HANDLE, void* CB)) - dlsym(m_libXBMC_pvr, "PVR_trigger_channel_groups_update"); - if (PVR_trigger_channel_groups_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_trigger_epg_update = (void (*)(void* HANDLE, void* CB, unsigned int iChannelUid)) - dlsym(m_libXBMC_pvr, "PVR_trigger_epg_update"); - if (PVR_trigger_epg_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_transfer_channel_group = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP *group)) - dlsym(m_libXBMC_pvr, "PVR_transfer_channel_group"); - if (PVR_transfer_channel_group == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_transfer_channel_group_member = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER *member)) - dlsym(m_libXBMC_pvr, "PVR_transfer_channel_group_member"); - if (PVR_transfer_channel_group_member == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - -#ifdef USE_DEMUX - PVR_free_demux_packet = (void (*)(void* HANDLE, void* CB, DemuxPacket* pPacket)) - dlsym(m_libXBMC_pvr, "PVR_free_demux_packet"); - if (PVR_free_demux_packet == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_allocate_demux_packet = (DemuxPacket* (*)(void* HANDLE, void* CB, int iDataSize)) - dlsym(m_libXBMC_pvr, "PVR_allocate_demux_packet"); - if (PVR_allocate_demux_packet == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } -#endif - - PVR_connection_state_change = (void (*)(void* HANDLE, void* CB, const char *strConnectionString, PVR_CONNECTION_STATE newState, const char *strMessage)) - dlsym(m_libXBMC_pvr, "PVR_connection_state_change"); - if (PVR_connection_state_change == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - PVR_epg_event_state_change = (void (*)(void* HANDLE, void* CB, EPG_TAG* tag, unsigned int iUniqueChannelId, EPG_EVENT_STATE newState)) - dlsym(m_libXBMC_pvr, "PVR_epg_event_state_change"); - if (PVR_epg_event_state_change == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } - - m_Callbacks = PVR_register_me(m_Handle); + m_Handle = static_cast(handle); + if (m_Handle) + m_Callbacks = (KodiAPI::V1::PVR::CB_PVRLib*)m_Handle->PVRLib_RegisterMe(m_Handle->addonData); + if (!m_Callbacks) + fprintf(stderr, "libXBMC_pvr-ERROR: PVRLib_register_me can't get callback table from Kodi !!!\n"); + return m_Callbacks != NULL; } @@ -162,7 +107,7 @@ public: */ void TransferEpgEntry(const ADDON_HANDLE handle, const EPG_TAG* entry) { - return PVR_transfer_epg_entry(m_Handle, m_Callbacks, handle, entry); + return m_Callbacks->TransferEpgEntry(m_Handle->addonData, handle, entry); } /*! @@ -172,7 +117,7 @@ public: */ void TransferChannelEntry(const ADDON_HANDLE handle, const PVR_CHANNEL* entry) { - return PVR_transfer_channel_entry(m_Handle, m_Callbacks, handle, entry); + return m_Callbacks->TransferChannelEntry(m_Handle->addonData, handle, entry); } /*! @@ -182,7 +127,7 @@ public: */ void TransferTimerEntry(const ADDON_HANDLE handle, const PVR_TIMER* entry) { - return PVR_transfer_timer_entry(m_Handle, m_Callbacks, handle, entry); + return m_Callbacks->TransferTimerEntry(m_Handle->addonData, handle, entry); } /*! @@ -192,7 +137,7 @@ public: */ void TransferRecordingEntry(const ADDON_HANDLE handle, const PVR_RECORDING* entry) { - return PVR_transfer_recording_entry(m_Handle, m_Callbacks, handle, entry); + return m_Callbacks->TransferRecordingEntry(m_Handle->addonData, handle, entry); } /*! @@ -202,7 +147,7 @@ public: */ void TransferChannelGroup(const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP* entry) { - return PVR_transfer_channel_group(m_Handle, m_Callbacks, handle, entry); + return m_Callbacks->TransferChannelGroup(m_Handle->addonData, handle, entry); } /*! @@ -212,7 +157,7 @@ public: */ void TransferChannelGroupMember(const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER* entry) { - return PVR_transfer_channel_group_member(m_Handle, m_Callbacks, handle, entry); + return m_Callbacks->TransferChannelGroupMember(m_Handle->addonData, handle, entry); } /*! @@ -221,7 +166,7 @@ public: */ void AddMenuHook(PVR_MENUHOOK* hook) { - return PVR_add_menu_hook(m_Handle, m_Callbacks, hook); + return m_Callbacks->AddMenuHook(m_Handle->addonData, hook); } /*! @@ -232,7 +177,7 @@ public: */ void Recording(const char* strRecordingName, const char* strFileName, bool bOn) { - return PVR_recording(m_Handle, m_Callbacks, strRecordingName, strFileName, bOn); + return m_Callbacks->Recording(m_Handle->addonData, strRecordingName, strFileName, bOn); } /*! @@ -240,7 +185,7 @@ public: */ void TriggerTimerUpdate(void) { - return PVR_trigger_timer_update(m_Handle, m_Callbacks); + return m_Callbacks->TriggerTimerUpdate(m_Handle->addonData); } /*! @@ -248,7 +193,7 @@ public: */ void TriggerRecordingUpdate(void) { - return PVR_trigger_recording_update(m_Handle, m_Callbacks); + return m_Callbacks->TriggerRecordingUpdate(m_Handle->addonData); } /*! @@ -256,7 +201,7 @@ public: */ void TriggerChannelUpdate(void) { - return PVR_trigger_channel_update(m_Handle, m_Callbacks); + return m_Callbacks->TriggerChannelUpdate(m_Handle->addonData); } /*! @@ -265,7 +210,7 @@ public: */ void TriggerEpgUpdate(unsigned int iChannelUid) { - return PVR_trigger_epg_update(m_Handle, m_Callbacks, iChannelUid); + return m_Callbacks->TriggerEpgUpdate(m_Handle->addonData, iChannelUid); } /*! @@ -273,7 +218,7 @@ public: */ void TriggerChannelGroupsUpdate(void) { - return PVR_trigger_channel_groups_update(m_Handle, m_Callbacks); + return m_Callbacks->TriggerChannelGroupsUpdate(m_Handle->addonData); } #ifdef USE_DEMUX @@ -283,7 +228,7 @@ public: */ void FreeDemuxPacket(DemuxPacket* pPacket) { - return PVR_free_demux_packet(m_Handle, m_Callbacks, pPacket); + return m_Callbacks->FreeDemuxPacket(m_Handle->addonData, pPacket); } /*! @@ -293,7 +238,7 @@ public: */ DemuxPacket* AllocateDemuxPacket(int iDataSize) { - return PVR_allocate_demux_packet(m_Handle, m_Callbacks, iDataSize); + return m_Callbacks->AllocateDemuxPacket(m_Handle->addonData, iDataSize); } #endif @@ -306,7 +251,7 @@ public: */ void ConnectionStateChange(const char *strConnectionString, PVR_CONNECTION_STATE newState, const char *strMessage) { - return PVR_connection_state_change(m_Handle, m_Callbacks, strConnectionString, newState, strMessage); + return m_Callbacks->ConnectionStateChange(m_Handle->addonData, strConnectionString, newState, strMessage); } /*! @@ -318,38 +263,10 @@ public: */ void EpgEventStateChange(EPG_TAG *tag, unsigned int iUniqueChannelId, EPG_EVENT_STATE newState) { - return PVR_epg_event_state_change(m_Handle, m_Callbacks, tag, iUniqueChannelId, newState); + return m_Callbacks->EpgEventStateChange(m_Handle->addonData, tag, iUniqueChannelId, newState); } -protected: - void* (*PVR_register_me)(void*); - void (*PVR_unregister_me)(void*, void*); - void (*PVR_transfer_epg_entry)(void*, void*, const ADDON_HANDLE, const EPG_TAG*); - void (*PVR_transfer_channel_entry)(void*, void*, const ADDON_HANDLE, const PVR_CHANNEL*); - void (*PVR_transfer_timer_entry)(void*, void*, const ADDON_HANDLE, const PVR_TIMER*); - void (*PVR_transfer_recording_entry)(void*, void*, const ADDON_HANDLE, const PVR_RECORDING*); - void (*PVR_add_menu_hook)(void*, void*, PVR_MENUHOOK*); - void (*PVR_recording)(void*, void*, const char*, const char*, bool); - void (*PVR_trigger_channel_update)(void*, void*); - void (*PVR_trigger_channel_groups_update)(void*, void*); - void (*PVR_trigger_timer_update)(void*, void*); - void (*PVR_trigger_recording_update)(void* , void*); - void (*PVR_trigger_epg_update)(void*, void*, unsigned int); - void (*PVR_transfer_channel_group)(void*, void*, const ADDON_HANDLE, const PVR_CHANNEL_GROUP*); - void (*PVR_transfer_channel_group_member)(void*, void*, const ADDON_HANDLE, const PVR_CHANNEL_GROUP_MEMBER*); -#ifdef USE_DEMUX - void (*PVR_free_demux_packet)(void*, void*, DemuxPacket*); - DemuxPacket* (*PVR_allocate_demux_packet)(void*, void*, int); -#endif - void (*PVR_connection_state_change)(void*, void*, const char*, PVR_CONNECTION_STATE, const char*); - void (*PVR_epg_event_state_change)(void*, void*, EPG_TAG*, unsigned int, EPG_EVENT_STATE); - private: - void* m_libXBMC_pvr; - void* m_Handle; - void* m_Callbacks; - struct cb_array - { - const char* libPath; - }; + AddonCB* m_Handle; + KodiAPI::V1::PVR::CB_PVRLib *m_Callbacks; }; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h index 2cf558a..57bb129 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h @@ -589,7 +589,7 @@ extern "C" * @return True if the seek operation was possible * @remarks Optional, and only used if addon has its own demuxer. Return False if this add-on won't provide this function. */ - bool SeekTime(int time, bool backwards, double *startpts); + bool SeekTime(double time, bool backwards, double *startpts); /*! * Notify the pvr addon/demuxer that XBMC wishes to change playback speed diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h index 08ae183..dbc7217 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h @@ -78,10 +78,10 @@ struct DemuxPacket; #define PVR_STREAM_MAX_STREAMS 20 /* current PVR API version */ -#define XBMC_PVR_API_VERSION "5.2.0" +#define XBMC_PVR_API_VERSION "5.2.1" /* min. PVR API version */ -#define XBMC_PVR_MIN_API_VERSION "5.2.0" +#define XBMC_PVR_MIN_API_VERSION "5.2.1" #ifdef __cplusplus extern "C" { @@ -594,7 +594,7 @@ extern "C" { bool (__cdecl* CanPauseStream)(void); void (__cdecl* PauseStream)(bool); bool (__cdecl* CanSeekStream)(void); - bool (__cdecl* SeekTime)(int, bool, double*); + bool (__cdecl* SeekTime)(double, bool, double*); void (__cdecl* SetSpeed)(int); time_t (__cdecl* GetPlayingTime)(void); time_t (__cdecl* GetBufferTimeStart)(void); diff --git a/xbmc/input/XBMC_vkeys.h b/xbmc/input/XBMC_vkeys.h new file mode 100644 index 0000000..4e3787c --- /dev/null +++ b/xbmc/input/XBMC_vkeys.h @@ -0,0 +1,286 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2009 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU General Public License + along with XBMC; see the file COPYING. If not, see + . + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef XBMC_vkeys_h +#define XBMC_vkeys_h + +// The XBMC_vkey identifies a key that is mapped to an action or function. +// The keysym.sym generated by SDL_KEYDOWN is mapped to a vkey and the vkey +// is used to lookup an action in the global mapping table. +// The vkey values are the ASCII code of the character where this is possible. +// Non-printing keypresses get a value in the range 0x80 - 0xFF. +// Note that the vkey is a byte value so it cannot be greater than 0xFF. + +typedef enum { + XBMCVK_BACK = 0x08, + XBMCVK_TAB = 0x09, + XBMCVK_RETURN = 0x0D, + XBMCVK_ESCAPE = 0x1B, + + XBMCVK_SPACE = 0x20, + XBMCVK_EXCLAIM = 0x21, + XBMCVK_QUOTEDBL = 0x22, + XBMCVK_HASH = 0x23, + XBMCVK_DOLLAR = 0x24, + XBMCVK_PERCENT = 0x25, + XBMCVK_AMPERSAND = 0x26, + XBMCVK_QUOTE = 0x27, + XBMCVK_LEFTPAREN = 0x28, + XBMCVK_RIGHTPAREN = 0x29, + XBMCVK_ASTERISK = 0x2A, + XBMCVK_PLUS = 0x2B, + XBMCVK_COMMA = 0x2C, + XBMCVK_MINUS = 0x2D, + XBMCVK_PERIOD = 0x2E, + XBMCVK_SLASH = 0x2F, + + XBMCVK_0 = 0x30, + XBMCVK_1 = 0x31, + XBMCVK_2 = 0x32, + XBMCVK_3 = 0x33, + XBMCVK_4 = 0x34, + XBMCVK_5 = 0x35, + XBMCVK_6 = 0x36, + XBMCVK_7 = 0x37, + XBMCVK_8 = 0x38, + XBMCVK_9 = 0x39, + + XBMCVK_COLON = 0x3A, + XBMCVK_SEMICOLON = 0x3B, + XBMCVK_LESS = 0x3C, + XBMCVK_EQUALS = 0x3D, + XBMCVK_GREATER = 0x3E, + XBMCVK_QUESTION = 0x3F, + XBMCVK_AT = 0x40, + + XBMCVK_A = 0x41, + XBMCVK_B = 0x42, + XBMCVK_C = 0x43, + XBMCVK_D = 0x44, + XBMCVK_E = 0x45, + XBMCVK_F = 0x46, + XBMCVK_G = 0x47, + XBMCVK_H = 0x48, + XBMCVK_I = 0x49, + XBMCVK_J = 0x4A, + XBMCVK_K = 0x4B, + XBMCVK_L = 0x4C, + XBMCVK_M = 0x4D, + XBMCVK_N = 0x4E, + XBMCVK_O = 0x4F, + XBMCVK_P = 0x50, + XBMCVK_Q = 0x51, + XBMCVK_R = 0x52, + XBMCVK_S = 0x53, + XBMCVK_T = 0x54, + XBMCVK_U = 0x55, + XBMCVK_V = 0x56, + XBMCVK_W = 0x57, + XBMCVK_X = 0x58, + XBMCVK_Y = 0x59, + XBMCVK_Z = 0x5A, + + XBMCVK_LEFTBRACKET = 0x5B, + XBMCVK_BACKSLASH = 0x5C, + XBMCVK_RIGHTBRACKET = 0x5D, + XBMCVK_CARET = 0x5E, + XBMCVK_UNDERSCORE = 0x5F, + XBMCVK_BACKQUOTE = 0x60, + +// Lowercase letters 0x61 - 0x7a have the same vkey as uppercase, so +// use this block for the numpad keys + XBMCVK_NUMPADDIVIDE = 0x61, + XBMCVK_NUMPADTIMES = 0x62, + XBMCVK_NUMPADMINUS = 0x63, + XBMCVK_NUMPADPLUS = 0x64, + XBMCVK_NUMPADENTER = 0x65, + XBMCVK_NUMPADPERIOD = 0x66, + XBMCVK_NUMPAD0 = 0x70, + XBMCVK_NUMPAD1 = 0x71, + XBMCVK_NUMPAD2 = 0x72, + XBMCVK_NUMPAD3 = 0x73, + XBMCVK_NUMPAD4 = 0x74, + XBMCVK_NUMPAD5 = 0x75, + XBMCVK_NUMPAD6 = 0x76, + XBMCVK_NUMPAD7 = 0x77, + XBMCVK_NUMPAD8 = 0x78, + XBMCVK_NUMPAD9 = 0x79, + + XBMCVK_LEFTBRACE = 0x7B, + XBMCVK_PIPE = 0x7C, + XBMCVK_RIGHTBRACE = 0x7D, + XBMCVK_TILDE = 0x7E, + +// Non-printing characters + + XBMCVK_UP = 0x80, + XBMCVK_DOWN = 0x81, + XBMCVK_LEFT = 0x82, + XBMCVK_RIGHT = 0x83, + XBMCVK_PAGEUP = 0x84, + XBMCVK_PAGEDOWN = 0x85, + XBMCVK_INSERT = 0x86, + XBMCVK_DELETE = 0x87, + XBMCVK_HOME = 0x88, + XBMCVK_END = 0x89, + + XBMCVK_F1 = 0x90, + XBMCVK_F2 = 0x91, + XBMCVK_F3 = 0x92, + XBMCVK_F4 = 0x93, + XBMCVK_F5 = 0x94, + XBMCVK_F6 = 0x95, + XBMCVK_F7 = 0x96, + XBMCVK_F8 = 0x97, + XBMCVK_F9 = 0x98, + XBMCVK_F10 = 0x99, + XBMCVK_F11 = 0x9A, + XBMCVK_F12 = 0x9B, + XBMCVK_F13 = 0x9C, + XBMCVK_F14 = 0x9D, + XBMCVK_F15 = 0x9E, + XBMCVK_F16 = 0x9F, + XBMCVK_F17 = 0xA0, + XBMCVK_F18 = 0xA1, + XBMCVK_F19 = 0xA2, + XBMCVK_F20 = 0xA3, + XBMCVK_F21 = 0xA4, + XBMCVK_F22 = 0xA5, + XBMCVK_F23 = 0xA6, + XBMCVK_F24 = 0xA7, + + XBMCVK_BROWSER_BACK = 0xB0, + XBMCVK_BROWSER_FORWARD = 0xB1, + XBMCVK_BROWSER_REFRESH = 0xB2, + XBMCVK_BROWSER_STOP = 0xB3, + XBMCVK_BROWSER_SEARCH = 0xB4, + XBMCVK_BROWSER_FAVORITES = 0xB5, + XBMCVK_BROWSER_HOME = 0xB6, + XBMCVK_VOLUME_MUTE = 0xB7, + XBMCVK_VOLUME_DOWN = 0xB8, + XBMCVK_VOLUME_UP = 0xB9, + XBMCVK_MEDIA_NEXT_TRACK = 0xBA, + XBMCVK_MEDIA_PREV_TRACK = 0xBB, + XBMCVK_MEDIA_STOP = 0xBC, + XBMCVK_MEDIA_PLAY_PAUSE = 0xBD, + XBMCVK_LAUNCH_MAIL = 0xBE, + XBMCVK_LAUNCH_MEDIA_SELECT = 0xBF, + XBMCVK_LAUNCH_APP1 = 0xC0, + XBMCVK_LAUNCH_APP2 = 0xC1, + XBMCVK_LAUNCH_FILE_BROWSER = 0xC2, + XBMCVK_LAUNCH_MEDIA_CENTER = 0xC3, + XBMCVK_MEDIA_REWIND = 0xC4, + XBMCVK_MEDIA_FASTFORWARD = 0xC5, + XBMCVK_MEDIA_RECORD = 0xC6, + + XBMCVK_LCONTROL = 0xD0, + XBMCVK_RCONTROL = 0xD1, + XBMCVK_LSHIFT = 0xD2, + XBMCVK_RSHIFT = 0xD3, + XBMCVK_LMENU = 0xD4, + XBMCVK_RMENU = 0xD5, + XBMCVK_LWIN = 0xD6, + XBMCVK_RWIN = 0xD7, + XBMCVK_MENU = 0xD8, + XBMCVK_CAPSLOCK = 0xD9, + XBMCVK_NUMLOCK = 0xDA, + + XBMCVK_PRINTSCREEN = 0xDB, + XBMCVK_SCROLLLOCK = 0xDC, + XBMCVK_PAUSE = 0XDD, + XBMCVK_POWER = 0XDE, + XBMCVK_SLEEP = 0XDF, + XBMCVK_GUIDE = 0xE0, + XBMCVK_SETTINGS = 0xE1, + XBMCVK_INFO = 0xE2, + XBMCVK_RED = 0xE3, + XBMCVK_GREEN = 0xE4, + XBMCVK_YELLOW = 0xE5, + XBMCVK_BLUE = 0xE6, + XBMCVK_ZOOM = 0xE7, + XBMCVK_TEXT = 0xE8, + XBMCVK_FAVORITES = 0xE9, + XBMCVK_HOMEPAGE = 0xEA, + XBMCVK_CONFIG = 0xEB, + XBMCVK_EPG = 0xEC, + + XBMCVK_LAST = 0xFF +} XBMCVKey; + +// These should be in winuser.h. Not sure why they have been defined here +#ifndef VK_0 +#define VK_0 '0' +#define VK_1 '1' +#define VK_2 '2' +#define VK_3 '3' +#define VK_4 '4' +#define VK_5 '5' +#define VK_6 '6' +#define VK_7 '7' +#define VK_8 '8' +#define VK_9 '9' +#define VK_A 'A' +#define VK_B 'B' +#define VK_C 'C' +#define VK_D 'D' +#define VK_E 'E' +#define VK_F 'F' +#define VK_G 'G' +#define VK_H 'H' +#define VK_I 'I' +#define VK_J 'J' +#define VK_K 'K' +#define VK_L 'L' +#define VK_M 'M' +#define VK_N 'N' +#define VK_O 'O' +#define VK_P 'P' +#define VK_Q 'Q' +#define VK_R 'R' +#define VK_S 'S' +#define VK_T 'T' +#define VK_U 'U' +#define VK_V 'V' +#define VK_W 'W' +#define VK_X 'X' +#define VK_Y 'Y' +#define VK_Z 'Z' +#endif /* VK_0 */ + +/* These keys haven't been defined, but were experimentally determined */ +#ifndef VK_SEMICOLON +#define VK_SEMICOLON 0xBA +#define VK_EQUALS 0xBB +#define VK_COMMA 0xBC +#define VK_MINUS 0xBD +#define VK_PERIOD 0xBE +#define VK_SLASH 0xBF +#define VK_GRAVE 0xC0 +#define VK_LBRACKET 0xDB +#define VK_BACKSLASH 0xDC +#define VK_RBRACKET 0xDD +#define VK_APOSTROPHE 0xDE +#define VK_BACKTICK 0xDF +#define VK_OEM_102 0xE2 +#endif + +#endif // XBMC_vkeys_h -- cgit v1.2.3