diff options
23 files changed, 1520 insertions, 39 deletions
diff --git a/project/cmake/CMakeLists.txt b/project/cmake/CMakeLists.txt index 03b3752..d58aa3c 100644 --- a/project/cmake/CMakeLists.txt +++ b/project/cmake/CMakeLists.txt | |||
| @@ -280,6 +280,7 @@ core_link_library(XBMC_codec addons/library.xbmc.codec/libXBMC_codec) | |||
| 280 | core_link_library(KODI_guilib addons/library.kodi.guilib/libKODI_guilib) | 280 | core_link_library(KODI_guilib addons/library.kodi.guilib/libKODI_guilib) |
| 281 | core_link_library(KODI_adsp addons/library.kodi.adsp/libKODI_adsp) | 281 | core_link_library(KODI_adsp addons/library.kodi.adsp/libKODI_adsp) |
| 282 | core_link_library(XBMC_pvr addons/library.xbmc.pvr/libXBMC_pvr) | 282 | core_link_library(XBMC_pvr addons/library.xbmc.pvr/libXBMC_pvr) |
| 283 | core_link_library(KODI_peripheral addons/library.kodi.peripheral/libKODI_peripheral) | ||
| 283 | 284 | ||
| 284 | file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/system/players/VideoPlayer) | 285 | file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/system/players/VideoPlayer) |
| 285 | add_custom_target(wrap-libraries ALL DEPENDS ${WRAP_FILES}) | 286 | add_custom_target(wrap-libraries ALL DEPENDS ${WRAP_FILES}) |
diff --git a/project/cmake/addons/addons/pvr.dvbviewer/platforms.txt b/project/cmake/addons/addons/pvr.dvbviewer/platforms.txt index 0702cb5..baa6044 100644 --- a/project/cmake/addons/addons/pvr.dvbviewer/platforms.txt +++ b/project/cmake/addons/addons/pvr.dvbviewer/platforms.txt | |||
| @@ -1 +1 @@ | |||
| all | all \ No newline at end of file | ||
diff --git a/project/cmake/addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt b/project/cmake/addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt index 0924150..db25aa2 100644 --- a/project/cmake/addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt +++ b/project/cmake/addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt | |||
| @@ -1 +1 @@ | |||
| pvr.dvbviewer https://github.com/manuelm/pvr.dvbviewer \ No newline at end of file | pvr.dvbviewer https://github.com/manuelm/pvr.dvbviewer master \ No newline at end of file | ||
diff --git a/project/cmake/installdata/addon-bindings.txt b/project/cmake/installdata/addon-bindings.txt index 9bebac6..61d2bc1 100644 --- a/project/cmake/installdata/addon-bindings.txt +++ b/project/cmake/installdata/addon-bindings.txt | |||
| @@ -13,20 +13,21 @@ xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h | |||
| 13 | xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h | 13 | xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h |
| 14 | xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h | 14 | xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h |
| 15 | xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_types.h | 15 | xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_types.h |
| 16 | xbmc/addons/kodi-addon-dev-kit/include/kodi_peripheral_callbacks.h | ||
| 17 | xbmc/addons/kodi-addon-dev-kit/include/kodi_peripheral_dll.h | ||
| 18 | xbmc/addons/kodi-addon-dev-kit/include/kodi_peripheral_types.h | ||
| 19 | xbmc/addons/kodi-addon-dev-kit/include/kodi_peripheral_utils.hpp | ||
| 16 | xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h | 20 | xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h |
| 17 | xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h | 21 | xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h |
| 18 | xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_dll.h | 22 | xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_dll.h |
| 19 | xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_types.h | 23 | xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_types.h |
| 20 | xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_dll.h | 24 | xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_dll.h |
| 21 | xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_types.h | 25 | xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_types.h |
| 22 | xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_stream_utils.hpp | ||
| 23 | xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h | 26 | xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h |
| 24 | xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h | 27 | xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h |
| 25 | xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_adsp.h | 28 | xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_adsp.h |
| 26 | xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h | 29 | xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h |
| 27 | xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h | 30 | xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h |
| 31 | xbmc/addons/kodi-addon-dev-kit-include/kodi/libKODI_peripheral.h | ||
| 28 | xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h | 32 | xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h |
| 29 | xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_codec.h | 33 | xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_codec.h |
| 30 | xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h | ||
| 31 | xbmc/cores/AudioEngine/Utils/AEChannelData.h | ||
| 32 | xbmc/filesystem/IFileTypes.h | ||
diff --git a/project/cmake/treedata/android/subdirs.txt b/project/cmake/treedata/android/subdirs.txt index 1c75fa6..599017c 100644 --- a/project/cmake/treedata/android/subdirs.txt +++ b/project/cmake/treedata/android/subdirs.txt | |||
| @@ -3,6 +3,7 @@ xbmc/input/touch input/touch | |||
| 3 | xbmc/input/touch/generic input/touch/generic | 3 | xbmc/input/touch/generic input/touch/generic |
| 4 | xbmc/network/linux network/linux | 4 | xbmc/network/linux network/linux |
| 5 | xbmc/peripherals/bus/linux peripherals/bus/linux | 5 | xbmc/peripherals/bus/linux peripherals/bus/linux |
| 6 | xbmc/peripherals/bus/android peripherals/bus/android | ||
| 6 | xbmc/powermanagement/android powermanagement/android | 7 | xbmc/powermanagement/android powermanagement/android |
| 7 | xbmc/storage/android storage/android | 8 | xbmc/storage/android storage/android |
| 8 | xbmc/filesystem/posix filesystem/posix | 9 | xbmc/filesystem/posix filesystem/posix |
diff --git a/project/cmake/treedata/common/addons.txt b/project/cmake/treedata/common/addons.txt index 29b7990..76410b7 100644 --- a/project/cmake/treedata/common/addons.txt +++ b/project/cmake/treedata/common/addons.txt | |||
| @@ -2,6 +2,7 @@ lib/addons/library.kodi.adsp KODI_adsp | |||
| 2 | lib/addons/library.kodi.audioengine KODI_audioengine | 2 | lib/addons/library.kodi.audioengine KODI_audioengine |
| 3 | lib/addons/library.kodi.guilib KODI_guilib | 3 | lib/addons/library.kodi.guilib KODI_guilib |
| 4 | lib/addons/library.kodi.inputstream KODI_inputstream | 4 | lib/addons/library.kodi.inputstream KODI_inputstream |
| 5 | lib/addons/library.kodi.peripheral KODI_peripheral | ||
| 5 | lib/addons/library.xbmc.addon XBMC_addon | 6 | lib/addons/library.xbmc.addon XBMC_addon |
| 6 | lib/addons/library.xbmc.codec XBMC_codec | 7 | lib/addons/library.xbmc.codec XBMC_codec |
| 7 | lib/addons/library.xbmc.pvr XBMC_pvr | 8 | lib/addons/library.xbmc.pvr XBMC_pvr |
diff --git a/project/cmake/treedata/common/games.txt b/project/cmake/treedata/common/games.txt new file mode 100644 index 0000000..e4e8b89 --- /dev/null +++ b/project/cmake/treedata/common/games.txt | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | xbmc/games/controllers games/controllers | ||
| 2 | xbmc/games/controllers/guicontrols games/controllers/guicontrols | ||
| 3 | xbmc/games/controllers/windows games/controllers/windows | ||
diff --git a/project/cmake/treedata/common/peripherals.txt b/project/cmake/treedata/common/peripherals.txt index e6d9283..903b537 100644 --- a/project/cmake/treedata/common/peripherals.txt +++ b/project/cmake/treedata/common/peripherals.txt | |||
| @@ -1,4 +1,6 @@ | |||
| 1 | xbmc/peripherals peripherals | 1 | xbmc/peripherals peripherals |
| 2 | xbmc/peripherals/addons peripherals/addons | ||
| 2 | xbmc/peripherals/bus peripherals/bus | 3 | xbmc/peripherals/bus peripherals/bus |
| 4 | xbmc/peripherals/bus/virtual peripherals/bus/virtual | ||
| 3 | xbmc/peripherals/devices peripherals/devices | 5 | xbmc/peripherals/devices peripherals/devices |
| 4 | xbmc/peripherals/dialogs peripherals/dialogs | 6 | xbmc/peripherals/dialogs peripherals/dialogs |
diff --git a/project/cmake/treedata/common/subdirs.txt b/project/cmake/treedata/common/subdirs.txt index 762547e..c2828e0 100644 --- a/project/cmake/treedata/common/subdirs.txt +++ b/project/cmake/treedata/common/subdirs.txt | |||
| @@ -1,25 +1,36 @@ | |||
| 1 | xbmc xbmc | 1 | xbmc xbmc |
| 2 | xbmc/addons addons | 2 | xbmc/addons addons |
| 3 | xbmc/commons commons | 3 | xbmc/addons/binary/interfaces addonsBinaryInterfaces |
| 4 | xbmc/cdrip cdrip | 4 | xbmc/addons/binary/interfaces/api1/Addon api1AddonCallbacks_Addon |
| 5 | xbmc/dbwrappers dbwrappers | 5 | xbmc/addons/binary/interfaces/api1/AudioDSP api1AddonCallbacks_AudioDSP |
| 6 | xbmc/dialogs dialogs | 6 | xbmc/addons/binary/interfaces/api1/AudioEngine api1AddonCallbacks_AudioEngine |
| 7 | xbmc/epg epg | 7 | xbmc/addons/binary/interfaces/api1/Codec api1AddonCallbacks_Codec |
| 8 | xbmc/guilib guilib | 8 | xbmc/addons/binary/interfaces/api1/GUI api1AddonCallbacks_GUI |
| 9 | xbmc/input input | 9 | xbmc/addons/binary/interfaces/api1/InputStream api1AddonCallbacks_InputStream |
| 10 | xbmc/listproviders listproviders | 10 | xbmc/addons/binary/interfaces/api1/Peripheral api1AddonCallbacks_Peripheral |
| 11 | xbmc/media media | 11 | xbmc/addons/binary/interfaces/api1/PVR api1AddonCallbacks_PVR |
| 12 | xbmc/messaging messaging | 12 | xbmc/commons commons |
| 13 | xbmc/messaging/helpers messagingHelpers | 13 | xbmc/cdrip cdrip |
| 14 | xbmc/pictures pictures | 14 | xbmc/dbwrappers dbwrappers |
| 15 | xbmc/platform platform | 15 | xbmc/dialogs dialogs |
| 16 | xbmc/playlists playlists | 16 | xbmc/epg epg |
| 17 | xbmc/powermanagement powermanagement | 17 | xbmc/guilib guilib |
| 18 | xbmc/programs programs | 18 | xbmc/input input |
| 19 | xbmc/rendering rendering | 19 | xbmc/input/joysticks input/joysticks |
| 20 | xbmc/storage storage | 20 | xbmc/input/joysticks/generic input/joysticks/generic |
| 21 | xbmc/threads threads | 21 | xbmc/listproviders listproviders |
| 22 | xbmc/utils utils | 22 | xbmc/media media |
| 23 | xbmc/view view | 23 | xbmc/messaging messaging |
| 24 | xbmc/windowing windowing | 24 | xbmc/messaging/helpers messagingHelpers |
| 25 | xbmc/windows windows | 25 | xbmc/pictures pictures |
| 26 | xbmc/platform platform | ||
| 27 | xbmc/playlists playlists | ||
| 28 | xbmc/powermanagement powermanagement | ||
| 29 | xbmc/programs programs | ||
| 30 | xbmc/rendering rendering | ||
| 31 | xbmc/storage storage | ||
| 32 | xbmc/threads threads | ||
| 33 | xbmc/utils utils | ||
| 34 | xbmc/view view | ||
| 35 | xbmc/windowing windowing | ||
| 36 | xbmc/windows windows | ||
diff --git a/project/cmake/treedata/optional/common/cec.txt b/project/cmake/treedata/optional/common/cec.txt deleted file mode 100644 index 19cd7f7..0000000 --- a/project/cmake/treedata/optional/common/cec.txt +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | xbmc/peripherals/bus/virtual peripherals/bus/virtual # CEC | ||
diff --git a/scripts/sync_buildenv.sh b/scripts/sync_buildenv.sh index f5f3a42..7905bb7 100755 --- a/scripts/sync_buildenv.sh +++ b/scripts/sync_buildenv.sh | |||
| @@ -26,5 +26,7 @@ do | |||
| 26 | done | 26 | done |
| 27 | 27 | ||
| 28 | branch=$(git rev-parse --abbrev-ref HEAD) | 28 | branch=$(git rev-parse --abbrev-ref HEAD) |
| 29 | mkdir -p project/cmake/addons/addons/pvr.dvbviewer | ||
| 29 | echo -n "pvr.dvbviewer https://github.com/manuelm/pvr.dvbviewer $branch" > project/cmake/addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt | 30 | echo -n "pvr.dvbviewer https://github.com/manuelm/pvr.dvbviewer $branch" > project/cmake/addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt |
| 30 | git add project/cmake/addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt | 31 | echo -n "all" > project/cmake/addons/addons/pvr.dvbviewer/platforms.txt |
| 32 | git add project/cmake/addons/addons/ | ||
diff --git a/xbmc/addons/addon-bindings.mk b/xbmc/addons/addon-bindings.mk index 319185a..71fe609 100644 --- a/xbmc/addons/addon-bindings.mk +++ b/xbmc/addons/addon-bindings.mk | |||
| @@ -12,7 +12,12 @@ BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_codec_types.h | |||
| 12 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h | 12 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h |
| 13 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h | 13 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h |
| 14 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h | 14 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h |
| 15 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_callbacks.h | ||
| 16 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_dll.h | ||
| 17 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h | ||
| 18 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_utils.hpp | ||
| 15 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_types.h | 19 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_types.h |
| 20 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_utils.hpp | ||
| 16 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h | 21 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h |
| 17 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h | 22 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h |
| 18 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_dll.h | 23 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_dll.h |
| @@ -24,6 +29,7 @@ BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h | |||
| 24 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_adsp.h | 29 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_adsp.h |
| 25 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h | 30 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h |
| 26 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h | 31 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h |
| 32 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_peripheral.h | ||
| 27 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h | 33 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h |
| 28 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_codec.h | 34 | BINDINGS+=xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_codec.h |
| 29 | BINDINGS+=xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h | 35 | BINDINGS+=xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_callbacks.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_callbacks.h new file mode 100644 index 0000000..720c62f --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_callbacks.h | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2016 Team Kodi | ||
| 3 | * http://kodi.tv | ||
| 4 | * | ||
| 5 | * This Program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | * any later version. | ||
| 9 | * | ||
| 10 | * This Program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this Program; see the file COPYING. If not, see | ||
| 17 | * <http://www.gnu.org/licenses/>. | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | #ifndef __PERIPHERAL_CALLBACKS_H__ | ||
| 21 | #define __PERIPHERAL_CALLBACKS_H__ | ||
| 22 | |||
| 23 | #include "kodi_peripheral_types.h" | ||
| 24 | |||
| 25 | #ifdef __cplusplus | ||
| 26 | extern "C" | ||
| 27 | { | ||
| 28 | #endif | ||
| 29 | |||
| 30 | typedef struct CB_PeripheralLib | ||
| 31 | { | ||
| 32 | /*! | ||
| 33 | * @brief Trigger a scan for peripherals | ||
| 34 | * | ||
| 35 | * The add-on calls this if a change in hardware is detected. | ||
| 36 | */ | ||
| 37 | void (*TriggerScan)(void* addonData); | ||
| 38 | |||
| 39 | /*! | ||
| 40 | * @brief Notify the frontend that button maps have changed | ||
| 41 | * | ||
| 42 | * @param[optional] deviceName The name of the device to refresh, or empty/null for all devices | ||
| 43 | * @param[optional] controllerId The controller ID to refresh, or empty/null for all controllers | ||
| 44 | */ | ||
| 45 | void (*RefreshButtonMaps)(void* addonData, const char* deviceName, const char* controllerId); | ||
| 46 | |||
| 47 | } CB_PeripheralLib; | ||
| 48 | |||
| 49 | #ifdef __cplusplus | ||
| 50 | } | ||
| 51 | #endif | ||
| 52 | |||
| 53 | #endif // __PERIPHERAL_CALLBACKS_H__ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_dll.h new file mode 100644 index 0000000..591afcc --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_dll.h | |||
| @@ -0,0 +1,198 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2016 Team Kodi | ||
| 3 | * http://kodi.tv | ||
| 4 | * | ||
| 5 | * This Program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | * any later version. | ||
| 9 | * | ||
| 10 | * This Program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this Program; see the file COPYING. If not, see | ||
| 17 | * <http://www.gnu.org/licenses/>. | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | #ifndef __PERIPHERAL_DLL_H__ | ||
| 21 | #define __PERIPHERAL_DLL_H__ | ||
| 22 | |||
| 23 | #include "kodi_peripheral_types.h" | ||
| 24 | |||
| 25 | #define PERIPHERAL_ADDON_JOYSTICKS // TODO | ||
| 26 | |||
| 27 | #ifdef __cplusplus | ||
| 28 | extern "C" | ||
| 29 | { | ||
| 30 | #endif | ||
| 31 | |||
| 32 | /// @name Peripheral operations | ||
| 33 | ///{ | ||
| 34 | /*! | ||
| 35 | * @brief Get the PERIPHERAL_API_VERSION used to compile this peripheral add-on | ||
| 36 | * @return KODI_PERIPHERAL_API_VERSION from kodi_peripheral_types.h | ||
| 37 | * @remarks Valid implementation required | ||
| 38 | * | ||
| 39 | * Used to check if the implementation is compatible with the frontend. | ||
| 40 | */ | ||
| 41 | const char* GetPeripheralAPIVersion(void); | ||
| 42 | |||
| 43 | /*! | ||
| 44 | * @brief Get the KODI_PERIPHERAL_MIN_API_VERSION used to compile this peripheral add-on | ||
| 45 | * @return KODI_PERIPHERAL_MIN_API_VERSION from kodi_peripheral_types.h | ||
| 46 | * @remarks Valid implementation required | ||
| 47 | * | ||
| 48 | * Used to check if the implementation is compatible with the frontend. | ||
| 49 | */ | ||
| 50 | const char* GetMinimumPeripheralAPIVersion(void); | ||
| 51 | |||
| 52 | /*! | ||
| 53 | * @brief Get the list of features that this add-on provides | ||
| 54 | * @param pCapabilities The add-on's capabilities. | ||
| 55 | * @return PERIPHERAL_NO_ERROR if the properties were fetched successfully. | ||
| 56 | * @remarks Valid implementation required. | ||
| 57 | * | ||
| 58 | * Called by the frontend to query the add-on's capabilities and supported | ||
| 59 | * peripherals. All capabilities that the add-on supports should be set to true. | ||
| 60 | * | ||
| 61 | */ | ||
| 62 | PERIPHERAL_ERROR GetAddonCapabilities(PERIPHERAL_CAPABILITIES *pCapabilities); | ||
| 63 | |||
| 64 | /*! | ||
| 65 | * @brief Perform a scan for joysticks | ||
| 66 | * @param peripheral_count Assigned to the number of peripherals allocated | ||
| 67 | * @param scan_results Assigned to allocated memory | ||
| 68 | * @return PERIPHERAL_NO_ERROR if successful; peripherals must be freed using | ||
| 69 | * FreeScanResults() in this case | ||
| 70 | * | ||
| 71 | * The frontend calls this when a hardware change is detected. If an add-on | ||
| 72 | * detects a hardware change, it can trigger this function using the | ||
| 73 | * TriggerScan() callback. | ||
| 74 | */ | ||
| 75 | PERIPHERAL_ERROR PerformDeviceScan(unsigned int* peripheral_count, PERIPHERAL_INFO** scan_results); | ||
| 76 | |||
| 77 | /*! | ||
| 78 | * @brief Free the memory allocated in PerformDeviceScan() | ||
| 79 | * | ||
| 80 | * Must be called if PerformDeviceScan() returns PERIPHERAL_NO_ERROR. | ||
| 81 | * | ||
| 82 | * @param peripheral_count The number of events allocated for the events array | ||
| 83 | * @param scan_results The array of allocated peripherals | ||
| 84 | */ | ||
| 85 | void FreeScanResults(unsigned int peripheral_count, PERIPHERAL_INFO* scan_results); | ||
| 86 | |||
| 87 | /*! | ||
| 88 | * @brief Get all events that have occurred since the last call to GetEvents() | ||
| 89 | * @return PERIPHERAL_NO_ERROR if successful; events must be freed using | ||
| 90 | * FreeEvents() in this case | ||
| 91 | */ | ||
| 92 | PERIPHERAL_ERROR GetEvents(unsigned int* event_count, PERIPHERAL_EVENT** events); | ||
| 93 | |||
| 94 | /*! | ||
| 95 | * @brief Free the memory allocated in GetEvents() | ||
| 96 | * | ||
| 97 | * Must be called if GetEvents() returns PERIPHERAL_NO_ERROR. | ||
| 98 | * | ||
| 99 | * @param event_count The number of events allocated for the events array | ||
| 100 | * @param events The array of allocated events | ||
| 101 | */ | ||
| 102 | void FreeEvents(unsigned int event_count, PERIPHERAL_EVENT* events); | ||
| 103 | ///} | ||
| 104 | |||
| 105 | /// @name Joystick operations | ||
| 106 | /*! | ||
| 107 | * @note #define PERIPHERAL_ADDON_JOYSTICKS before including kodi_peripheral_dll.h | ||
| 108 | * in the add-on if the add-on provides joysticks and add provides_joysticks="true" | ||
| 109 | * to the kodi.peripheral extension point node in addon.xml. | ||
| 110 | */ | ||
| 111 | ///{ | ||
| 112 | #ifdef PERIPHERAL_ADDON_JOYSTICKS | ||
| 113 | /*! | ||
| 114 | * @brief Get extended info about an attached joystick | ||
| 115 | * @param index The joystick's driver index | ||
| 116 | * @param info The container for the allocated joystick info | ||
| 117 | * @return PERIPHERAL_NO_ERROR if successful; array must be freed using | ||
| 118 | * FreeJoystickInfo() in this case | ||
| 119 | */ | ||
| 120 | PERIPHERAL_ERROR GetJoystickInfo(unsigned int index, JOYSTICK_INFO* info); | ||
| 121 | |||
| 122 | /*! | ||
| 123 | * @brief Free the memory allocated in GetJoystickInfo() | ||
| 124 | */ | ||
| 125 | void FreeJoystickInfo(JOYSTICK_INFO* info); | ||
| 126 | |||
| 127 | /*! | ||
| 128 | * @brief Get the features that allow translating the joystick into the controller profile | ||
| 129 | * @param joystick The device's joystick properties; unknown values may be left at their default | ||
| 130 | * @param controller_id The controller profile being requested, e.g. game.controller.default | ||
| 131 | * @param feature_count The number of features allocated for the features array | ||
| 132 | * @param features The array of allocated features | ||
| 133 | * @return PERIPHERAL_NO_ERROR if successful; array must be freed using | ||
| 134 | * FreeButtonMap() in this case | ||
| 135 | */ | ||
| 136 | PERIPHERAL_ERROR GetFeatures(const JOYSTICK_INFO* joystick, const char* controller_id, | ||
| 137 | unsigned int* feature_count, JOYSTICK_FEATURE** features); | ||
| 138 | |||
| 139 | /*! | ||
| 140 | * @brief Free the memory allocated in GetFeatures() | ||
| 141 | * | ||
| 142 | * Must be called if GetFeatures() returns PERIPHERAL_NO_ERROR. | ||
| 143 | * | ||
| 144 | * @param feature_count The number of features allocated for the features array | ||
| 145 | * @param features The array of allocated features | ||
| 146 | */ | ||
| 147 | void FreeFeatures(unsigned int feature_count, JOYSTICK_FEATURE* features); | ||
| 148 | |||
| 149 | /*! | ||
| 150 | * @brief Add or update joystick features | ||
| 151 | * @param joystick The device's joystick properties; unknown values may be left at their default | ||
| 152 | * @param controller_id The game controller profile being updated | ||
| 153 | * @param feature_count The number of features int the features array | ||
| 154 | * @param features The array of features | ||
| 155 | * @return PERIPHERAL_NO_ERROR if successful | ||
| 156 | */ | ||
| 157 | PERIPHERAL_ERROR MapFeatures(const JOYSTICK_INFO* joystick, const char* controller_id, | ||
| 158 | unsigned int feature_count, JOYSTICK_FEATURE* features); | ||
| 159 | |||
| 160 | /*! | ||
| 161 | * @brief Reset the button map for the given joystick and controller profile ID | ||
| 162 | * @param joystick The device's joystick properties | ||
| 163 | * @param controller_id The game controller profile being reset | ||
| 164 | */ | ||
| 165 | void ResetButtonMap(const JOYSTICK_INFO* joystick, const char* controller_id); | ||
| 166 | #endif | ||
| 167 | ///} | ||
| 168 | |||
| 169 | /*! | ||
| 170 | * Called by the frontend to assign the function pointers of this add-on to | ||
| 171 | * pClient. Note that get_addon() is defined here, so it will be available in | ||
| 172 | * all compiled peripheral add-ons. | ||
| 173 | */ | ||
| 174 | void __declspec(dllexport) get_addon(struct PeripheralAddon* pClient) | ||
| 175 | { | ||
| 176 | pClient->GetPeripheralAPIVersion = GetPeripheralAPIVersion; | ||
| 177 | pClient->GetMinimumPeripheralAPIVersion = GetMinimumPeripheralAPIVersion; | ||
| 178 | pClient->GetAddonCapabilities = GetAddonCapabilities; | ||
| 179 | pClient->PerformDeviceScan = PerformDeviceScan; | ||
| 180 | pClient->FreeScanResults = FreeScanResults; | ||
| 181 | pClient->GetEvents = GetEvents; | ||
| 182 | pClient->FreeEvents = FreeEvents; | ||
| 183 | |||
| 184 | #ifdef PERIPHERAL_ADDON_JOYSTICKS | ||
| 185 | pClient->GetJoystickInfo = GetJoystickInfo; | ||
| 186 | pClient->FreeJoystickInfo = FreeJoystickInfo; | ||
| 187 | pClient->GetFeatures = GetFeatures; | ||
| 188 | pClient->FreeFeatures = FreeFeatures; | ||
| 189 | pClient->MapFeatures = MapFeatures; | ||
| 190 | pClient->ResetButtonMap = ResetButtonMap; | ||
| 191 | #endif | ||
| 192 | } | ||
| 193 | |||
| 194 | #ifdef __cplusplus | ||
| 195 | } | ||
| 196 | #endif | ||
| 197 | |||
| 198 | #endif // __PERIPHERAL_DLL_H__ | ||
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 new file mode 100644 index 0000000..85e2363 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_types.h | |||
| @@ -0,0 +1,301 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2016 Team Kodi | ||
| 3 | * http://kodi.tv | ||
| 4 | * | ||
| 5 | * This Program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | * any later version. | ||
| 9 | * | ||
| 10 | * This Program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this Program; see the file COPYING. If not, see | ||
| 17 | * <http://www.gnu.org/licenses/>. | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | #ifndef __PERIPHERAL_TYPES_H__ | ||
| 21 | #define __PERIPHERAL_TYPES_H__ | ||
| 22 | |||
| 23 | #ifdef TARGET_WINDOWS | ||
| 24 | #include <windows.h> | ||
| 25 | #else | ||
| 26 | #ifndef __cdecl | ||
| 27 | #define __cdecl | ||
| 28 | #endif | ||
| 29 | #ifndef __declspec | ||
| 30 | #define __declspec(X) | ||
| 31 | #endif | ||
| 32 | #endif | ||
| 33 | |||
| 34 | #include <stdint.h> | ||
| 35 | |||
| 36 | #undef ATTRIBUTE_PACKED | ||
| 37 | #undef PRAGMA_PACK_BEGIN | ||
| 38 | #undef PRAGMA_PACK_END | ||
| 39 | |||
| 40 | #if defined(__GNUC__) | ||
| 41 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) | ||
| 42 | #define ATTRIBUTE_PACKED __attribute__ ((packed)) | ||
| 43 | #define PRAGMA_PACK 0 | ||
| 44 | #endif | ||
| 45 | #endif | ||
| 46 | |||
| 47 | #if !defined(ATTRIBUTE_PACKED) | ||
| 48 | #define ATTRIBUTE_PACKED | ||
| 49 | #define PRAGMA_PACK 1 | ||
| 50 | #endif | ||
| 51 | |||
| 52 | /* current Peripheral API version */ | ||
| 53 | #define PERIPHERAL_API_VERSION "1.0.17" | ||
| 54 | |||
| 55 | /* min. Peripheral API version */ | ||
| 56 | #define PERIPHERAL_MIN_API_VERSION "1.0.16" | ||
| 57 | |||
| 58 | /* indicates a joystick has no preference for port number */ | ||
| 59 | #define NO_PORT_REQUESTED (-1) | ||
| 60 | |||
| 61 | /* joystick's driver button/hat/axis index is unknown */ | ||
| 62 | #define DRIVER_INDEX_UNKNOWN (-1) | ||
| 63 | |||
| 64 | #ifdef __cplusplus | ||
| 65 | extern "C" | ||
| 66 | { | ||
| 67 | #endif | ||
| 68 | |||
| 69 | /// @name Peripheral types | ||
| 70 | ///{ | ||
| 71 | typedef enum PERIPHERAL_ERROR | ||
| 72 | { | ||
| 73 | PERIPHERAL_NO_ERROR = 0, // no error occurred | ||
| 74 | PERIPHERAL_ERROR_UNKNOWN = -1, // an unknown error occurred | ||
| 75 | PERIPHERAL_ERROR_FAILED = -2, // the command failed | ||
| 76 | PERIPHERAL_ERROR_INVALID_PARAMETERS = -3, // the parameters of the method are invalid for this operation | ||
| 77 | PERIPHERAL_ERROR_NOT_IMPLEMENTED = -4, // the method that the frontend called is not implemented | ||
| 78 | PERIPHERAL_ERROR_NOT_CONNECTED = -5, // no peripherals are connected | ||
| 79 | PERIPHERAL_ERROR_CONNECTION_FAILED = -6, // peripherals are connected, but command was interrupted | ||
| 80 | } PERIPHERAL_ERROR; | ||
| 81 | |||
| 82 | typedef enum PERIPHERAL_TYPE | ||
| 83 | { | ||
| 84 | PERIPHERAL_TYPE_UNKNOWN, | ||
| 85 | PERIPHERAL_TYPE_JOYSTICK, | ||
| 86 | } PERIPHERAL_TYPE; | ||
| 87 | |||
| 88 | typedef struct PERIPHERAL_INFO | ||
| 89 | { | ||
| 90 | PERIPHERAL_TYPE type; /*!< @brief type of peripheral */ | ||
| 91 | char* name; /*!< @brief name of peripheral */ | ||
| 92 | uint16_t vendor_id; /*!< @brief vendor ID of peripheral, 0x0000 if unknown */ | ||
| 93 | uint16_t product_id; /*!< @brief product ID of peripheral, 0x0000 if unknown */ | ||
| 94 | unsigned int index; /*!< @brief the order in which the add-on identified this peripheral */ | ||
| 95 | } ATTRIBUTE_PACKED PERIPHERAL_INFO; | ||
| 96 | |||
| 97 | /*! | ||
| 98 | * @brief Properties passed to the Create() method of an add-on. | ||
| 99 | */ | ||
| 100 | typedef struct PERIPHERAL_PROPERTIES | ||
| 101 | { | ||
| 102 | const char* user_path; /*!< @brief path to the user profile */ | ||
| 103 | const char* addon_path; /*!< @brief path to this add-on */ | ||
| 104 | } ATTRIBUTE_PACKED PERIPHERAL_PROPERTIES; | ||
| 105 | |||
| 106 | /*! | ||
| 107 | * @brief Peripheral add-on capabilities. | ||
| 108 | * If a capability is set to true, then the corresponding methods from | ||
| 109 | * kodi_peripheral_dll.h need to be implemented. | ||
| 110 | */ | ||
| 111 | typedef struct PERIPHERAL_CAPABILITIES | ||
| 112 | { | ||
| 113 | bool provides_joysticks; /*!< @brief true if the add-on provides joysticks */ | ||
| 114 | } ATTRIBUTE_PACKED PERIPHERAL_CAPABILITIES; | ||
| 115 | ///} | ||
| 116 | |||
| 117 | /// @name Event types | ||
| 118 | ///{ | ||
| 119 | typedef enum PERIPHERAL_EVENT_TYPE | ||
| 120 | { | ||
| 121 | PERIPHERAL_EVENT_TYPE_NONE, /*!< @brief unknown event */ | ||
| 122 | PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON, /*!< @brief state changed for joystick driver button */ | ||
| 123 | PERIPHERAL_EVENT_TYPE_DRIVER_HAT, /*!< @brief state changed for joystick driver hat */ | ||
| 124 | PERIPHERAL_EVENT_TYPE_DRIVER_AXIS, /*!< @brief state changed for joystick driver axis */ | ||
| 125 | } PERIPHERAL_EVENT_TYPE; | ||
| 126 | |||
| 127 | typedef enum JOYSTICK_STATE_BUTTON | ||
| 128 | { | ||
| 129 | JOYSTICK_STATE_BUTTON_UNPRESSED = 0x0, /*!< @brief button is released */ | ||
| 130 | JOYSTICK_STATE_BUTTON_PRESSED = 0x1, /*!< @brief button is pressed */ | ||
| 131 | } JOYSTICK_STATE_BUTTON; | ||
| 132 | |||
| 133 | typedef enum JOYSTICK_STATE_HAT | ||
| 134 | { | ||
| 135 | JOYSTICK_STATE_HAT_UNPRESSED = 0x0, /*!< @brief no directions are pressed */ | ||
| 136 | JOYSTICK_STATE_HAT_LEFT = 0x1, /*!< @brief only left is pressed */ | ||
| 137 | JOYSTICK_STATE_HAT_RIGHT = 0x2, /*!< @brief only right is pressed */ | ||
| 138 | JOYSTICK_STATE_HAT_UP = 0x4, /*!< @brief only up is pressed */ | ||
| 139 | JOYSTICK_STATE_HAT_DOWN = 0x8, /*!< @brief only down is pressed */ | ||
| 140 | JOYSTICK_STATE_HAT_LEFT_UP = JOYSTICK_STATE_HAT_LEFT | JOYSTICK_STATE_HAT_UP, | ||
| 141 | JOYSTICK_STATE_HAT_LEFT_DOWN = JOYSTICK_STATE_HAT_LEFT | JOYSTICK_STATE_HAT_DOWN, | ||
| 142 | JOYSTICK_STATE_HAT_RIGHT_UP = JOYSTICK_STATE_HAT_RIGHT | JOYSTICK_STATE_HAT_UP, | ||
| 143 | JOYSTICK_STATE_HAT_RIGHT_DOWN = JOYSTICK_STATE_HAT_RIGHT | JOYSTICK_STATE_HAT_DOWN, | ||
| 144 | } JOYSTICK_STATE_HAT; | ||
| 145 | |||
| 146 | /*! | ||
| 147 | * @brief value in the closed interval [-1.0, 1.0] | ||
| 148 | * | ||
| 149 | * The axis state uses the XInput coordinate system: | ||
| 150 | * - Negative values signify down or to the left | ||
| 151 | * - Positive values signify up or to the right | ||
| 152 | */ | ||
| 153 | typedef float JOYSTICK_STATE_AXIS; | ||
| 154 | |||
| 155 | typedef struct PERIPHERAL_EVENT | ||
| 156 | { | ||
| 157 | unsigned int peripheral_index; | ||
| 158 | PERIPHERAL_EVENT_TYPE type; | ||
| 159 | unsigned int driver_index; | ||
| 160 | JOYSTICK_STATE_BUTTON driver_button_state; | ||
| 161 | JOYSTICK_STATE_HAT driver_hat_state; | ||
| 162 | JOYSTICK_STATE_AXIS driver_axis_state; | ||
| 163 | } ATTRIBUTE_PACKED PERIPHERAL_EVENT; | ||
| 164 | ///} | ||
| 165 | |||
| 166 | /// @name Joystick types | ||
| 167 | ///{ | ||
| 168 | typedef struct JOYSTICK_INFO | ||
| 169 | { | ||
| 170 | PERIPHERAL_INFO peripheral; /*!< @brief peripheral info for this joystick */ | ||
| 171 | char* provider; /*!< @brief name of the driver or interface providing the joystick */ | ||
| 172 | int requested_port; /*!< @brief requested port number (such as for 360 controllers), or NO_PORT_REQUESTED */ | ||
| 173 | unsigned int button_count; /*!< @brief number of buttons reported by the driver */ | ||
| 174 | unsigned int hat_count; /*!< @brief number of hats reported by the driver */ | ||
| 175 | unsigned int axis_count; /*!< @brief number of axes reported by the driver */ | ||
| 176 | } ATTRIBUTE_PACKED JOYSTICK_INFO; | ||
| 177 | |||
| 178 | typedef enum JOYSTICK_DRIVER_PRIMITIVE_TYPE | ||
| 179 | { | ||
| 180 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN, | ||
| 181 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON, | ||
| 182 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION, | ||
| 183 | JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS, | ||
| 184 | } JOYSTICK_DRIVER_PRIMITIVE_TYPE; | ||
| 185 | |||
| 186 | typedef struct JOYSTICK_DRIVER_BUTTON | ||
| 187 | { | ||
| 188 | int index; | ||
| 189 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_BUTTON; | ||
| 190 | |||
| 191 | typedef enum JOYSTICK_DRIVER_HAT_DIRECTION | ||
| 192 | { | ||
| 193 | JOYSTICK_DRIVER_HAT_UNKNOWN, | ||
| 194 | JOYSTICK_DRIVER_HAT_LEFT, | ||
| 195 | JOYSTICK_DRIVER_HAT_RIGHT, | ||
| 196 | JOYSTICK_DRIVER_HAT_UP, | ||
| 197 | JOYSTICK_DRIVER_HAT_DOWN, | ||
| 198 | } JOYSTICK_DRIVER_HAT_DIRECTION; | ||
| 199 | |||
| 200 | typedef struct JOYSTICK_DRIVER_HAT | ||
| 201 | { | ||
| 202 | int index; | ||
| 203 | JOYSTICK_DRIVER_HAT_DIRECTION direction; | ||
| 204 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_HAT; | ||
| 205 | |||
| 206 | typedef enum JOYSTICK_DRIVER_SEMIAXIS_DIRECTION | ||
| 207 | { | ||
| 208 | JOYSTICK_DRIVER_SEMIAXIS_NEGATIVE = -1, /*!< @brief negative half of the axis */ | ||
| 209 | JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN = 0, /*!< @brief unknown direction */ | ||
| 210 | JOYSTICK_DRIVER_SEMIAXIS_POSITIVE = 1, /*!< @brief positive half of the axis */ | ||
| 211 | } JOYSTICK_DRIVER_SEMIAXIS_DIRECTION; | ||
| 212 | |||
| 213 | typedef struct JOYSTICK_DRIVER_SEMIAXIS | ||
| 214 | { | ||
| 215 | int index; | ||
| 216 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction; | ||
| 217 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_SEMIAXIS; | ||
| 218 | |||
| 219 | typedef struct JOYSTICK_DRIVER_PRIMITIVE | ||
| 220 | { | ||
| 221 | JOYSTICK_DRIVER_PRIMITIVE_TYPE type; | ||
| 222 | union | ||
| 223 | { | ||
| 224 | struct JOYSTICK_DRIVER_BUTTON button; | ||
| 225 | struct JOYSTICK_DRIVER_HAT hat; | ||
| 226 | struct JOYSTICK_DRIVER_SEMIAXIS semiaxis; | ||
| 227 | }; | ||
| 228 | } ATTRIBUTE_PACKED JOYSTICK_DRIVER_PRIMITIVE; | ||
| 229 | |||
| 230 | typedef enum JOYSTICK_FEATURE_TYPE | ||
| 231 | { | ||
| 232 | JOYSTICK_FEATURE_TYPE_UNKNOWN, | ||
| 233 | JOYSTICK_FEATURE_TYPE_SCALAR, | ||
| 234 | JOYSTICK_FEATURE_TYPE_ANALOG_STICK, | ||
| 235 | JOYSTICK_FEATURE_TYPE_ACCELEROMETER, | ||
| 236 | } JOYSTICK_FEATURE_TYPE; | ||
| 237 | |||
| 238 | typedef struct JOYSTICK_FEATURE_SCALAR | ||
| 239 | { | ||
| 240 | struct JOYSTICK_DRIVER_PRIMITIVE primitive; | ||
| 241 | } ATTRIBUTE_PACKED JOYSTICK_FEATURE_SCALAR; | ||
| 242 | |||
| 243 | typedef struct JOYSTICK_FEATURE_ANALOG_STICK | ||
| 244 | { | ||
| 245 | struct JOYSTICK_DRIVER_PRIMITIVE up; | ||
| 246 | struct JOYSTICK_DRIVER_PRIMITIVE down; | ||
| 247 | struct JOYSTICK_DRIVER_PRIMITIVE right; | ||
| 248 | struct JOYSTICK_DRIVER_PRIMITIVE left; | ||
| 249 | } ATTRIBUTE_PACKED JOYSTICK_FEATURE_ANALOG_STICK; | ||
| 250 | |||
| 251 | typedef struct JOYSTICK_FEATURE_ACCELEROMETER | ||
| 252 | { | ||
| 253 | struct JOYSTICK_DRIVER_PRIMITIVE positive_x; | ||
| 254 | struct JOYSTICK_DRIVER_PRIMITIVE positive_y; | ||
| 255 | struct JOYSTICK_DRIVER_PRIMITIVE positive_z; | ||
| 256 | } ATTRIBUTE_PACKED JOYSTICK_FEATURE_ACCELEROMETER; | ||
| 257 | |||
| 258 | typedef struct JOYSTICK_FEATURE | ||
| 259 | { | ||
| 260 | char* name; | ||
| 261 | JOYSTICK_FEATURE_TYPE type; | ||
| 262 | union | ||
| 263 | { | ||
| 264 | struct JOYSTICK_FEATURE_SCALAR scalar; | ||
| 265 | struct JOYSTICK_FEATURE_ANALOG_STICK analog_stick; | ||
| 266 | struct JOYSTICK_FEATURE_ACCELEROMETER accelerometer; | ||
| 267 | }; | ||
| 268 | } ATTRIBUTE_PACKED JOYSTICK_FEATURE; | ||
| 269 | ///} | ||
| 270 | |||
| 271 | // TODO: Mouse, light gun, multitouch | ||
| 272 | |||
| 273 | /*! | ||
| 274 | * @brief Structure to transfer the methods from kodi_peripheral_dll.h to the frontend | ||
| 275 | */ | ||
| 276 | typedef struct PeripheralAddon | ||
| 277 | { | ||
| 278 | const char* (__cdecl* GetPeripheralAPIVersion)(void); | ||
| 279 | const char* (__cdecl* GetMinimumPeripheralAPIVersion)(void); | ||
| 280 | PERIPHERAL_ERROR (__cdecl* GetAddonCapabilities)(PERIPHERAL_CAPABILITIES*); | ||
| 281 | PERIPHERAL_ERROR (__cdecl* PerformDeviceScan)(unsigned int*, PERIPHERAL_INFO**); | ||
| 282 | void (__cdecl* FreeScanResults)(unsigned int, PERIPHERAL_INFO*); | ||
| 283 | PERIPHERAL_ERROR (__cdecl* GetEvents)(unsigned int*, PERIPHERAL_EVENT**); | ||
| 284 | void (__cdecl* FreeEvents)(unsigned int, PERIPHERAL_EVENT*); | ||
| 285 | |||
| 286 | /// @name Joystick operations | ||
| 287 | ///{ | ||
| 288 | PERIPHERAL_ERROR (__cdecl* GetJoystickInfo)(unsigned int, JOYSTICK_INFO*); | ||
| 289 | void (__cdecl* FreeJoystickInfo)(JOYSTICK_INFO*); | ||
| 290 | PERIPHERAL_ERROR (__cdecl* GetFeatures)(const JOYSTICK_INFO*, const char*, unsigned int*, JOYSTICK_FEATURE**); | ||
| 291 | void (__cdecl* FreeFeatures)(unsigned int, JOYSTICK_FEATURE*); | ||
| 292 | PERIPHERAL_ERROR (__cdecl* MapFeatures)(const JOYSTICK_INFO*, const char*, unsigned int, JOYSTICK_FEATURE*); | ||
| 293 | void (__cdecl* ResetButtonMap)(const JOYSTICK_INFO*, const char*); | ||
| 294 | ///} | ||
| 295 | } PeripheralAddon; | ||
| 296 | |||
| 297 | #ifdef __cplusplus | ||
| 298 | } | ||
| 299 | #endif | ||
| 300 | |||
| 301 | #endif // __PERIPHERAL_TYPES_H__ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_utils.hpp b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_utils.hpp new file mode 100644 index 0000000..4423cb4 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_utils.hpp | |||
| @@ -0,0 +1,657 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2016 Team Kodi | ||
| 3 | * http://kodi.tv | ||
| 4 | * | ||
| 5 | * This Program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | * any later version. | ||
| 9 | * | ||
| 10 | * This Program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this Program; see the file COPYING. If not, see | ||
| 17 | * <http://www.gnu.org/licenses/>. | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | #pragma once | ||
| 21 | |||
| 22 | #include "kodi_peripheral_types.h" | ||
| 23 | |||
| 24 | #include <cstring> | ||
| 25 | #include <map> | ||
| 26 | #include <string> | ||
| 27 | #include <vector> | ||
| 28 | |||
| 29 | #define PERIPHERAL_SAFE_DELETE(x) do { delete (x); (x) = NULL; } while (0) | ||
| 30 | #define PERIPHERAL_SAFE_DELETE_ARRAY(x) do { delete[] (x); (x) = NULL; } while (0) | ||
| 31 | |||
| 32 | namespace ADDON | ||
| 33 | { | ||
| 34 | /*! | ||
| 35 | * Utility class to manipulate arrays of peripheral types. | ||
| 36 | */ | ||
| 37 | template <class THE_CLASS, typename THE_STRUCT> | ||
| 38 | class PeripheralVector | ||
| 39 | { | ||
| 40 | public: | ||
| 41 | static void ToStructs(const std::vector<THE_CLASS>& vecObjects, THE_STRUCT** pStructs) | ||
| 42 | { | ||
| 43 | if (!pStructs) | ||
| 44 | return; | ||
| 45 | |||
| 46 | if (vecObjects.empty()) | ||
| 47 | { | ||
| 48 | *pStructs = NULL; | ||
| 49 | } | ||
| 50 | else | ||
| 51 | { | ||
| 52 | (*pStructs) = new THE_STRUCT[vecObjects.size()]; | ||
| 53 | for (unsigned int i = 0; i < vecObjects.size(); i++) | ||
| 54 | vecObjects.at(i).ToStruct((*pStructs)[i]); | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | static void ToStructs(const std::vector<THE_CLASS*>& vecObjects, THE_STRUCT** pStructs) | ||
| 59 | { | ||
| 60 | if (!pStructs) | ||
| 61 | return; | ||
| 62 | |||
| 63 | if (vecObjects.empty()) | ||
| 64 | { | ||
| 65 | *pStructs = NULL; | ||
| 66 | } | ||
| 67 | else | ||
| 68 | { | ||
| 69 | *pStructs = new THE_STRUCT[vecObjects.size()]; | ||
| 70 | for (unsigned int i = 0; i < vecObjects.size(); i++) | ||
| 71 | vecObjects.at(i)->ToStruct((*pStructs)[i]); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | static void FreeStructs(unsigned int structCount, THE_STRUCT* structs) | ||
| 76 | { | ||
| 77 | if (structs) | ||
| 78 | { | ||
| 79 | for (unsigned int i = 0; i < structCount; i++) | ||
| 80 | THE_CLASS::FreeStruct(structs[i]); | ||
| 81 | } | ||
| 82 | PERIPHERAL_SAFE_DELETE_ARRAY(structs); | ||
| 83 | } | ||
| 84 | }; | ||
| 85 | |||
| 86 | /*! | ||
| 87 | * ADDON::Peripheral | ||
| 88 | * | ||
| 89 | * Wrapper class providing peripheral information. Classes can extend | ||
| 90 | * Peripheral to inherit peripheral properties. | ||
| 91 | */ | ||
| 92 | class Peripheral | ||
| 93 | { | ||
| 94 | public: | ||
| 95 | Peripheral(PERIPHERAL_TYPE type = PERIPHERAL_TYPE_UNKNOWN, const std::string& strName = "") : | ||
| 96 | m_type(type), | ||
| 97 | m_strName(strName), | ||
| 98 | m_vendorId(0), | ||
| 99 | m_productId(0), | ||
| 100 | m_index(0) | ||
| 101 | { | ||
| 102 | } | ||
| 103 | |||
| 104 | Peripheral(const PERIPHERAL_INFO& info) : | ||
| 105 | m_type(info.type), | ||
| 106 | m_strName(info.name ? info.name : ""), | ||
| 107 | m_vendorId(info.vendor_id), | ||
| 108 | m_productId(info.product_id), | ||
| 109 | m_index(info.index) | ||
| 110 | { | ||
| 111 | } | ||
| 112 | |||
| 113 | virtual ~Peripheral(void) { } | ||
| 114 | |||
| 115 | PERIPHERAL_TYPE Type(void) const { return m_type; } | ||
| 116 | const std::string& Name(void) const { return m_strName; } | ||
| 117 | uint16_t VendorID(void) const { return m_vendorId; } | ||
| 118 | uint16_t ProductID(void) const { return m_productId; } | ||
| 119 | unsigned int Index(void) const { return m_index; } | ||
| 120 | |||
| 121 | // Derived property: VID and PID are 0x0000 if unknown | ||
| 122 | bool IsVidPidKnown(void) const { return m_vendorId != 0 || m_productId != 0; } | ||
| 123 | |||
| 124 | void SetType(PERIPHERAL_TYPE type) { m_type = type; } | ||
| 125 | void SetName(const std::string& strName) { m_strName = strName; } | ||
| 126 | void SetVendorID(uint16_t vendorId) { m_vendorId = vendorId; } | ||
| 127 | void SetProductID(uint16_t productId) { m_productId = productId; } | ||
| 128 | void SetIndex(unsigned int index) { m_index = index; } | ||
| 129 | |||
| 130 | void ToStruct(PERIPHERAL_INFO& info) const | ||
| 131 | { | ||
| 132 | info.type = m_type; | ||
| 133 | info.name = new char[m_strName.size() + 1]; | ||
| 134 | info.vendor_id = m_vendorId; | ||
| 135 | info.product_id = m_productId; | ||
| 136 | info.index = m_index; | ||
| 137 | |||
| 138 | std::strcpy(info.name, m_strName.c_str()); | ||
| 139 | } | ||
| 140 | |||
| 141 | static void FreeStruct(PERIPHERAL_INFO& info) | ||
| 142 | { | ||
| 143 | PERIPHERAL_SAFE_DELETE_ARRAY(info.name); | ||
| 144 | } | ||
| 145 | |||
| 146 | private: | ||
| 147 | PERIPHERAL_TYPE m_type; | ||
| 148 | std::string m_strName; | ||
| 149 | uint16_t m_vendorId; | ||
| 150 | uint16_t m_productId; | ||
| 151 | unsigned int m_index; | ||
| 152 | }; | ||
| 153 | |||
| 154 | typedef PeripheralVector<Peripheral, PERIPHERAL_INFO> Peripherals; | ||
| 155 | |||
| 156 | /*! | ||
| 157 | * ADDON::PeripheralEvent | ||
| 158 | * | ||
| 159 | * Wrapper class for peripheral events. | ||
| 160 | */ | ||
| 161 | class PeripheralEvent | ||
| 162 | { | ||
| 163 | public: | ||
| 164 | PeripheralEvent(void) : | ||
| 165 | m_event() | ||
| 166 | { | ||
| 167 | } | ||
| 168 | |||
| 169 | PeripheralEvent(unsigned int peripheralIndex, unsigned int buttonIndex, JOYSTICK_STATE_BUTTON state) : | ||
| 170 | m_event() | ||
| 171 | { | ||
| 172 | SetType(PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON); | ||
| 173 | SetPeripheralIndex(peripheralIndex); | ||
| 174 | SetDriverIndex(buttonIndex); | ||
| 175 | SetButtonState(state); | ||
| 176 | } | ||
| 177 | |||
| 178 | PeripheralEvent(unsigned int peripheralIndex, unsigned int hatIndex, JOYSTICK_STATE_HAT state) : | ||
| 179 | m_event() | ||
| 180 | { | ||
| 181 | SetType(PERIPHERAL_EVENT_TYPE_DRIVER_HAT); | ||
| 182 | SetPeripheralIndex(peripheralIndex); | ||
| 183 | SetDriverIndex(hatIndex); | ||
| 184 | SetHatState(state); | ||
| 185 | } | ||
| 186 | |||
| 187 | PeripheralEvent(unsigned int peripheralIndex, unsigned int axisIndex, JOYSTICK_STATE_AXIS state) : | ||
| 188 | m_event() | ||
| 189 | { | ||
| 190 | SetType(PERIPHERAL_EVENT_TYPE_DRIVER_AXIS); | ||
| 191 | SetPeripheralIndex(peripheralIndex); | ||
| 192 | SetDriverIndex(axisIndex); | ||
| 193 | SetAxisState(state); | ||
| 194 | } | ||
| 195 | |||
| 196 | PeripheralEvent(const PERIPHERAL_EVENT& event) : | ||
| 197 | m_event(event) | ||
| 198 | { | ||
| 199 | } | ||
| 200 | |||
| 201 | PERIPHERAL_EVENT_TYPE Type(void) const { return m_event.type; } | ||
| 202 | unsigned int PeripheralIndex(void) const { return m_event.peripheral_index; } | ||
| 203 | unsigned int DriverIndex(void) const { return m_event.driver_index; } | ||
| 204 | JOYSTICK_STATE_BUTTON ButtonState(void) const { return m_event.driver_button_state; } | ||
| 205 | JOYSTICK_STATE_HAT HatState(void) const { return m_event.driver_hat_state; } | ||
| 206 | JOYSTICK_STATE_AXIS AxisState(void) const { return m_event.driver_axis_state; } | ||
| 207 | |||
| 208 | void SetType(PERIPHERAL_EVENT_TYPE type) { m_event.type = type; } | ||
| 209 | void SetPeripheralIndex(unsigned int index) { m_event.peripheral_index = index; } | ||
| 210 | void SetDriverIndex(unsigned int index) { m_event.driver_index = index; } | ||
| 211 | void SetButtonState(JOYSTICK_STATE_BUTTON state) { m_event.driver_button_state = state; } | ||
| 212 | void SetHatState(JOYSTICK_STATE_HAT state) { m_event.driver_hat_state = state; } | ||
| 213 | void SetAxisState(JOYSTICK_STATE_AXIS state) { m_event.driver_axis_state = state; } | ||
| 214 | |||
| 215 | void ToStruct(PERIPHERAL_EVENT& event) const | ||
| 216 | { | ||
| 217 | event = m_event; | ||
| 218 | } | ||
| 219 | |||
| 220 | static void FreeStruct(PERIPHERAL_EVENT& event) | ||
| 221 | { | ||
| 222 | (void)event; | ||
| 223 | } | ||
| 224 | |||
| 225 | private: | ||
| 226 | PERIPHERAL_EVENT m_event; | ||
| 227 | }; | ||
| 228 | |||
| 229 | typedef PeripheralVector<PeripheralEvent, PERIPHERAL_EVENT> PeripheralEvents; | ||
| 230 | |||
| 231 | /*! | ||
| 232 | * ADDON::Joystick | ||
| 233 | * | ||
| 234 | * Wrapper class providing additional joystick information not provided by | ||
| 235 | * ADDON::Peripheral. | ||
| 236 | */ | ||
| 237 | class Joystick : public Peripheral | ||
| 238 | { | ||
| 239 | public: | ||
| 240 | Joystick(const std::string& provider = "", const std::string& strName = "") : | ||
| 241 | Peripheral(PERIPHERAL_TYPE_JOYSTICK, strName), | ||
| 242 | m_provider(provider), | ||
| 243 | m_requestedPort(NO_PORT_REQUESTED), | ||
| 244 | m_buttonCount(0), | ||
| 245 | m_hatCount(0), | ||
| 246 | m_axisCount(0) | ||
| 247 | { | ||
| 248 | } | ||
| 249 | |||
| 250 | Joystick(const Joystick& other) | ||
| 251 | { | ||
| 252 | *this = other; | ||
| 253 | } | ||
| 254 | |||
| 255 | 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 | { | ||
| 263 | } | ||
| 264 | |||
| 265 | virtual ~Joystick(void) { } | ||
| 266 | |||
| 267 | Joystick& operator=(const Joystick& rhs) | ||
| 268 | { | ||
| 269 | if (this != &rhs) | ||
| 270 | { | ||
| 271 | Peripheral::operator=(rhs); | ||
| 272 | |||
| 273 | m_provider = rhs.m_provider; | ||
| 274 | m_requestedPort = rhs.m_requestedPort; | ||
| 275 | m_buttonCount = rhs.m_buttonCount; | ||
| 276 | m_hatCount = rhs.m_hatCount; | ||
| 277 | m_axisCount = rhs.m_axisCount; | ||
| 278 | } | ||
| 279 | return *this; | ||
| 280 | } | ||
| 281 | |||
| 282 | const std::string& Provider(void) const { return m_provider; } | ||
| 283 | int RequestedPort(void) const { return m_requestedPort; } | ||
| 284 | unsigned int ButtonCount(void) const { return m_buttonCount; } | ||
| 285 | unsigned int HatCount(void) const { return m_hatCount; } | ||
| 286 | unsigned int AxisCount(void) const { return m_axisCount; } | ||
| 287 | |||
| 288 | // Derived property: Counts are unknown if all are zero | ||
| 289 | bool AreElementCountsKnown(void) const { return m_buttonCount != 0 || m_hatCount != 0 || m_axisCount != 0; } | ||
| 290 | |||
| 291 | void SetProvider(const std::string& provider) { m_provider = provider; } | ||
| 292 | void SetRequestedPort(int requestedPort) { m_requestedPort = requestedPort; } | ||
| 293 | void SetButtonCount(unsigned int buttonCount) { m_buttonCount = buttonCount; } | ||
| 294 | void SetHatCount(unsigned int hatCount) { m_hatCount = hatCount; } | ||
| 295 | void SetAxisCount(unsigned int axisCount) { m_axisCount = axisCount; } | ||
| 296 | |||
| 297 | void ToStruct(JOYSTICK_INFO& info) const | ||
| 298 | { | ||
| 299 | Peripheral::ToStruct(info.peripheral); | ||
| 300 | |||
| 301 | info.provider = new char[m_provider.size() + 1]; | ||
| 302 | info.requested_port = m_requestedPort; | ||
| 303 | info.button_count = m_buttonCount; | ||
| 304 | info.hat_count = m_hatCount; | ||
| 305 | info.axis_count = m_axisCount; | ||
| 306 | |||
| 307 | std::strcpy(info.provider, m_provider.c_str()); | ||
| 308 | } | ||
| 309 | |||
| 310 | static void FreeStruct(JOYSTICK_INFO& info) | ||
| 311 | { | ||
| 312 | Peripheral::FreeStruct(info.peripheral); | ||
| 313 | |||
| 314 | PERIPHERAL_SAFE_DELETE_ARRAY(info.provider); | ||
| 315 | } | ||
| 316 | |||
| 317 | private: | ||
| 318 | std::string m_provider; | ||
| 319 | int m_requestedPort; | ||
| 320 | unsigned int m_buttonCount; | ||
| 321 | unsigned int m_hatCount; | ||
| 322 | unsigned int m_axisCount; | ||
| 323 | }; | ||
| 324 | |||
| 325 | typedef PeripheralVector<Joystick, JOYSTICK_INFO> Joysticks; | ||
| 326 | |||
| 327 | /*! | ||
| 328 | * ADDON::DriverPrimitive | ||
| 329 | * | ||
| 330 | * Base class for joystick driver primitives. A driver primitive can be: | ||
| 331 | * | ||
| 332 | * 1) a button | ||
| 333 | * 2) a hat direction | ||
| 334 | * 3) a semiaxis (either the positive or negative half of an axis) | ||
| 335 | * | ||
| 336 | * The type determines the fields in use: | ||
| 337 | * | ||
| 338 | * Button: | ||
| 339 | * - driver index | ||
| 340 | * | ||
| 341 | * Hat direction: | ||
| 342 | * - driver index | ||
| 343 | * - hat direction | ||
| 344 | * | ||
| 345 | * Semiaxis: | ||
| 346 | * - driver index | ||
| 347 | * - semiaxis direction | ||
| 348 | */ | ||
| 349 | class DriverPrimitive | ||
| 350 | { | ||
| 351 | public: | ||
| 352 | /*! | ||
| 353 | * \brief Construct an invalid driver primitive | ||
| 354 | */ | ||
| 355 | DriverPrimitive(void) : | ||
| 356 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN), | ||
| 357 | m_driverIndex(0), | ||
| 358 | m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), | ||
| 359 | m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN) | ||
| 360 | { | ||
| 361 | } | ||
| 362 | |||
| 363 | /*! | ||
| 364 | * \brief Construct a driver primitive representing a button | ||
| 365 | */ | ||
| 366 | DriverPrimitive(unsigned int buttonIndex) : | ||
| 367 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON), | ||
| 368 | m_driverIndex(buttonIndex), | ||
| 369 | m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), | ||
| 370 | m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN) | ||
| 371 | { | ||
| 372 | } | ||
| 373 | |||
| 374 | /*! | ||
| 375 | * \brief Construct a driver primitive representing one of the four direction | ||
| 376 | * arrows on a dpad | ||
| 377 | */ | ||
| 378 | DriverPrimitive(unsigned int hatIndex, JOYSTICK_DRIVER_HAT_DIRECTION direction) : | ||
| 379 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION), | ||
| 380 | m_driverIndex(hatIndex), | ||
| 381 | m_hatDirection(direction), | ||
| 382 | m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN) | ||
| 383 | { | ||
| 384 | } | ||
| 385 | |||
| 386 | /*! | ||
| 387 | * \brief Construct a driver primitive representing the positive or negative | ||
| 388 | * half of an axis | ||
| 389 | */ | ||
| 390 | DriverPrimitive(unsigned int axisIndex, JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction) : | ||
| 391 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS), | ||
| 392 | m_driverIndex(axisIndex), | ||
| 393 | m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), | ||
| 394 | m_semiAxisDirection(direction) | ||
| 395 | { | ||
| 396 | } | ||
| 397 | |||
| 398 | DriverPrimitive(const JOYSTICK_DRIVER_PRIMITIVE& primitive) : | ||
| 399 | m_type(primitive.type), | ||
| 400 | m_driverIndex(0), | ||
| 401 | m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), | ||
| 402 | m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN) | ||
| 403 | { | ||
| 404 | switch (m_type) | ||
| 405 | { | ||
| 406 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: | ||
| 407 | { | ||
| 408 | m_driverIndex = primitive.button.index; | ||
| 409 | break; | ||
| 410 | } | ||
| 411 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION: | ||
| 412 | { | ||
| 413 | m_driverIndex = primitive.hat.index; | ||
| 414 | m_hatDirection = primitive.hat.direction; | ||
| 415 | break; | ||
| 416 | } | ||
| 417 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: | ||
| 418 | { | ||
| 419 | m_driverIndex = primitive.semiaxis.index; | ||
| 420 | m_semiAxisDirection = primitive.semiaxis.direction; | ||
| 421 | break; | ||
| 422 | } | ||
| 423 | default: | ||
| 424 | break; | ||
| 425 | } | ||
| 426 | } | ||
| 427 | |||
| 428 | JOYSTICK_DRIVER_PRIMITIVE_TYPE Type(void) const { return m_type; } | ||
| 429 | unsigned int DriverIndex(void) const { return m_driverIndex; } | ||
| 430 | JOYSTICK_DRIVER_HAT_DIRECTION HatDirection(void) const { return m_hatDirection; } | ||
| 431 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION SemiAxisDirection(void) const { return m_semiAxisDirection; } | ||
| 432 | |||
| 433 | bool operator==(const DriverPrimitive& other) const | ||
| 434 | { | ||
| 435 | if (m_type == other.m_type) | ||
| 436 | { | ||
| 437 | switch (m_type) | ||
| 438 | { | ||
| 439 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: | ||
| 440 | { | ||
| 441 | return m_driverIndex == other.m_driverIndex; | ||
| 442 | } | ||
| 443 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION: | ||
| 444 | { | ||
| 445 | return m_driverIndex == other.m_driverIndex && | ||
| 446 | m_hatDirection == other.m_hatDirection; | ||
| 447 | } | ||
| 448 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: | ||
| 449 | { | ||
| 450 | return m_driverIndex == other.m_driverIndex && | ||
| 451 | m_semiAxisDirection == other.m_semiAxisDirection; | ||
| 452 | } | ||
| 453 | default: | ||
| 454 | break; | ||
| 455 | } | ||
| 456 | } | ||
| 457 | return false; | ||
| 458 | } | ||
| 459 | |||
| 460 | void ToStruct(JOYSTICK_DRIVER_PRIMITIVE& driver_primitive) const | ||
| 461 | { | ||
| 462 | driver_primitive.type = m_type; | ||
| 463 | switch (m_type) | ||
| 464 | { | ||
| 465 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: | ||
| 466 | { | ||
| 467 | driver_primitive.button.index = m_driverIndex; | ||
| 468 | break; | ||
| 469 | } | ||
| 470 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION: | ||
| 471 | { | ||
| 472 | driver_primitive.hat.index = m_driverIndex; | ||
| 473 | driver_primitive.hat.direction = m_hatDirection; | ||
| 474 | break; | ||
| 475 | } | ||
| 476 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS: | ||
| 477 | { | ||
| 478 | driver_primitive.semiaxis.index = m_driverIndex; | ||
| 479 | driver_primitive.semiaxis.direction = m_semiAxisDirection; | ||
| 480 | break; | ||
| 481 | } | ||
| 482 | default: | ||
| 483 | break; | ||
| 484 | } | ||
| 485 | } | ||
| 486 | |||
| 487 | private: | ||
| 488 | JOYSTICK_DRIVER_PRIMITIVE_TYPE m_type; | ||
| 489 | unsigned int m_driverIndex; | ||
| 490 | JOYSTICK_DRIVER_HAT_DIRECTION m_hatDirection; | ||
| 491 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION m_semiAxisDirection; | ||
| 492 | }; | ||
| 493 | |||
| 494 | /*! | ||
| 495 | * ADDON::JoystickFeature | ||
| 496 | * | ||
| 497 | * Class for joystick features. A feature can be: | ||
| 498 | * | ||
| 499 | * 1) scalar[1] | ||
| 500 | * 2) analog stick | ||
| 501 | * 3) accelerometer | ||
| 502 | * | ||
| 503 | * [1] All three driver primitives (buttons, hats and axes) have a state that | ||
| 504 | * can be represented using a single scalar value. For this reason, | ||
| 505 | * features that map to a single primitive are called "scalar features". | ||
| 506 | * | ||
| 507 | * Features can be mapped to a variable number of driver primitives. The names | ||
| 508 | * of the primitives for each feature are: | ||
| 509 | * | ||
| 510 | * Scalar feature: | ||
| 511 | * - primitive | ||
| 512 | * | ||
| 513 | * Analog stick: | ||
| 514 | * - up | ||
| 515 | * - down | ||
| 516 | * - right | ||
| 517 | * - left | ||
| 518 | * | ||
| 519 | * Accelerometer: | ||
| 520 | * - positive X | ||
| 521 | * - positive Y | ||
| 522 | * - positive Z | ||
| 523 | */ | ||
| 524 | class JoystickFeature | ||
| 525 | { | ||
| 526 | public: | ||
| 527 | const unsigned int MAX_PRIMITIVES = 4; | ||
| 528 | |||
| 529 | JoystickFeature(void) : | ||
| 530 | m_type(JOYSTICK_FEATURE_TYPE_UNKNOWN) | ||
| 531 | { | ||
| 532 | m_primitives.resize(MAX_PRIMITIVES); | ||
| 533 | } | ||
| 534 | |||
| 535 | JoystickFeature(const std::string& name, JOYSTICK_FEATURE_TYPE type) : | ||
| 536 | m_name(name), | ||
| 537 | m_type(type) | ||
| 538 | { | ||
| 539 | m_primitives.resize(MAX_PRIMITIVES); | ||
| 540 | } | ||
| 541 | |||
| 542 | JoystickFeature(const JoystickFeature& other) | ||
| 543 | { | ||
| 544 | *this = other; | ||
| 545 | } | ||
| 546 | |||
| 547 | JoystickFeature(const JOYSTICK_FEATURE& feature) : | ||
| 548 | m_name(feature.name ? feature.name : ""), | ||
| 549 | m_type(feature.type) | ||
| 550 | { | ||
| 551 | m_primitives.resize(MAX_PRIMITIVES); | ||
| 552 | switch (m_type) | ||
| 553 | { | ||
| 554 | case JOYSTICK_FEATURE_TYPE_SCALAR: | ||
| 555 | SetPrimitive(feature.scalar.primitive); | ||
| 556 | break; | ||
| 557 | case JOYSTICK_FEATURE_TYPE_ANALOG_STICK: | ||
| 558 | SetUp(feature.analog_stick.up); | ||
| 559 | SetDown(feature.analog_stick.down); | ||
| 560 | SetRight(feature.analog_stick.right); | ||
| 561 | SetLeft(feature.analog_stick.left); | ||
| 562 | break; | ||
| 563 | case JOYSTICK_FEATURE_TYPE_ACCELEROMETER: | ||
| 564 | SetPositiveX(feature.accelerometer.positive_x); | ||
| 565 | SetPositiveY(feature.accelerometer.positive_y); | ||
| 566 | SetPositiveZ(feature.accelerometer.positive_z); | ||
| 567 | break; | ||
| 568 | default: | ||
| 569 | break; | ||
| 570 | } | ||
| 571 | } | ||
| 572 | |||
| 573 | JoystickFeature& operator=(const JoystickFeature& rhs) | ||
| 574 | { | ||
| 575 | if (this != &rhs) | ||
| 576 | { | ||
| 577 | m_name = rhs.m_name; | ||
| 578 | m_type = rhs.m_type; | ||
| 579 | m_primitives = rhs.m_primitives; | ||
| 580 | } | ||
| 581 | return *this; | ||
| 582 | } | ||
| 583 | |||
| 584 | bool operator==(const JoystickFeature& other) const | ||
| 585 | { | ||
| 586 | return m_name == other.m_name && | ||
| 587 | m_type == other.m_type && | ||
| 588 | m_primitives == other.m_primitives; | ||
| 589 | } | ||
| 590 | |||
| 591 | const std::string& Name(void) const { return m_name; } | ||
| 592 | JOYSTICK_FEATURE_TYPE Type(void) const { return m_type; } | ||
| 593 | |||
| 594 | void SetName(const std::string& name) { m_name = name; } | ||
| 595 | void SetType(JOYSTICK_FEATURE_TYPE type) { m_type = type; } | ||
| 596 | |||
| 597 | // Scalar methods | ||
| 598 | const DriverPrimitive& Primitive(void) const { return m_primitives[0]; } | ||
| 599 | void SetPrimitive(const DriverPrimitive& primitive) { m_primitives[0] = primitive; } | ||
| 600 | |||
| 601 | // Analog stick methods | ||
| 602 | const DriverPrimitive& Up(void) const { return m_primitives[0]; } | ||
| 603 | const DriverPrimitive& Down(void) const { return m_primitives[1]; } | ||
| 604 | const DriverPrimitive& Right(void) const { return m_primitives[2]; } | ||
| 605 | const DriverPrimitive& Left(void) const { return m_primitives[3]; } | ||
| 606 | void SetUp(const DriverPrimitive& primitive) { m_primitives[0] = primitive; } | ||
| 607 | void SetDown(const DriverPrimitive& primitive) { m_primitives[1] = primitive; } | ||
| 608 | void SetRight(const DriverPrimitive& primitive) { m_primitives[2] = primitive; } | ||
| 609 | void SetLeft(const DriverPrimitive& primitive) { m_primitives[3] = primitive; } | ||
| 610 | |||
| 611 | // Accelerometer methods | ||
| 612 | const DriverPrimitive& PositiveX(void) const { return m_primitives[0]; } | ||
| 613 | const DriverPrimitive& PositiveY(void) const { return m_primitives[1]; } | ||
| 614 | const DriverPrimitive& PositiveZ(void) const { return m_primitives[2]; } | ||
| 615 | void SetPositiveX(const DriverPrimitive& primitive) { m_primitives[0] = primitive; } | ||
| 616 | void SetPositiveY(const DriverPrimitive& primitive) { m_primitives[1] = primitive; } | ||
| 617 | void SetPositiveZ(const DriverPrimitive& primitive) { m_primitives[2] = primitive; } | ||
| 618 | |||
| 619 | void ToStruct(JOYSTICK_FEATURE& feature) const | ||
| 620 | { | ||
| 621 | feature.name = new char[m_name.length() + 1]; | ||
| 622 | feature.type = m_type; | ||
| 623 | switch (m_type) | ||
| 624 | { | ||
| 625 | case JOYSTICK_FEATURE_TYPE_SCALAR: | ||
| 626 | Primitive().ToStruct(feature.scalar.primitive); | ||
| 627 | break; | ||
| 628 | case JOYSTICK_FEATURE_TYPE_ANALOG_STICK: | ||
| 629 | Up().ToStruct(feature.analog_stick.up); | ||
| 630 | Down().ToStruct(feature.analog_stick.down); | ||
| 631 | Right().ToStruct(feature.analog_stick.right); | ||
| 632 | Left().ToStruct(feature.analog_stick.left); | ||
| 633 | break; | ||
| 634 | case JOYSTICK_FEATURE_TYPE_ACCELEROMETER: | ||
| 635 | PositiveX().ToStruct(feature.accelerometer.positive_x); | ||
| 636 | PositiveY().ToStruct(feature.accelerometer.positive_y); | ||
| 637 | PositiveZ().ToStruct(feature.accelerometer.positive_z); | ||
| 638 | break; | ||
| 639 | default: | ||
| 640 | break; | ||
| 641 | } | ||
| 642 | std::strcpy(feature.name, m_name.c_str()); | ||
| 643 | } | ||
| 644 | |||
| 645 | static void FreeStruct(JOYSTICK_FEATURE& feature) | ||
| 646 | { | ||
| 647 | PERIPHERAL_SAFE_DELETE_ARRAY(feature.name); | ||
| 648 | } | ||
| 649 | |||
| 650 | private: | ||
| 651 | std::string m_name; | ||
| 652 | JOYSTICK_FEATURE_TYPE m_type; | ||
| 653 | std::vector<DriverPrimitive> m_primitives; | ||
| 654 | }; | ||
| 655 | |||
| 656 | typedef PeripheralVector<JoystickFeature, JOYSTICK_FEATURE> JoystickFeatures; | ||
| 657 | } | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_utils.hpp b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_utils.hpp new file mode 100644 index 0000000..cebce7e --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_utils.hpp | |||
| @@ -0,0 +1,96 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2015-2016 Team Kodi | ||
| 3 | * http://kodi.tv | ||
| 4 | * | ||
| 5 | * This Program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | * any later version. | ||
| 9 | * | ||
| 10 | * This Program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this Program; see the file COPYING. If not, see | ||
| 17 | * <http://www.gnu.org/licenses/>. | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | #pragma once | ||
| 21 | |||
| 22 | /*! | ||
| 23 | * @file kodi_vfs_utils.hpp - C++ wrappers for Kodi's VFS operations | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include "libXBMC_addon.h" | ||
| 27 | #include "kodi_vfs_types.h" | ||
| 28 | |||
| 29 | #include <stdint.h> | ||
| 30 | #include <string> | ||
| 31 | #include <vector> | ||
| 32 | |||
| 33 | namespace ADDON | ||
| 34 | { | ||
| 35 | class CVFSDirEntry | ||
| 36 | { | ||
| 37 | public: | ||
| 38 | CVFSDirEntry(const std::string& label = "", | ||
| 39 | const std::string& path = "", | ||
| 40 | bool bFolder = false, | ||
| 41 | int64_t size = -1) : | ||
| 42 | m_label(label), | ||
| 43 | m_path(path), | ||
| 44 | m_bFolder(bFolder), | ||
| 45 | m_size(size) | ||
| 46 | { | ||
| 47 | } | ||
| 48 | |||
| 49 | CVFSDirEntry(const VFSDirEntry& dirEntry) : | ||
| 50 | m_label(dirEntry.label ? dirEntry.label : ""), | ||
| 51 | m_path(dirEntry.path ? dirEntry.path : ""), | ||
| 52 | m_bFolder(dirEntry.folder), | ||
| 53 | m_size(dirEntry.size) | ||
| 54 | { | ||
| 55 | } | ||
| 56 | |||
| 57 | const std::string& Label(void) const { return m_label; } | ||
| 58 | const std::string& Path(void) const { return m_path; } | ||
| 59 | bool IsFolder(void) const { return m_bFolder; } | ||
| 60 | int64_t Size(void) const { return m_size; } | ||
| 61 | |||
| 62 | void SetLabel(const std::string& label) { m_label = label; } | ||
| 63 | void SetPath(const std::string& path) { m_path = path; } | ||
| 64 | void SetFolder(bool bFolder) { m_bFolder = bFolder; } | ||
| 65 | void SetSize(int64_t size) { m_size = size; } | ||
| 66 | |||
| 67 | private: | ||
| 68 | std::string m_label; | ||
| 69 | std::string m_path; | ||
| 70 | bool m_bFolder; | ||
| 71 | int64_t m_size; | ||
| 72 | }; | ||
| 73 | |||
| 74 | class VFSUtils | ||
| 75 | { | ||
| 76 | public: | ||
| 77 | static bool GetDirectory(ADDON::CHelper_libXBMC_addon* frontend, | ||
| 78 | const std::string& path, | ||
| 79 | const std::string& mask, | ||
| 80 | std::vector<CVFSDirEntry>& items) | ||
| 81 | { | ||
| 82 | VFSDirEntry* dir_list = nullptr; | ||
| 83 | unsigned int num_items = 0; | ||
| 84 | if (frontend->GetDirectory(path.c_str(), mask.c_str(), &dir_list, &num_items)) | ||
| 85 | { | ||
| 86 | for (unsigned int i = 0; i < num_items; i++) | ||
| 87 | items.push_back(CVFSDirEntry(dir_list[i])); | ||
| 88 | |||
| 89 | frontend->FreeDirectory(dir_list, num_items); | ||
| 90 | |||
| 91 | return true; | ||
| 92 | } | ||
| 93 | return false; | ||
| 94 | } | ||
| 95 | }; | ||
| 96 | } | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h index f541637..be3b93d 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h | |||
| @@ -311,11 +311,6 @@ public: | |||
| 311 | * @param ratio the new sample rate ratio, calculated by ((double)desiredRate / (double)GetSampleRate()) | 311 | * @param ratio the new sample rate ratio, calculated by ((double)desiredRate / (double)GetSampleRate()) |
| 312 | */ | 312 | */ |
| 313 | virtual void SetResampleRatio(double Ratio); | 313 | virtual void SetResampleRatio(double Ratio); |
| 314 | |||
| 315 | /** | ||
| 316 | * Sginal a clock change | ||
| 317 | */ | ||
| 318 | virtual void Discontinuity(); | ||
| 319 | 314 | ||
| 320 | private: | 315 | private: |
| 321 | AEStreamHandle *m_StreamHandle; | 316 | AEStreamHandle *m_StreamHandle; |
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 e0dc881..7fe1725 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 | |||
| @@ -40,6 +40,9 @@ | |||
| 40 | #define INPUTSTREAM_HELPER_DLL "/library.kodi.inputstream/" INPUTSTREAM_HELPER_DLL_NAME | 40 | #define INPUTSTREAM_HELPER_DLL "/library.kodi.inputstream/" INPUTSTREAM_HELPER_DLL_NAME |
| 41 | #endif | 41 | #endif |
| 42 | 42 | ||
| 43 | /* current input stream API version */ | ||
| 44 | #define KODI_INPUTSTREAM_API_VERSION "1.0.0" | ||
| 45 | |||
| 43 | class CHelper_libKODI_inputstream | 46 | class CHelper_libKODI_inputstream |
| 44 | { | 47 | { |
| 45 | public: | 48 | public: |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_peripheral.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_peripheral.h new file mode 100644 index 0000000..9f3f986 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_peripheral.h | |||
| @@ -0,0 +1,140 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2016 Team Kodi | ||
| 3 | * http://kodi.tv | ||
| 4 | * | ||
| 5 | * This Program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | * any later version. | ||
| 9 | * | ||
| 10 | * This Program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this Program; see the file COPYING. If not, see | ||
| 17 | * <http://www.gnu.org/licenses/>. | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | #pragma once | ||
| 21 | |||
| 22 | #include "libXBMC_addon.h" | ||
| 23 | #include "kodi_peripheral_callbacks.h" | ||
| 24 | |||
| 25 | #include <string> | ||
| 26 | #include <stdio.h> | ||
| 27 | |||
| 28 | #if defined(ANDROID) | ||
| 29 | #include <sys/stat.h> | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #ifdef _WIN32 | ||
| 33 | #define PERIPHERAL_HELPER_DLL "\\library.kodi.peripheral\\libKODI_peripheral" ADDON_HELPER_EXT | ||
| 34 | #else | ||
| 35 | #define PERIPHERAL_HELPER_DLL_NAME "libKODI_peripheral-" ADDON_HELPER_ARCH ADDON_HELPER_EXT | ||
| 36 | #define PERIPHERAL_HELPER_DLL "/library.kodi.peripheral/" PERIPHERAL_HELPER_DLL_NAME | ||
| 37 | #endif | ||
| 38 | |||
| 39 | #define PERIPHERAL_REGISTER_SYMBOL(dll, functionPtr) \ | ||
| 40 | CHelper_libKODI_peripheral::RegisterSymbol(dll, functionPtr, #functionPtr) | ||
| 41 | |||
| 42 | namespace ADDON | ||
| 43 | { | ||
| 44 | |||
| 45 | class CHelper_libKODI_peripheral | ||
| 46 | { | ||
| 47 | public: | ||
| 48 | CHelper_libKODI_peripheral(void) | ||
| 49 | { | ||
| 50 | m_handle = NULL; | ||
| 51 | m_callbacks = NULL; | ||
| 52 | m_libKODI_peripheral = NULL; | ||
| 53 | } | ||
| 54 | |||
| 55 | ~CHelper_libKODI_peripheral(void) | ||
| 56 | { | ||
| 57 | if (m_libKODI_peripheral) | ||
| 58 | { | ||
| 59 | PERIPHERAL_unregister_me(m_handle, m_callbacks); | ||
| 60 | dlclose(m_libKODI_peripheral); | ||
| 61 | } | ||
| 62 | } | ||
| 63 | |||
| 64 | template <typename T> | ||
| 65 | static bool RegisterSymbol(void* dll, T& functionPtr, const char* strFunctionPtr) | ||
| 66 | { | ||
| 67 | if ((functionPtr = (T)dlsym(dll, strFunctionPtr)) == NULL) | ||
| 68 | { | ||
| 69 | fprintf(stderr, "ERROR: Unable to assign function %s: %s\n", strFunctionPtr, dlerror()); | ||
| 70 | return false; | ||
| 71 | } | ||
| 72 | return true; | ||
| 73 | } | ||
| 74 | |||
| 75 | /*! | ||
| 76 | * @brief Resolve all callback methods | ||
| 77 | * @param handle Pointer to the add-on | ||
| 78 | * @return True when all methods were resolved, false otherwise. | ||
| 79 | */ | ||
| 80 | bool RegisterMe(void* handle) | ||
| 81 | { | ||
| 82 | m_handle = handle; | ||
| 83 | |||
| 84 | std::string libBasePath; | ||
| 85 | libBasePath = ((cb_array*)m_handle)->libPath; | ||
| 86 | libBasePath += PERIPHERAL_HELPER_DLL; | ||
| 87 | |||
| 88 | #if defined(ANDROID) | ||
| 89 | struct stat st; | ||
| 90 | if (stat(libBasePath.c_str(),&st) != 0) | ||
| 91 | { | ||
| 92 | std::string tempbin = getenv("XBMC_ANDROID_LIBS"); | ||
| 93 | libBasePath = tempbin + "/" + PERIPHERAL_HELPER_DLL_NAME; | ||
| 94 | } | ||
| 95 | #endif | ||
| 96 | |||
| 97 | m_libKODI_peripheral = dlopen(libBasePath.c_str(), RTLD_LAZY); | ||
| 98 | if (m_libKODI_peripheral == NULL) | ||
| 99 | { | ||
| 100 | fprintf(stderr, "Unable to load %s\n", dlerror()); | ||
| 101 | return false; | ||
| 102 | } | ||
| 103 | |||
| 104 | if (!PERIPHERAL_REGISTER_SYMBOL(m_libKODI_peripheral, PERIPHERAL_register_me)) return false; | ||
| 105 | if (!PERIPHERAL_REGISTER_SYMBOL(m_libKODI_peripheral, PERIPHERAL_unregister_me)) return false; | ||
| 106 | if (!PERIPHERAL_REGISTER_SYMBOL(m_libKODI_peripheral, PERIPHERAL_trigger_scan)) return false; | ||
| 107 | if (!PERIPHERAL_REGISTER_SYMBOL(m_libKODI_peripheral, PERIPHERAL_refresh_button_maps)) return false; | ||
| 108 | |||
| 109 | m_callbacks = PERIPHERAL_register_me(m_handle); | ||
| 110 | return m_callbacks != NULL; | ||
| 111 | } | ||
| 112 | |||
| 113 | void TriggerScan(void) | ||
| 114 | { | ||
| 115 | return PERIPHERAL_trigger_scan(m_handle, m_callbacks); | ||
| 116 | } | ||
| 117 | |||
| 118 | void RefreshButtonMaps(const std::string& strDeviceName = "", const std::string& strControllerId = "") | ||
| 119 | { | ||
| 120 | return PERIPHERAL_refresh_button_maps(m_handle, m_callbacks, strDeviceName.c_str(), strControllerId.c_str()); | ||
| 121 | } | ||
| 122 | |||
| 123 | protected: | ||
| 124 | CB_PeripheralLib* (*PERIPHERAL_register_me)(void* handle); | ||
| 125 | void (*PERIPHERAL_unregister_me)(void* handle, CB_PeripheralLib* cb); | ||
| 126 | void (*PERIPHERAL_trigger_scan)(void* handle, CB_PeripheralLib* cb); | ||
| 127 | void (*PERIPHERAL_refresh_button_maps)(void* handle, CB_PeripheralLib* cb, const char* deviceName, const char* controllerId); | ||
| 128 | |||
| 129 | private: | ||
| 130 | void* m_handle; | ||
| 131 | CB_PeripheralLib* m_callbacks; | ||
| 132 | void* m_libKODI_peripheral; | ||
| 133 | |||
| 134 | struct cb_array | ||
| 135 | { | ||
| 136 | const char* libPath; | ||
| 137 | }; | ||
| 138 | }; | ||
| 139 | |||
| 140 | } | ||
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 e8d5ec7..b32ad86 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 | |||
| @@ -86,6 +86,8 @@ typedef intptr_t ssize_t; | |||
| 86 | #include <sys/stat.h> | 86 | #include <sys/stat.h> |
| 87 | #endif | 87 | #endif |
| 88 | 88 | ||
| 89 | struct __stat64; | ||
| 90 | |||
| 89 | #ifdef LOG_DEBUG | 91 | #ifdef LOG_DEBUG |
| 90 | #undef LOG_DEBUG | 92 | #undef LOG_DEBUG |
| 91 | #endif | 93 | #endif |
| @@ -99,6 +101,9 @@ typedef intptr_t ssize_t; | |||
| 99 | #undef LOG_ERROR | 101 | #undef LOG_ERROR |
| 100 | #endif | 102 | #endif |
| 101 | 103 | ||
| 104 | /* current addon API version */ | ||
| 105 | #define KODI_ADDON_API_VERSION "1.0.0" | ||
| 106 | |||
| 102 | namespace ADDON | 107 | namespace ADDON |
| 103 | { | 108 | { |
| 104 | typedef enum addon_log | 109 | typedef enum addon_log |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_codec_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_codec_types.h index 01e7548..b1f43f9 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_codec_types.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_codec_types.h | |||
| @@ -24,6 +24,9 @@ | |||
| 24 | extern "C" { | 24 | extern "C" { |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | /* current codec API version */ | ||
| 28 | #define KODI_CODEC_API_VERSION "1.0.0" | ||
| 29 | |||
| 27 | typedef unsigned int xbmc_codec_id_t; | 30 | typedef unsigned int xbmc_codec_id_t; |
| 28 | 31 | ||
| 29 | typedef enum | 32 | typedef enum |
diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h index d64fbb3..dbee80a 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h | |||
| @@ -20,14 +20,17 @@ | |||
| 20 | * | 20 | * |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #include <cstdint> | ||
| 24 | |||
| 23 | #define DMX_SPECIALID_STREAMINFO -10 | 25 | #define DMX_SPECIALID_STREAMINFO -10 |
| 24 | #define DMX_SPECIALID_STREAMCHANGE -11 | 26 | #define DMX_SPECIALID_STREAMCHANGE -11 |
| 25 | 27 | ||
| 26 | typedef struct DemuxPacket | 28 | typedef struct DemuxPacket |
| 27 | { | 29 | { |
| 28 | unsigned char* pData; // data | 30 | unsigned char* pData; // data |
| 29 | int iSize; // data size | 31 | int iSize; // data size |
| 30 | int iStreamId; // integer representing the stream index | 32 | int iStreamId; // integer representing the stream index |
| 33 | int64_t demuxerId; // id of the demuxer that created the packet | ||
| 31 | int iGroupId; // the group this data belongs to, used to group data from different streams together | 34 | int iGroupId; // the group this data belongs to, used to group data from different streams together |
| 32 | 35 | ||
| 33 | double pts; // pts in DVD_TIME_BASE | 36 | double pts; // pts in DVD_TIME_BASE |
