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