| 1 |
/* |
| 2 |
* Copyright (C) 2016-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "addons/kodi-dev-kit/include/kodi/addon-instance/Game.h" |
| 12 |
#include "cores/RetroPlayer/streams/RetroPlayerStreamTypes.h" |
| 13 |
#include "games/controllers/ControllerTypes.h" |
| 14 |
#include "input/keyboard/KeyboardTypes.h" |
| 15 |
|
| 16 |
extern "C" |
| 17 |
{ |
| 18 |
#include <libavutil/pixfmt.h> |
| 19 |
} |
| 20 |
|
| 21 |
namespace KODI |
| 22 |
{ |
| 23 |
namespace GAME |
| 24 |
{ |
| 25 |
/*! |
| 26 |
* \ingroup games |
| 27 |
* |
| 28 |
* \brief Translates data types from Game API to the corresponding format in Kodi. |
| 29 |
* |
| 30 |
* This class is stateless. |
| 31 |
*/ |
| 32 |
class CGameClientTranslator |
| 33 |
{ |
| 34 |
CGameClientTranslator() = delete; |
| 35 |
|
| 36 |
public: |
| 37 |
/*! |
| 38 |
* \brief Translates game errors to string representation (e.g. for logging). |
| 39 |
* \param error The error to translate. |
| 40 |
* \return Translated error. |
| 41 |
*/ |
| 42 |
static const char* ToString(GAME_ERROR error); |
| 43 |
|
| 44 |
/*! |
| 45 |
* \brief Translates game memory types to string representation (e.g. for logging). |
| 46 |
* \param memory The memory type to translate. |
| 47 |
* \return Translated memory type. |
| 48 |
*/ |
| 49 |
static const char* ToString(GAME_MEMORY error); |
| 50 |
|
| 51 |
/*! |
| 52 |
* \brief Translate stream type (Game API to RetroPlayer). |
| 53 |
* \param gameType The stream type to translate. |
| 54 |
* \param[out] retroType The translated stream type. |
| 55 |
* \return True if the Game API type was translated to a valid RetroPlayer type |
| 56 |
*/ |
| 57 |
static bool TranslateStreamType(GAME_STREAM_TYPE gameType, RETRO::StreamType& retroType); |
| 58 |
|
| 59 |
/*! |
| 60 |
* \brief Translate pixel format (Game API to RetroPlayer/FFMPEG). |
| 61 |
* \param format The pixel format to translate. |
| 62 |
* \return Translated pixel format. |
| 63 |
*/ |
| 64 |
static AVPixelFormat TranslatePixelFormat(GAME_PIXEL_FORMAT format); |
| 65 |
|
| 66 |
/*! |
| 67 |
* \brief Translate pixel format (RetroPlayer/FFMPEG to Game API). |
| 68 |
* \param format The pixel format to translate. |
| 69 |
* \return Translated pixel format. |
| 70 |
*/ |
| 71 |
static GAME_PIXEL_FORMAT TranslatePixelFormat(AVPixelFormat format); |
| 72 |
|
| 73 |
/*! |
| 74 |
* \brief Translate audio PCM format (Game API to RetroPlayer). |
| 75 |
* \param format The audio PCM format to translate. |
| 76 |
* \return Translated audio PCM format. |
| 77 |
*/ |
| 78 |
static RETRO::PCMFormat TranslatePCMFormat(GAME_PCM_FORMAT format); |
| 79 |
|
| 80 |
/*! |
| 81 |
* \brief Translate audio channels (Game API to RetroPlayer). |
| 82 |
* \param format The audio channels to translate. |
| 83 |
* \return Translated audio channels. |
| 84 |
*/ |
| 85 |
static RETRO::AudioChannel TranslateAudioChannel(GAME_AUDIO_CHANNEL channel); |
| 86 |
|
| 87 |
/*! |
| 88 |
* \brief Translate video rotation (Game API to RetroPlayer). |
| 89 |
* \param rotation The video rotation to translate. |
| 90 |
* \return Translated video rotation. |
| 91 |
*/ |
| 92 |
static RETRO::VideoRotation TranslateRotation(GAME_VIDEO_ROTATION rotation); |
| 93 |
|
| 94 |
/*! |
| 95 |
* \brief Translate key modifiers (Kodi to Game API). |
| 96 |
* \param modifiers The key modifiers to translate (e.g. Shift, Ctrl). |
| 97 |
* \return Translated key modifiers. |
| 98 |
*/ |
| 99 |
static GAME_KEY_MOD GetModifiers(KEYBOARD::Modifier modifier); |
| 100 |
|
| 101 |
/*! |
| 102 |
* \brief Translate region to string representation (e.g. for logging). |
| 103 |
* \param error The region to translate (e.g. PAL, NTSC). |
| 104 |
* \return Translated region. |
| 105 |
*/ |
| 106 |
static const char* TranslateRegion(GAME_REGION region); |
| 107 |
|
| 108 |
/*! |
| 109 |
* \brief Translate port type (Game API to Kodi) |
| 110 |
* \param portType The port type to translate |
| 111 |
* \return Translated port type |
| 112 |
*/ |
| 113 |
static PORT_TYPE TranslatePortType(GAME_PORT_TYPE portType); |
| 114 |
}; |
| 115 |
} // namespace GAME |
| 116 |
} // namespace KODI |