diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
commit | c04dcc2e7d834218ef2d4194331e383402495ae1 (patch) | |
tree | 7333e38d10d75386e60f336b80c2443c1166031d /xbmc/input/actions | |
parent | Initial commit. (diff) | |
download | kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip |
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/input/actions')
-rw-r--r-- | xbmc/input/actions/Action.cpp | 154 | ||||
-rw-r--r-- | xbmc/input/actions/Action.h | 123 | ||||
-rw-r--r-- | xbmc/input/actions/ActionIDs.h | 493 | ||||
-rw-r--r-- | xbmc/input/actions/ActionTranslator.cpp | 311 | ||||
-rw-r--r-- | xbmc/input/actions/ActionTranslator.h | 20 | ||||
-rw-r--r-- | xbmc/input/actions/CMakeLists.txt | 10 |
6 files changed, 1111 insertions, 0 deletions
diff --git a/xbmc/input/actions/Action.cpp b/xbmc/input/actions/Action.cpp new file mode 100644 index 0000000..8449e42 --- /dev/null +++ b/xbmc/input/actions/Action.cpp @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "Action.h" + +#include "ActionIDs.h" +#include "ActionTranslator.h" +#include "input/Key.h" + +CAction::CAction() : m_id(ACTION_NONE) +{ +} + +CAction::CAction(int actionID, + float amount1 /* = 1.0f */, + float amount2 /* = 0.0f */, + const std::string& name /* = "" */, + unsigned int holdTime /*= 0*/) + : m_name(name) +{ + m_id = actionID; + m_amount[0] = amount1; + m_amount[1] = amount2; + m_repeat = 0; + m_buttonCode = 0; + m_unicode = 0; + m_holdTime = holdTime; +} + +CAction::CAction(int actionID, + unsigned int state, + float posX, + float posY, + float offsetX, + float offsetY, + float velocityX, + float velocityY, + const std::string& name) + : m_name(name) +{ + m_id = actionID; + m_amount[0] = posX; + m_amount[1] = posY; + m_amount[2] = offsetX; + m_amount[3] = offsetY; + m_amount[4] = velocityX; + m_amount[5] = velocityY; + m_repeat = 0; + m_buttonCode = 0; + m_unicode = 0; + m_holdTime = state; +} + +CAction::CAction(int actionID, wchar_t unicode) +{ + m_id = actionID; + m_repeat = 0; + m_buttonCode = 0; + m_unicode = unicode; + m_holdTime = 0; +} + +CAction::CAction(int actionID, const std::string& name, const CKey& key) : m_name(name) +{ + m_id = actionID; + m_amount[0] = 1; // digital button (could change this for repeat acceleration) + m_repeat = key.GetRepeat(); + m_buttonCode = key.GetButtonCode(); + m_unicode = key.GetUnicode(); + m_holdTime = key.GetHeld(); + // get the action amounts of the analog buttons + if (key.GetButtonCode() == KEY_BUTTON_LEFT_ANALOG_TRIGGER) + m_amount[0] = (float)key.GetLeftTrigger() / 255.0f; + else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_ANALOG_TRIGGER) + m_amount[0] = (float)key.GetRightTrigger() / 255.0f; + else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK) + { + m_amount[0] = key.GetLeftThumbX(); + m_amount[1] = key.GetLeftThumbY(); + } + else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK) + { + m_amount[0] = key.GetRightThumbX(); + m_amount[1] = key.GetRightThumbY(); + } + else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_UP) + m_amount[0] = key.GetLeftThumbY(); + else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_DOWN) + m_amount[0] = -key.GetLeftThumbY(); + else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_LEFT) + m_amount[0] = -key.GetLeftThumbX(); + else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_RIGHT) + m_amount[0] = key.GetLeftThumbX(); + else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_UP) + m_amount[0] = key.GetRightThumbY(); + else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_DOWN) + m_amount[0] = -key.GetRightThumbY(); + else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_LEFT) + m_amount[0] = -key.GetRightThumbX(); + else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_RIGHT) + m_amount[0] = key.GetRightThumbX(); +} + +CAction::CAction(int actionID, const std::string& name) : m_name(name) +{ + m_id = actionID; + m_repeat = 0; + m_buttonCode = 0; + m_unicode = 0; + m_holdTime = 0; +} + +CAction& CAction::operator=(const CAction& rhs) +{ + if (this != &rhs) + { + m_id = rhs.m_id; + for (unsigned int i = 0; i < max_amounts; i++) + m_amount[i] = rhs.m_amount[i]; + m_name = rhs.m_name; + m_repeat = rhs.m_repeat; + m_buttonCode = rhs.m_buttonCode; + m_unicode = rhs.m_unicode; + m_holdTime = rhs.m_holdTime; + m_text = rhs.m_text; + } + return *this; +} + +void CAction::ClearAmount() +{ + for (float& amount : m_amount) + amount = 0; +} + +bool CAction::IsMouse() const +{ + return (m_id >= ACTION_MOUSE_START && m_id <= ACTION_MOUSE_END); +} + +bool CAction::IsGesture() const +{ + return (m_id >= ACTION_GESTURE_NOTIFY && m_id <= ACTION_GESTURE_END); +} + +bool CAction::IsAnalog() const +{ + return CActionTranslator::IsAnalog(m_id); +} diff --git a/xbmc/input/actions/Action.h b/xbmc/input/actions/Action.h new file mode 100644 index 0000000..f1d4173 --- /dev/null +++ b/xbmc/input/actions/Action.h @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include <string> + +#ifndef SWIG + +class CKey; + +/*! + \ingroup actionkeys + \brief class encapsulating information regarding a particular user action to be sent to windows + and controls + */ +class CAction +{ +public: + CAction(); + CAction(int actionID, + float amount1 = 1.0f, + float amount2 = 0.0f, + const std::string& name = "", + unsigned int holdTime = 0); + CAction(int actionID, wchar_t unicode); + CAction(int actionID, + unsigned int state, + float posX, + float posY, + float offsetX, + float offsetY, + float velocityX = 0.0f, + float velocityY = 0.0f, + const std::string& name = ""); + CAction(int actionID, const std::string& name, const CKey& key); + CAction(int actionID, const std::string& name); + + CAction(const CAction& other) { *this = other; } + CAction& operator=(const CAction& rhs); + + /*! \brief Identifier of the action + \return id of the action + */ + int GetID() const { return m_id; } + + /*! \brief Is this an action from the mouse + \return true if this is a mouse action, false otherwise + */ + bool IsMouse() const; + + bool IsGesture() const; + + /*! \brief Human-readable name of the action + \return name of the action + */ + const std::string& GetName() const { return m_name; } + + /*! \brief Text of the action if any + \return text payload of this action. + */ + const std::string& GetText() const { return m_text; } + + /*! \brief Set the text payload of the action + \param text to be set + */ + void SetText(const std::string& text) { m_text = text; } + + /*! \brief Get an amount associated with this action + \param zero-based index of amount to retrieve, defaults to 0 + \return an amount associated with this action + */ + float GetAmount(unsigned int index = 0) const + { + return (index < max_amounts) ? m_amount[index] : 0; + }; + + /*! \brief Reset all amount values to zero + */ + void ClearAmount(); + + /*! \brief Unicode value associated with this action + \return unicode value associated with this action, for keyboard input. + */ + wchar_t GetUnicode() const { return m_unicode; } + + /*! \brief Time in ms that the key has been held + \return time that the key has been held down in ms. + */ + unsigned int GetHoldTime() const { return m_holdTime; } + + /*! \brief Time since last repeat in ms + \return time since last repeat in ms. Returns 0 if unknown. + */ + float GetRepeat() const { return m_repeat; } + + /*! \brief Button code that triggered this action + \return button code + */ + unsigned int GetButtonCode() const { return m_buttonCode; } + + bool IsAnalog() const; + +private: + int m_id; + std::string m_name; + + static const unsigned int max_amounts = 6; // Must be at least 6 + float m_amount[max_amounts] = {}; + + float m_repeat = 0.0f; + unsigned int m_holdTime = 0; + unsigned int m_buttonCode = 0; + wchar_t m_unicode = 0; + std::string m_text; +}; + +#endif diff --git a/xbmc/input/actions/ActionIDs.h b/xbmc/input/actions/ActionIDs.h new file mode 100644 index 0000000..50fa662 --- /dev/null +++ b/xbmc/input/actions/ActionIDs.h @@ -0,0 +1,493 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +/** + * \defgroup kodi_key_action_ids Action Id's + * \ingroup python_xbmcgui_window_cb + * \ingroup python_xbmcgui_action + * @{ + * @brief Actions that we have defined. + */ + +constexpr const int ACTION_NONE = 0; +constexpr const int ACTION_MOVE_LEFT = 1; +constexpr const int ACTION_MOVE_RIGHT = 2; +constexpr const int ACTION_MOVE_UP = 3; +constexpr const int ACTION_MOVE_DOWN = 4; +constexpr const int ACTION_PAGE_UP = 5; +constexpr const int ACTION_PAGE_DOWN = 6; +constexpr const int ACTION_SELECT_ITEM = 7; +constexpr const int ACTION_HIGHLIGHT_ITEM = 8; +constexpr const int ACTION_PARENT_DIR = 9; +constexpr const int ACTION_PREVIOUS_MENU = 10; +constexpr const int ACTION_SHOW_INFO = 11; + +constexpr const int ACTION_PAUSE = 12; +constexpr const int ACTION_STOP = 13; +constexpr const int ACTION_NEXT_ITEM = 14; +constexpr const int ACTION_PREV_ITEM = 15; + +//! Can be used to specify specific action in a window, Playback control is +//! handled in ACTION_PLAYER_* +constexpr const int ACTION_FORWARD = 16; + +//! Can be used to specify specific action in a window, Playback control is +//! handled in ACTION_PLAYER_* +constexpr const int ACTION_REWIND = 17; + +//! Toggle between GUI and movie or GUI and visualisation. +constexpr const int ACTION_SHOW_GUI = 18; + +//! Toggle quick-access zoom modes. Can be used in videoFullScreen.zml window id=2005 +constexpr const int ACTION_ASPECT_RATIO = 19; + +//! Seek +1% in the movie. Can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_STEP_FORWARD = 20; + +//! Seek -1% in the movie. Can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_STEP_BACK = 21; + +//! Seek +10% in the movie. Can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_BIG_STEP_FORWARD = 22; + +//! Seek -10% in the movie. Can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_BIG_STEP_BACK = 23; + +//! Show/hide OSD. Can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_SHOW_OSD = 24; + +//! Turn subtitles on/off. Can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_SHOW_SUBTITLES = 25; + +//! Switch to next subtitle of movie. Can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_NEXT_SUBTITLE = 26; + +//! Show debug info for VideoPlayer +constexpr const int ACTION_PLAYER_DEBUG = 27; + +//! Show next picture of slideshow. Can be used in slideshow.xml window id=2007 +constexpr const int ACTION_NEXT_PICTURE = 28; + +//! Show previous picture of slideshow. Can be used in slideshow.xml window id=2007 +constexpr const int ACTION_PREV_PICTURE = 29; + +//! Zoom in picture during slideshow. Can be used in slideshow.xml window id=2007 +constexpr const int ACTION_ZOOM_OUT = 30; + +//! Zoom out picture during slideshow. Can be used in slideshow.xml window id=2007 +constexpr const int ACTION_ZOOM_IN = 31; + +//! Used to toggle between source view and destination view. Can be used in +//! myfiles.xml window < id=3 +constexpr const int ACTION_TOGGLE_SOURCE_DEST = 32; + +//! Used to toggle between current view and playlist view. Can be used in all mymusic xml files +constexpr const int ACTION_SHOW_PLAYLIST = 33; + +//! Used to queue a item to the playlist. Can be used in all mymusic xml files +constexpr const int ACTION_QUEUE_ITEM = 34; + +//! Not used anymore +constexpr const int ACTION_REMOVE_ITEM = 35; + +//! Not used anymore +constexpr const int ACTION_SHOW_FULLSCREEN = 36; + +//! Zoom 1x picture during slideshow. Can be used in slideshow.xml window id=2007 +constexpr const int ACTION_ZOOM_LEVEL_NORMAL = 37; + +//! Zoom 2x picture during slideshow. Can be used in slideshow.xml window id=2007 +constexpr const int ACTION_ZOOM_LEVEL_1 = 38; + +//! Zoom 3x picture during slideshow. Can be used in slideshow.xml window id=2007 +constexpr const int ACTION_ZOOM_LEVEL_2 = 39; + +//! Zoom 4x picture during slideshow. Can be used in slideshow.xml window id=2007 +constexpr const int ACTION_ZOOM_LEVEL_3 = 40; + +//! Zoom 5x picture during slideshow. Can be used in slideshow.xml window id=2007 +constexpr const int ACTION_ZOOM_LEVEL_4 = 41; + +//! Zoom 6x picture during slideshow. Can be used in slideshow.xml window id=2007 +constexpr const int ACTION_ZOOM_LEVEL_5 = 42; + +//! Zoom 7x picture during slideshow. Can be used in slideshow.xml window id=2007 +constexpr const int ACTION_ZOOM_LEVEL_6 = 43; + +//! Zoom 8x picture during slideshow. Can be used in slideshow.xml window id=2007 +constexpr const int ACTION_ZOOM_LEVEL_7 = 44; + +//! Zoom 9x picture during slideshow. Can be used in slideshow.xml window id=2007 +constexpr const int ACTION_ZOOM_LEVEL_8 = 45; + +//< Zoom 10x picture during slideshow. Can be used in slideshow.xml window id=2007 +constexpr const int ACTION_ZOOM_LEVEL_9 = 46; + +//< Select next arrow. Can be used in: settingsScreenCalibration.xml windowid=11 +constexpr const int ACTION_CALIBRATE_SWAP_ARROWS = 47; + +//! Reset calibration to defaults. Can be used in: `settingsScreenCalibration.xml` +//! windowid=11/settingsUICalibration.xml windowid=10 +constexpr const int ACTION_CALIBRATE_RESET = 48; + +//! Analog thumbstick move. Can be used in: `slideshow.xml` +//! windowid=2007/settingsScreenCalibration.xml windowid=11/settingsUICalibration.xml +//! windowid=10 +//! @note see also ACTION_ANALOG_MOVE_X_LEFT, ACTION_ANALOG_MOVE_X_RIGHT, +//! ACTION_ANALOG_MOVE_Y_UP, ACTION_ANALOG_MOVE_Y_DOWN +constexpr const int ACTION_ANALOG_MOVE = 49; + +//! Rotate current picture clockwise during slideshow. Can be used in +//! slideshow.xml window < id=2007 +constexpr const int ACTION_ROTATE_PICTURE_CW = 50; + +//! Rotate current picture counterclockwise during slideshow. Can be used in +//! slideshow.xml window id=2007 +constexpr const int ACTION_ROTATE_PICTURE_CCW = 51; + +//! Decrease subtitle/movie Delay. Can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_SUBTITLE_DELAY_MIN = 52; + +//! Increase subtitle/movie Delay. Can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_SUBTITLE_DELAY_PLUS = 53; + +//! Increase avsync delay. Can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_AUDIO_DELAY_MIN = 54; + +//! Decrease avsync delay. Can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_AUDIO_DELAY_PLUS = 55; + +//! Select next language in movie. Can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_AUDIO_NEXT_LANGUAGE = 56; + +//! Switch 2 next resolution. Can b used during screen calibration +//! settingsScreenCalibration.xml windowid=11 +constexpr const int ACTION_CHANGE_RESOLUTION = 57; + +//! Remote keys 0-9 are used by multiple windows. +//! +//! For example, in videoFullScreen.xml window id=2005 you can enter +//! time (mmss) to jump to particular point in the movie. +//! +//! With spincontrols you can enter a 3-digit number to quickly set the +//! spincontrol to desired value. +//!@{ +constexpr const int REMOTE_0 = 58; + +//! @see REMOTE_0 about details. +constexpr const int REMOTE_1 = 59; + +//! @see REMOTE_0 about details. +constexpr const int REMOTE_2 = 60; + +//! @see REMOTE_0 about details. +constexpr const int REMOTE_3 = 61; + +//! @see REMOTE_0 about details. +constexpr const int REMOTE_4 = 62; + +//! @see REMOTE_0 about details. +constexpr const int REMOTE_5 = 63; + +//! @see REMOTE_0 about details. +constexpr const int REMOTE_6 = 64; + +//! @see REMOTE_0 about details. +constexpr const int REMOTE_7 = 65; + +//! @see REMOTE_0 about details. +constexpr const int REMOTE_8 = 66; + +//! @see REMOTE_0 about details. +constexpr const int REMOTE_9 = 67; +//!@} + +//! Show player process info (video decoder, pixel format, pvr signal strength +//! and the like +constexpr const int ACTION_PLAYER_PROCESS_INFO = 69; + +constexpr const int ACTION_PLAYER_PROGRAM_SELECT = 70; + +constexpr const int ACTION_PLAYER_RESOLUTION_SELECT = 71; + +//! Jumps a few seconds back during playback of movie. Can be used in videoFullScreen.xml +//! window id=2005 +constexpr const int ACTION_SMALL_STEP_BACK = 76; + +//! FF in current file played. global action, can be used anywhere +constexpr const int ACTION_PLAYER_FORWARD = 77; + +//! RW in current file played. global action, can be used anywhere +constexpr const int ACTION_PLAYER_REWIND = 78; + +//! Play current song. Unpauses song and sets playspeed to 1x. global action, +//! can be used anywhere +constexpr const int ACTION_PLAYER_PLAY = 79; + +//! Delete current selected item. Can be used in myfiles.xml window id=3 and in +//! myvideoTitle.xml window id=25 +constexpr const int ACTION_DELETE_ITEM = 80; + +//! Copy current selected item. Can be used in myfiles.xml window id=3 +constexpr const int ACTION_COPY_ITEM = 81; + +//! Move current selected item. Can be used in myfiles.xml window id=3 +constexpr const int ACTION_MOVE_ITEM = 82; + +//! Take a screenshot +constexpr const int ACTION_TAKE_SCREENSHOT = 85; + +//! Rename item +constexpr const int ACTION_RENAME_ITEM = 87; + +constexpr const int ACTION_VOLUME_UP = 88; +constexpr const int ACTION_VOLUME_DOWN = 89; +constexpr const int ACTION_VOLAMP = 90; +constexpr const int ACTION_MUTE = 91; +constexpr const int ACTION_NAV_BACK = 92; +constexpr const int ACTION_VOLAMP_UP = 93; +constexpr const int ACTION_VOLAMP_DOWN = 94; + +//! Creates an episode bookmark on the currently playing video file containing +//! more than one episode +constexpr const int ACTION_CREATE_EPISODE_BOOKMARK = 95; + +//! Creates a bookmark of the currently playing video file +constexpr const int ACTION_CREATE_BOOKMARK = 96; + +//! Goto the next chapter, if not available perform a big step forward +constexpr const int ACTION_CHAPTER_OR_BIG_STEP_FORWARD = 97; + +//! Goto the previous chapter, if not available perform a big step back +constexpr const int ACTION_CHAPTER_OR_BIG_STEP_BACK = 98; + +//! Switch to next subtitle of movie, but will not enable/disable the subtitles. +//! Can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_CYCLE_SUBTITLE = 99; + +constexpr const int ACTION_MOUSE_START = 100; +constexpr const int ACTION_MOUSE_LEFT_CLICK = 100; +constexpr const int ACTION_MOUSE_RIGHT_CLICK = 101; +constexpr const int ACTION_MOUSE_MIDDLE_CLICK = 102; +constexpr const int ACTION_MOUSE_DOUBLE_CLICK = 103; +constexpr const int ACTION_MOUSE_WHEEL_UP = 104; +constexpr const int ACTION_MOUSE_WHEEL_DOWN = 105; +constexpr const int ACTION_MOUSE_DRAG = 106; +constexpr const int ACTION_MOUSE_MOVE = 107; +constexpr const int ACTION_MOUSE_LONG_CLICK = 108; +constexpr const int ACTION_MOUSE_DRAG_END = 109; +constexpr const int ACTION_MOUSE_END = 109; + +constexpr const int ACTION_BACKSPACE = 110; +constexpr const int ACTION_SCROLL_UP = 111; +constexpr const int ACTION_SCROLL_DOWN = 112; +constexpr const int ACTION_ANALOG_FORWARD = 113; +constexpr const int ACTION_ANALOG_REWIND = 114; + +constexpr const int ACTION_MOVE_ITEM_UP = 115; //!< move item up in playlist +constexpr const int ACTION_MOVE_ITEM_DOWN = 116; //!< move item down in playlist +constexpr const int ACTION_CONTEXT_MENU = 117; //!< pops up the context menu + +// stuff for virtual keyboard shortcuts +constexpr const int ACTION_SHIFT = 118; //!< stuff for virtual keyboard shortcuts +constexpr const int ACTION_SYMBOLS = 119; //!< stuff for virtual keyboard shortcuts +constexpr const int ACTION_CURSOR_LEFT = 120; //!< stuff for virtual keyboard shortcuts +constexpr const int ACTION_CURSOR_RIGHT = 121; //!< stuff for virtual keyboard shortcuts + +constexpr const int ACTION_BUILT_IN_FUNCTION = 122; + +//! Displays current time, can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_SHOW_OSD_TIME = 123; + +constexpr const int ACTION_ANALOG_SEEK_FORWARD = 124; //!< seeks forward, and displays the seek bar. +constexpr const int ACTION_ANALOG_SEEK_BACK = 125; //!< seeks backward, and displays the seek bar. + +constexpr const int ACTION_VIS_PRESET_SHOW = 126; +constexpr const int ACTION_VIS_PRESET_NEXT = 128; +constexpr const int ACTION_VIS_PRESET_PREV = 129; +constexpr const int ACTION_VIS_PRESET_LOCK = 130; +constexpr const int ACTION_VIS_PRESET_RANDOM = 131; +constexpr const int ACTION_VIS_RATE_PRESET_PLUS = 132; +constexpr const int ACTION_VIS_RATE_PRESET_MINUS = 133; + +constexpr const int ACTION_SHOW_VIDEOMENU = 134; +constexpr const int ACTION_ENTER = 135; + +constexpr const int ACTION_INCREASE_RATING = 136; +constexpr const int ACTION_DECREASE_RATING = 137; + +constexpr const int ACTION_NEXT_SCENE = 138; //!< switch to next scene/cutpoint in movie +constexpr const int ACTION_PREV_SCENE = 139; //!< switch to previous scene/cutpoint in movie + +constexpr const int ACTION_NEXT_LETTER = 140; //!< jump through a list or container by letter +constexpr const int ACTION_PREV_LETTER = 141; + +constexpr const int ACTION_JUMP_SMS2 = 142; //!< jump direct to a particular letter using SMS-style input +constexpr const int ACTION_JUMP_SMS3 = 143; +constexpr const int ACTION_JUMP_SMS4 = 144; +constexpr const int ACTION_JUMP_SMS5 = 145; +constexpr const int ACTION_JUMP_SMS6 = 146; +constexpr const int ACTION_JUMP_SMS7 = 147; +constexpr const int ACTION_JUMP_SMS8 = 148; +constexpr const int ACTION_JUMP_SMS9 = 149; + +constexpr const int ACTION_FILTER_CLEAR = 150; +constexpr const int ACTION_FILTER_SMS2 = 151; +constexpr const int ACTION_FILTER_SMS3 = 152; +constexpr const int ACTION_FILTER_SMS4 = 153; +constexpr const int ACTION_FILTER_SMS5 = 154; +constexpr const int ACTION_FILTER_SMS6 = 155; +constexpr const int ACTION_FILTER_SMS7 = 156; +constexpr const int ACTION_FILTER_SMS8 = 157; +constexpr const int ACTION_FILTER_SMS9 = 158; + +constexpr const int ACTION_FIRST_PAGE = 159; +constexpr const int ACTION_LAST_PAGE = 160; + +constexpr const int ACTION_AUDIO_DELAY = 161; +constexpr const int ACTION_SUBTITLE_DELAY = 162; +constexpr const int ACTION_MENU = 163; + +constexpr const int ACTION_SET_RATING = 164; + +constexpr const int ACTION_RECORD = 170; + +constexpr const int ACTION_PASTE = 180; +constexpr const int ACTION_NEXT_CONTROL = 181; +constexpr const int ACTION_PREV_CONTROL = 182; +constexpr const int ACTION_CHANNEL_SWITCH = 183; +constexpr const int ACTION_CHANNEL_UP = 184; +constexpr const int ACTION_CHANNEL_DOWN = 185; +constexpr const int ACTION_NEXT_CHANNELGROUP = 186; +constexpr const int ACTION_PREVIOUS_CHANNELGROUP = 187; +constexpr const int ACTION_PVR_PLAY = 188; +constexpr const int ACTION_PVR_PLAY_TV = 189; +constexpr const int ACTION_PVR_PLAY_RADIO = 190; +constexpr const int ACTION_PVR_SHOW_TIMER_RULE = 191; +constexpr const int ACTION_CHANNEL_NUMBER_SEP = 192; +constexpr const int ACTION_PVR_ANNOUNCE_REMINDERS = 193; + +constexpr const int ACTION_TOGGLE_FULLSCREEN = 199; //!< switch 2 desktop resolution +constexpr const int ACTION_TOGGLE_WATCHED = 200; //!< Toggle watched status (videos) +constexpr const int ACTION_SCAN_ITEM = 201; //!< scan item +constexpr const int ACTION_TOGGLE_DIGITAL_ANALOG = 202; //!< switch digital <-> analog +constexpr const int ACTION_RELOAD_KEYMAPS = 203; //!< reloads CButtonTranslator's keymaps +constexpr const int ACTION_GUIPROFILE_BEGIN = 204; //!< start the GUIControlProfiler running + +constexpr const int ACTION_TELETEXT_RED = 215; //!< Teletext Color button <b>Red</b> to control TopText +constexpr const int ACTION_TELETEXT_GREEN = 216; //!< Teletext Color button <b>Green</b> to control TopText +constexpr const int ACTION_TELETEXT_YELLOW = 217; //!< Teletext Color button <b>Yellow</b> to control TopText +constexpr const int ACTION_TELETEXT_BLUE = 218; //!< Teletext Color button <b>Blue</b> to control TopText + +constexpr const int ACTION_INCREASE_PAR = 219; +constexpr const int ACTION_DECREASE_PAR = 220; + +constexpr const int ACTION_VSHIFT_UP = 227; //!< shift up video image in VideoPlayer +constexpr const int ACTION_VSHIFT_DOWN = 228; //!< shift down video image in VideoPlayer + +constexpr const int ACTION_PLAYER_PLAYPAUSE = 229; //!< Play/pause. If playing it pauses, if paused it plays. + +constexpr const int ACTION_SUBTITLE_VSHIFT_UP = 230; //!< shift up subtitles in VideoPlayer +constexpr const int ACTION_SUBTITLE_VSHIFT_DOWN = 231; //!< shift down subtitles in VideoPlayer +constexpr const int ACTION_SUBTITLE_ALIGN = 232; //!< toggle vertical alignment of subtitles + +constexpr const int ACTION_FILTER = 233; + +constexpr const int ACTION_SWITCH_PLAYER = 234; + +constexpr const int ACTION_STEREOMODE_NEXT = 235; +constexpr const int ACTION_STEREOMODE_PREVIOUS = 236; +constexpr const int ACTION_STEREOMODE_TOGGLE = 237; //!< turns 3d mode on/off +constexpr const int ACTION_STEREOMODE_SELECT = 238; +constexpr const int ACTION_STEREOMODE_TOMONO = 239; +constexpr const int ACTION_STEREOMODE_SET = 240; + +constexpr const int ACTION_SETTINGS_RESET = 241; +constexpr const int ACTION_SETTINGS_LEVEL_CHANGE = 242; + +//! Show autoclosing OSD. Can be used in videoFullScreen.xml window id=2005 +constexpr const int ACTION_TRIGGER_OSD = 243; +constexpr const int ACTION_INPUT_TEXT = 244; +constexpr const int ACTION_VOLUME_SET = 245; +constexpr const int ACTION_TOGGLE_COMMSKIP = 246; + +constexpr const int ACTION_BROWSE_SUBTITLE = 247; //!< Browse for subtitle. Can be used in videofullscreen + +constexpr const int ACTION_PLAYER_RESET = 248; //!< Send a reset command to the active game + +constexpr const int ACTION_TOGGLE_FONT = 249; //!< Toggle font. Used in TextViewer dialog + +constexpr const int ACTION_VIDEO_NEXT_STREAM = 250; //!< Cycle video streams. Used in videofullscreen. + +//! Used to queue an item to the next position in the playlist +constexpr const int ACTION_QUEUE_ITEM_NEXT = 251; + +constexpr const int ACTION_HDR_TOGGLE = 260; //!< Toggle display HDR on/off + +constexpr const int ACTION_CYCLE_TONEMAP_METHOD = 261; //!< Switch to next tonemap method + +//! Show debug info for video (source format, metadata, shaders, render flags and output format) +constexpr const int ACTION_PLAYER_DEBUG_VIDEO = 262; + +// Voice actions +constexpr const int ACTION_VOICE_RECOGNIZE = 300; + +// Touch actions +constexpr const int ACTION_TOUCH_TAP = 401; //!< touch actions +constexpr const int ACTION_TOUCH_TAP_TEN = 410; //!< touch actions +constexpr const int ACTION_TOUCH_LONGPRESS = 411; //!< touch actions +constexpr const int ACTION_TOUCH_LONGPRESS_TEN = 420; //!< touch actions + +constexpr const int ACTION_GESTURE_NOTIFY = 500; +constexpr const int ACTION_GESTURE_BEGIN = 501; + +//! sendaction with point and currentPinchScale (fingers together < 1.0 -> +//! fingers apart > 1.0) +constexpr const int ACTION_GESTURE_ZOOM = 502; +constexpr const int ACTION_GESTURE_ROTATE = 503; +constexpr const int ACTION_GESTURE_PAN = 504; +constexpr const int ACTION_GESTURE_ABORT = 505; //!< gesture was interrupted in unspecified state + +constexpr const int ACTION_GESTURE_SWIPE_LEFT = 511; +constexpr const int ACTION_GESTURE_SWIPE_LEFT_TEN = 520; +constexpr const int ACTION_GESTURE_SWIPE_RIGHT = 521; +constexpr const int ACTION_GESTURE_SWIPE_RIGHT_TEN = 530; +constexpr const int ACTION_GESTURE_SWIPE_UP = 531; +constexpr const int ACTION_GESTURE_SWIPE_UP_TEN = 540; +constexpr const int ACTION_GESTURE_SWIPE_DOWN = 541; +constexpr const int ACTION_GESTURE_SWIPE_DOWN_TEN = 550; + +//! 5xx is reserved for additional gesture actions +constexpr const int ACTION_GESTURE_END = 599; + +/*! + * @brief Other, non-gesture actions + */ +///@{ + +//!< analog thumbstick move, horizontal axis, left; see ACTION_ANALOG_MOVE +constexpr const int ACTION_ANALOG_MOVE_X_LEFT = 601; + +//!< analog thumbstick move, horizontal axis, right; see ACTION_ANALOG_MOVE +constexpr const int ACTION_ANALOG_MOVE_X_RIGHT = 602; + +//!< analog thumbstick move, vertical axis, up; see ACTION_ANALOG_MOVE +constexpr const int ACTION_ANALOG_MOVE_Y_UP = 603; + +//!< analog thumbstick move, vertical axis, down; see ACTION_ANALOG_MOVE +constexpr const int ACTION_ANALOG_MOVE_Y_DOWN = 604; + +///@} + +// The NOOP action can be specified to disable an input event. This is +// useful in user keyboard.xml etc to disable actions specified in the +// system mappings. ERROR action is used to play an error sound +constexpr const int ACTION_ERROR = 998; +constexpr const int ACTION_NOOP = 999; diff --git a/xbmc/input/actions/ActionTranslator.cpp b/xbmc/input/actions/ActionTranslator.cpp new file mode 100644 index 0000000..51d531c --- /dev/null +++ b/xbmc/input/actions/ActionTranslator.cpp @@ -0,0 +1,311 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "ActionTranslator.h" + +#include "ActionIDs.h" +#include "interfaces/builtins/Builtins.h" +#include "utils/StringUtils.h" +#include "utils/log.h" + +#include <map> + +namespace +{ +using ActionName = std::string; +using ActionID = unsigned int; + +static const std::map<ActionName, ActionID> ActionMappings = { + {"left", ACTION_MOVE_LEFT}, + {"right", ACTION_MOVE_RIGHT}, + {"up", ACTION_MOVE_UP}, + {"down", ACTION_MOVE_DOWN}, + {"pageup", ACTION_PAGE_UP}, + {"pagedown", ACTION_PAGE_DOWN}, + {"select", ACTION_SELECT_ITEM}, + {"highlight", ACTION_HIGHLIGHT_ITEM}, + {"parentdir", ACTION_NAV_BACK}, // backward compatibility + {"parentfolder", ACTION_PARENT_DIR}, + {"back", ACTION_NAV_BACK}, + {"menu", ACTION_MENU}, + {"previousmenu", ACTION_PREVIOUS_MENU}, + {"info", ACTION_SHOW_INFO}, + {"pause", ACTION_PAUSE}, + {"stop", ACTION_STOP}, + {"skipnext", ACTION_NEXT_ITEM}, + {"skipprevious", ACTION_PREV_ITEM}, + {"fullscreen", ACTION_SHOW_GUI}, + {"aspectratio", ACTION_ASPECT_RATIO}, + {"stepforward", ACTION_STEP_FORWARD}, + {"stepback", ACTION_STEP_BACK}, + {"bigstepforward", ACTION_BIG_STEP_FORWARD}, + {"bigstepback", ACTION_BIG_STEP_BACK}, + {"chapterorbigstepforward", ACTION_CHAPTER_OR_BIG_STEP_FORWARD}, + {"chapterorbigstepback", ACTION_CHAPTER_OR_BIG_STEP_BACK}, + {"osd", ACTION_SHOW_OSD}, + {"showsubtitles", ACTION_SHOW_SUBTITLES}, + {"nextsubtitle", ACTION_NEXT_SUBTITLE}, + {"browsesubtitle", ACTION_BROWSE_SUBTITLE}, + {"cyclesubtitle", ACTION_CYCLE_SUBTITLE}, + {"playerdebug", ACTION_PLAYER_DEBUG}, + {"playerdebugvideo", ACTION_PLAYER_DEBUG_VIDEO}, + {"codecinfo", ACTION_PLAYER_PROCESS_INFO}, + {"playerprocessinfo", ACTION_PLAYER_PROCESS_INFO}, + {"playerprogramselect", ACTION_PLAYER_PROGRAM_SELECT}, + {"playerresolutionselect", ACTION_PLAYER_RESOLUTION_SELECT}, + {"nextpicture", ACTION_NEXT_PICTURE}, + {"previouspicture", ACTION_PREV_PICTURE}, + {"zoomout", ACTION_ZOOM_OUT}, + {"zoomin", ACTION_ZOOM_IN}, + {"playlist", ACTION_SHOW_PLAYLIST}, + {"queue", ACTION_QUEUE_ITEM}, + {"playnext", ACTION_QUEUE_ITEM_NEXT}, + {"zoomnormal", ACTION_ZOOM_LEVEL_NORMAL}, + {"zoomlevel1", ACTION_ZOOM_LEVEL_1}, + {"zoomlevel2", ACTION_ZOOM_LEVEL_2}, + {"zoomlevel3", ACTION_ZOOM_LEVEL_3}, + {"zoomlevel4", ACTION_ZOOM_LEVEL_4}, + {"zoomlevel5", ACTION_ZOOM_LEVEL_5}, + {"zoomlevel6", ACTION_ZOOM_LEVEL_6}, + {"zoomlevel7", ACTION_ZOOM_LEVEL_7}, + {"zoomlevel8", ACTION_ZOOM_LEVEL_8}, + {"zoomlevel9", ACTION_ZOOM_LEVEL_9}, + {"nextcalibration", ACTION_CALIBRATE_SWAP_ARROWS}, + {"resetcalibration", ACTION_CALIBRATE_RESET}, + {"analogmove", ACTION_ANALOG_MOVE}, + {"analogmovexleft", ACTION_ANALOG_MOVE_X_LEFT}, + {"analogmovexright", ACTION_ANALOG_MOVE_X_RIGHT}, + {"analogmoveyup", ACTION_ANALOG_MOVE_Y_UP}, + {"analogmoveydown", ACTION_ANALOG_MOVE_Y_DOWN}, + {"rotate", ACTION_ROTATE_PICTURE_CW}, + {"rotateccw", ACTION_ROTATE_PICTURE_CCW}, + {"close", ACTION_NAV_BACK}, // backwards compatibility + {"subtitledelayminus", ACTION_SUBTITLE_DELAY_MIN}, + {"subtitledelay", ACTION_SUBTITLE_DELAY}, + {"subtitledelayplus", ACTION_SUBTITLE_DELAY_PLUS}, + {"audiodelayminus", ACTION_AUDIO_DELAY_MIN}, + {"audiodelay", ACTION_AUDIO_DELAY}, + {"audiodelayplus", ACTION_AUDIO_DELAY_PLUS}, + {"subtitleshiftup", ACTION_SUBTITLE_VSHIFT_UP}, + {"subtitleshiftdown", ACTION_SUBTITLE_VSHIFT_DOWN}, + {"subtitlealign", ACTION_SUBTITLE_ALIGN}, + {"audionextlanguage", ACTION_AUDIO_NEXT_LANGUAGE}, + {"verticalshiftup", ACTION_VSHIFT_UP}, + {"verticalshiftdown", ACTION_VSHIFT_DOWN}, + {"nextresolution", ACTION_CHANGE_RESOLUTION}, + {"audiotoggledigital", ACTION_TOGGLE_DIGITAL_ANALOG}, + {"number0", REMOTE_0}, + {"number1", REMOTE_1}, + {"number2", REMOTE_2}, + {"number3", REMOTE_3}, + {"number4", REMOTE_4}, + {"number5", REMOTE_5}, + {"number6", REMOTE_6}, + {"number7", REMOTE_7}, + {"number8", REMOTE_8}, + {"number9", REMOTE_9}, + {"smallstepback", ACTION_SMALL_STEP_BACK}, + {"fastforward", ACTION_PLAYER_FORWARD}, + {"rewind", ACTION_PLAYER_REWIND}, + {"play", ACTION_PLAYER_PLAY}, + {"playpause", ACTION_PLAYER_PLAYPAUSE}, + {"switchplayer", ACTION_SWITCH_PLAYER}, + {"delete", ACTION_DELETE_ITEM}, + {"copy", ACTION_COPY_ITEM}, + {"move", ACTION_MOVE_ITEM}, + {"screenshot", ACTION_TAKE_SCREENSHOT}, + {"rename", ACTION_RENAME_ITEM}, + {"togglewatched", ACTION_TOGGLE_WATCHED}, + {"scanitem", ACTION_SCAN_ITEM}, + {"reloadkeymaps", ACTION_RELOAD_KEYMAPS}, + {"volumeup", ACTION_VOLUME_UP}, + {"volumedown", ACTION_VOLUME_DOWN}, + {"mute", ACTION_MUTE}, + {"backspace", ACTION_BACKSPACE}, + {"scrollup", ACTION_SCROLL_UP}, + {"scrolldown", ACTION_SCROLL_DOWN}, + {"analogfastforward", ACTION_ANALOG_FORWARD}, + {"analogrewind", ACTION_ANALOG_REWIND}, + {"moveitemup", ACTION_MOVE_ITEM_UP}, + {"moveitemdown", ACTION_MOVE_ITEM_DOWN}, + {"contextmenu", ACTION_CONTEXT_MENU}, + {"shift", ACTION_SHIFT}, + {"symbols", ACTION_SYMBOLS}, + {"cursorleft", ACTION_CURSOR_LEFT}, + {"cursorright", ACTION_CURSOR_RIGHT}, + {"showtime", ACTION_SHOW_OSD_TIME}, + {"analogseekforward", ACTION_ANALOG_SEEK_FORWARD}, + {"analogseekback", ACTION_ANALOG_SEEK_BACK}, + {"showpreset", ACTION_VIS_PRESET_SHOW}, + {"nextpreset", ACTION_VIS_PRESET_NEXT}, + {"previouspreset", ACTION_VIS_PRESET_PREV}, + {"lockpreset", ACTION_VIS_PRESET_LOCK}, + {"randompreset", ACTION_VIS_PRESET_RANDOM}, + {"increasevisrating", ACTION_VIS_RATE_PRESET_PLUS}, + {"decreasevisrating", ACTION_VIS_RATE_PRESET_MINUS}, + {"showvideomenu", ACTION_SHOW_VIDEOMENU}, + {"enter", ACTION_ENTER}, + {"increaserating", ACTION_INCREASE_RATING}, + {"decreaserating", ACTION_DECREASE_RATING}, + {"setrating", ACTION_SET_RATING}, + {"togglefullscreen", ACTION_TOGGLE_FULLSCREEN}, + {"nextscene", ACTION_NEXT_SCENE}, + {"previousscene", ACTION_PREV_SCENE}, + {"nextletter", ACTION_NEXT_LETTER}, + {"prevletter", ACTION_PREV_LETTER}, + {"jumpsms2", ACTION_JUMP_SMS2}, + {"jumpsms3", ACTION_JUMP_SMS3}, + {"jumpsms4", ACTION_JUMP_SMS4}, + {"jumpsms5", ACTION_JUMP_SMS5}, + {"jumpsms6", ACTION_JUMP_SMS6}, + {"jumpsms7", ACTION_JUMP_SMS7}, + {"jumpsms8", ACTION_JUMP_SMS8}, + {"jumpsms9", ACTION_JUMP_SMS9}, + {"filter", ACTION_FILTER}, + {"filterclear", ACTION_FILTER_CLEAR}, + {"filtersms2", ACTION_FILTER_SMS2}, + {"filtersms3", ACTION_FILTER_SMS3}, + {"filtersms4", ACTION_FILTER_SMS4}, + {"filtersms5", ACTION_FILTER_SMS5}, + {"filtersms6", ACTION_FILTER_SMS6}, + {"filtersms7", ACTION_FILTER_SMS7}, + {"filtersms8", ACTION_FILTER_SMS8}, + {"filtersms9", ACTION_FILTER_SMS9}, + {"firstpage", ACTION_FIRST_PAGE}, + {"lastpage", ACTION_LAST_PAGE}, + {"guiprofile", ACTION_GUIPROFILE_BEGIN}, + {"red", ACTION_TELETEXT_RED}, + {"green", ACTION_TELETEXT_GREEN}, + {"yellow", ACTION_TELETEXT_YELLOW}, + {"blue", ACTION_TELETEXT_BLUE}, + {"increasepar", ACTION_INCREASE_PAR}, + {"decreasepar", ACTION_DECREASE_PAR}, + {"volampup", ACTION_VOLAMP_UP}, + {"volampdown", ACTION_VOLAMP_DOWN}, + {"volumeamplification", ACTION_VOLAMP}, + {"createbookmark", ACTION_CREATE_BOOKMARK}, + {"createepisodebookmark", ACTION_CREATE_EPISODE_BOOKMARK}, + {"settingsreset", ACTION_SETTINGS_RESET}, + {"settingslevelchange", ACTION_SETTINGS_LEVEL_CHANGE}, + {"togglefont", ACTION_TOGGLE_FONT}, + {"videonextstream", ACTION_VIDEO_NEXT_STREAM}, + + // 3D movie playback/GUI + {"stereomode", ACTION_STEREOMODE_SELECT}, // cycle 3D modes, for now an alias for next + {"nextstereomode", ACTION_STEREOMODE_NEXT}, + {"previousstereomode", ACTION_STEREOMODE_PREVIOUS}, + {"togglestereomode", ACTION_STEREOMODE_TOGGLE}, + {"stereomodetomono", ACTION_STEREOMODE_TOMONO}, + + // HDR display support + {"hdrtoggle", ACTION_HDR_TOGGLE}, + + // Tone mapping + {"cycletonemapmethod", ACTION_CYCLE_TONEMAP_METHOD}, + + // PVR actions + {"channelup", ACTION_CHANNEL_UP}, + {"channeldown", ACTION_CHANNEL_DOWN}, + {"previouschannelgroup", ACTION_PREVIOUS_CHANNELGROUP}, + {"nextchannelgroup", ACTION_NEXT_CHANNELGROUP}, + {"playpvr", ACTION_PVR_PLAY}, + {"playpvrtv", ACTION_PVR_PLAY_TV}, + {"playpvrradio", ACTION_PVR_PLAY_RADIO}, + {"record", ACTION_RECORD}, + {"togglecommskip", ACTION_TOGGLE_COMMSKIP}, + {"showtimerrule", ACTION_PVR_SHOW_TIMER_RULE}, + {"channelnumberseparator", ACTION_CHANNEL_NUMBER_SEP}, + + // Mouse actions + {"leftclick", ACTION_MOUSE_LEFT_CLICK}, + {"rightclick", ACTION_MOUSE_RIGHT_CLICK}, + {"middleclick", ACTION_MOUSE_MIDDLE_CLICK}, + {"doubleclick", ACTION_MOUSE_DOUBLE_CLICK}, + {"longclick", ACTION_MOUSE_LONG_CLICK}, + {"wheelup", ACTION_MOUSE_WHEEL_UP}, + {"wheeldown", ACTION_MOUSE_WHEEL_DOWN}, + {"mousedrag", ACTION_MOUSE_DRAG}, + {"mousedragend", ACTION_MOUSE_DRAG_END}, + {"mousemove", ACTION_MOUSE_MOVE}, + + // Touch + {"tap", ACTION_TOUCH_TAP}, + {"longpress", ACTION_TOUCH_LONGPRESS}, + {"pangesture", ACTION_GESTURE_PAN}, + {"zoomgesture", ACTION_GESTURE_ZOOM}, + {"rotategesture", ACTION_GESTURE_ROTATE}, + {"swipeleft", ACTION_GESTURE_SWIPE_LEFT}, + {"swiperight", ACTION_GESTURE_SWIPE_RIGHT}, + {"swipeup", ACTION_GESTURE_SWIPE_UP}, + {"swipedown", ACTION_GESTURE_SWIPE_DOWN}, + + // Voice + {"voicerecognizer", ACTION_VOICE_RECOGNIZE}, + + // Do nothing / error action + {"error", ACTION_ERROR}, + {"noop", ACTION_NOOP}}; +} // namespace + +void CActionTranslator::GetActions(std::vector<std::string>& actionList) +{ + actionList.reserve(ActionMappings.size()); + for (auto& actionMapping : ActionMappings) + actionList.push_back(actionMapping.first); +} + +bool CActionTranslator::IsAnalog(unsigned int actionID) +{ + switch (actionID) + { + case ACTION_ANALOG_SEEK_FORWARD: + case ACTION_ANALOG_SEEK_BACK: + case ACTION_SCROLL_UP: + case ACTION_SCROLL_DOWN: + case ACTION_ANALOG_FORWARD: + case ACTION_ANALOG_REWIND: + case ACTION_ANALOG_MOVE: + case ACTION_ANALOG_MOVE_X_LEFT: + case ACTION_ANALOG_MOVE_X_RIGHT: + case ACTION_ANALOG_MOVE_Y_UP: + case ACTION_ANALOG_MOVE_Y_DOWN: + case ACTION_CURSOR_LEFT: + case ACTION_CURSOR_RIGHT: + case ACTION_VOLUME_UP: + case ACTION_VOLUME_DOWN: + case ACTION_ZOOM_IN: + case ACTION_ZOOM_OUT: + return true; + default: + return false; + } +} + +bool CActionTranslator::TranslateString(std::string strAction, unsigned int& actionId) +{ + actionId = ACTION_NONE; + + if (strAction.empty()) + return false; + + StringUtils::ToLower(strAction); + + auto it = ActionMappings.find(strAction); + if (it != ActionMappings.end()) + actionId = it->second; + else if (CBuiltins::GetInstance().HasCommand(strAction)) + actionId = ACTION_BUILT_IN_FUNCTION; + + if (actionId == ACTION_NONE) + { + CLog::Log(LOGERROR, "Keymapping error: no such action '{}' defined", strAction); + return false; + } + + return true; +} diff --git a/xbmc/input/actions/ActionTranslator.h b/xbmc/input/actions/ActionTranslator.h new file mode 100644 index 0000000..91c146a --- /dev/null +++ b/xbmc/input/actions/ActionTranslator.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2017-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include <string> +#include <vector> + +class CActionTranslator +{ +public: + static void GetActions(std::vector<std::string>& actionList); + static bool IsAnalog(unsigned int actionId); + static bool TranslateString(std::string strAction, unsigned int& actionId); +}; diff --git a/xbmc/input/actions/CMakeLists.txt b/xbmc/input/actions/CMakeLists.txt new file mode 100644 index 0000000..a7a4d87 --- /dev/null +++ b/xbmc/input/actions/CMakeLists.txt @@ -0,0 +1,10 @@ +set(SOURCES Action.cpp + ActionTranslator.cpp +) + +set(HEADERS Action.h + ActionIDs.h + ActionTranslator.h +) + +core_add_library(input_actions) |