kodi
TouchTranslator.h
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 #pragma once
10 
11 #include "input/keymaps/interfaces/IKeyMapper.h"
12 
13 #include <map>
14 #include <string>
15 
16 namespace tinyxml2
17 {
18 class XMLElement;
19 class XMLNode;
20 } // namespace tinyxml2
21 
22 namespace KODI
23 {
24 namespace KEYMAP
25 {
30 {
31 public:
32  CTouchTranslator() = default;
33 
34  // implementation of IKeyMapper
35  void MapActions(int windowID, const tinyxml2::XMLNode* bDevice) override;
36  void Clear() override;
37 
38  bool TranslateTouchAction(
39  int window, int touchAction, int touchPointers, int& action, std::string& actionString);
40 
41 private:
42  bool TranslateAction(int window,
43  unsigned int touchCommand,
44  int touchPointers,
45  unsigned int& actionId,
46  std::string& actionString);
47 
48  struct CTouchAction
49  {
50  unsigned int actionId;
51  std::string strAction; // Needed for "ActivateWindow()" type actions
52  };
53 
54  using TouchActionKey = unsigned int;
55  using TouchActionMap = std::map<TouchActionKey, CTouchAction>;
56 
57  using WindowID = int;
58  using TouchMap = std::map<WindowID, TouchActionMap>;
59 
60  unsigned int GetActionID(WindowID window,
61  TouchActionKey touchActionKey,
62  std::string& actionString);
63 
64  static unsigned int TranslateTouchCommand(const tinyxml2::XMLElement* pButton,
65  CTouchAction& action);
66 
67  static unsigned int GetTouchActionKey(unsigned int touchCommandId, int touchPointers);
68 
69  TouchMap m_touchMap;
70 };
71 } // namespace KEYMAP
72 } // namespace KODI
Definition: TouchTranslator.h:29
Definition: SkinTimerManager.h:18
Interface for classes that can map buttons to Kodi actions.
Definition: IKeyMapper.h:25
Definition: AudioDecoder.h:18