| 1 |
/* |
| 2 |
* Copyright (C) 2017-2024 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 |
#include "AppTranslator.h" |
| 10 |
|
| 11 |
#include "input/keyboard/KeyIDs.h" |
| 12 |
#include "utils/StringUtils.h" |
| 13 |
#include "utils/log.h" |
| 14 |
|
| 15 |
#include <map> |
| 16 |
|
| 17 |
using namespace KODI; |
| 18 |
using namespace KEYMAP; |
| 19 |
|
| 20 |
namespace |
| 21 |
{ |
| 22 |
|
| 23 |
using ActionName = std::string; |
| 24 |
using CommandID = uint32_t; |
| 25 |
|
| 26 |
#ifdef TARGET_WINDOWS |
| 27 |
static const std::map<ActionName, CommandID> AppCommands = { |
| 28 |
{"browser_back", APPCOMMAND_BROWSER_BACKWARD}, |
| 29 |
{"browser_forward", APPCOMMAND_BROWSER_FORWARD}, |
| 30 |
{"browser_refresh", APPCOMMAND_BROWSER_REFRESH}, |
| 31 |
{"browser_stop", APPCOMMAND_BROWSER_STOP}, |
| 32 |
{"browser_search", APPCOMMAND_BROWSER_SEARCH}, |
| 33 |
{"browser_favorites", APPCOMMAND_BROWSER_FAVORITES}, |
| 34 |
{"browser_home", APPCOMMAND_BROWSER_HOME}, |
| 35 |
{"volume_mute", APPCOMMAND_VOLUME_MUTE}, |
| 36 |
{"volume_down", APPCOMMAND_VOLUME_DOWN}, |
| 37 |
{"volume_up", APPCOMMAND_VOLUME_UP}, |
| 38 |
{"next_track", APPCOMMAND_MEDIA_NEXTTRACK}, |
| 39 |
{"prev_track", APPCOMMAND_MEDIA_PREVIOUSTRACK}, |
| 40 |
{"stop", APPCOMMAND_MEDIA_STOP}, |
| 41 |
{"play_pause", APPCOMMAND_MEDIA_PLAY_PAUSE}, |
| 42 |
{"launch_mail", APPCOMMAND_LAUNCH_MAIL}, |
| 43 |
{"launch_media_select", APPCOMMAND_LAUNCH_MEDIA_SELECT}, |
| 44 |
{"launch_app1", APPCOMMAND_LAUNCH_APP1}, |
| 45 |
{"launch_app2", APPCOMMAND_LAUNCH_APP2}, |
| 46 |
{"play", APPCOMMAND_MEDIA_PLAY}, |
| 47 |
{"pause", APPCOMMAND_MEDIA_PAUSE}, |
| 48 |
{"fastforward", APPCOMMAND_MEDIA_FAST_FORWARD}, |
| 49 |
{"rewind", APPCOMMAND_MEDIA_REWIND}, |
| 50 |
{"channelup", APPCOMMAND_MEDIA_CHANNEL_UP}, |
| 51 |
{"channeldown", APPCOMMAND_MEDIA_CHANNEL_DOWN}}; |
| 52 |
#endif |
| 53 |
|
| 54 |
} // anonymous namespace |
| 55 |
|
| 56 |
uint32_t CAppTranslator::TranslateAppCommand(const std::string& szButton) |
| 57 |
{ |
| 58 |
#ifdef TARGET_WINDOWS |
| 59 |
std::string strAppCommand = szButton; |
| 60 |
StringUtils::ToLower(strAppCommand); |
| 61 |
|
| 62 |
auto it = AppCommands.find(strAppCommand); |
| 63 |
if (it != AppCommands.end()) |
| 64 |
return it->second | KEY_APPCOMMAND; |
| 65 |
|
| 66 |
CLog::Log(LOGERROR, "{}: Can't find appcommand {}", __FUNCTION__, szButton); |
| 67 |
#endif |
| 68 |
|
| 69 |
return 0; |
| 70 |
} |