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