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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
#pragma once
#include "StarInputEvent.hpp"
#include "StarSet.hpp"
#include "StarJson.hpp"
namespace Star {
enum class InterfaceAction {
None,
PlayerUp,
PlayerDown,
PlayerLeft,
PlayerRight,
PlayerJump,
PlayerMainItem,
PlayerAltItem,
PlayerDropItem,
PlayerInteract,
PlayerShifting,
PlayerTechAction1,
PlayerTechAction2,
PlayerTechAction3,
EmoteBlabbering,
EmoteShouting,
EmoteHappy,
EmoteSad,
EmoteNeutral,
EmoteLaugh,
EmoteAnnoyed,
EmoteOh,
EmoteOooh,
EmoteBlink,
EmoteWink,
EmoteEat,
EmoteSleep,
ShowLabels,
CameraShift,
TitleBack,
CinematicSkip,
CinematicNext,
GuiClose,
GuiShifting,
KeybindingClear,
KeybindingCancel,
ChatPageUp,
ChatPageDown,
ChatPreviousLine,
ChatNextLine,
ChatSendLine,
ChatBegin,
ChatBeginCommand,
ChatStop,
InterfaceShowHelp,
InterfaceHideHud,
InterfaceChangeBarGroup,
InterfaceDeselectHands,
InterfaceBar1,
InterfaceBar2,
InterfaceBar3,
InterfaceBar4,
InterfaceBar5,
InterfaceBar6,
InterfaceBar7,
InterfaceBar8,
InterfaceBar9,
InterfaceBar10,
EssentialBar1,
EssentialBar2,
EssentialBar3,
EssentialBar4,
InterfaceRepeatCommand,
InterfaceToggleFullscreen,
InterfaceReload,
InterfaceEscapeMenu,
InterfaceInventory,
InterfaceCodex,
InterfaceQuest,
InterfaceCrafting,
};
extern EnumMap<InterfaceAction> const InterfaceActionNames;
// Maps the mod keys that can used in key chords to its associated KeyMod.
extern HashMap<Key, KeyMod> const KeyChordMods;
struct KeyChord {
Key key;
KeyMod mods;
bool operator<(KeyChord const& rhs) const;
};
KeyChord inputDescriptorFromJson(Json const& json);
Json inputDescriptorToJson(KeyChord const& chord);
String printInputDescriptor(KeyChord chord);
STAR_CLASS(KeyBindings);
class KeyBindings {
public:
KeyBindings();
explicit KeyBindings(Json const& json);
Set<InterfaceAction> actions(Key key) const;
Set<InterfaceAction> actions(InputEvent const& event) const;
Set<InterfaceAction> actions(KeyChord chord) const;
Set<InterfaceAction> actionsForKey(Key key) const;
private:
// Maps the primary key to a list of InterfaceActions, and any mods that they
// require to be held.
Map<Key, List<pair<KeyMod, InterfaceAction>>> m_actions;
};
}
|