xbmc
Action.h
1 /*
2  * Copyright (C) 2005-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 <string>
12 
13 #ifndef SWIG
14 
15 class CKey;
16 
22 class CAction
23 {
24 public:
25  CAction();
26  CAction(int actionID,
27  float amount1 = 1.0f,
28  float amount2 = 0.0f,
29  const std::string& name = "",
30  unsigned int holdTime = 0);
31  CAction(int actionID, wchar_t unicode);
32  CAction(int actionID,
33  unsigned int state,
34  float posX,
35  float posY,
36  float offsetX,
37  float offsetY,
38  float velocityX = 0.0f,
39  float velocityY = 0.0f,
40  const std::string& name = "");
41  CAction(int actionID, const std::string& name, const CKey& key);
42  CAction(int actionID, const std::string& name);
43 
44  CAction(const CAction& other) { *this = other; }
45  CAction& operator=(const CAction& rhs);
46 
50  int GetID() const { return m_id; }
51 
55  bool IsMouse() const;
56 
57  bool IsGesture() const;
58 
62  const std::string& GetName() const { return m_name; }
63 
67  const std::string& GetText() const { return m_text; }
68 
72  void SetText(const std::string& text) { m_text = text; }
73 
78  float GetAmount(unsigned int index = 0) const
79  {
80  return (index < max_amounts) ? m_amount[index] : 0;
81  };
82 
85  void ClearAmount();
86 
90  wchar_t GetUnicode() const { return m_unicode; }
91 
95  unsigned int GetHoldTime() const { return m_holdTime; }
96 
100  float GetRepeat() const { return m_repeat; }
101 
105  unsigned int GetButtonCode() const { return m_buttonCode; }
106 
107  bool IsAnalog() const;
108 
109 private:
110  int m_id;
111  std::string m_name;
112 
113  static const unsigned int max_amounts = 6; // Must be at least 6
114  float m_amount[max_amounts] = {};
115 
116  float m_repeat = 0.0f;
117  unsigned int m_holdTime = 0;
118  unsigned int m_buttonCode = 0;
119  wchar_t m_unicode = 0;
120  std::string m_text;
121 };
122 
123 #endif
float GetRepeat() const
Time since last repeat in ms.
Definition: Action.h:100
void ClearAmount()
Reset all amount values to zero.
Definition: Action.cpp:135
int GetID() const
Identifier of the action.
Definition: Action.h:50
class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:22
unsigned int GetHoldTime() const
Time in ms that the key has been held.
Definition: Action.h:95
unsigned int GetButtonCode() const
Button code that triggered this action.
Definition: Action.h:105
void SetText(const std::string &text)
Set the text payload of the action.
Definition: Action.h:72
wchar_t GetUnicode() const
Unicode value associated with this action.
Definition: Action.h:90
float GetAmount(unsigned int index=0) const
Get an amount associated with this action.
Definition: Action.h:78
bool IsMouse() const
Is this an action from the mouse.
Definition: Action.cpp:141
Definition: Key.h:135
const std::string & GetText() const
Text of the action if any.
Definition: Action.h:67
const std::string & GetName() const
Human-readable name of the action.
Definition: Action.h:62