-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.h
77 lines (62 loc) · 1.72 KB
/
action.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef ACTION_H
#define ACTION_H
#include <QObject>
#include <QHash>
#include <QPair>
class Action : public QObject
{
Q_OBJECT
public:
enum class ControllerButtonAction
{
MouseLeftClick, MouseRightClick,
Left, Right, Up, Down, Backspace, Enter,
KeyboardActivate, KeyboardEnterKey,
MediaPlayPause,
};
enum class ControllerAnalogAction
{
MouseMove, MouseWheel,
KeyboardScroll,
};
enum class ControllerComboAction
{
EnableDisableApp
};
enum class ControllerButton
{
None,
Up, Down, Left, Right, Start, Back, LT, RT, LB, RB, LS, RS, A, B, X, Y
};
enum class ControllerAnalog
{
None,
Left, Right
};
protected:
QHash<ControllerButtonAction, ControllerButton> m_buttonActionHash;
QHash<ControllerAnalogAction, ControllerAnalog> m_analogActionHash;
QHash<ControllerComboAction, QPair<ControllerButton, ControllerButton>*> m_comboActionHash;
private:
explicit Action(QObject *parent = nullptr);
public:
static Action* instance();
ControllerButton find(ControllerButtonAction action);
ControllerAnalog find(ControllerAnalogAction action);
const QPair<ControllerButton, ControllerButton> *find(ControllerComboAction action);
static quint32 getXInputButton(ControllerButton b);
signals:
};
inline uint qHash(Action::ControllerButtonAction key, uint seed)
{
return ::qHash(static_cast<uint>(key), seed);
}
inline uint qHash(Action::ControllerAnalogAction key, uint seed)
{
return ::qHash(static_cast<uint>(key), seed);
}
inline uint qHash(Action::ControllerComboAction key, uint seed)
{
return ::qHash(static_cast<uint>(key), seed);
}
#endif // ACTION_H