-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathkeybinding_map.h
41 lines (34 loc) · 1.05 KB
/
keybinding_map.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
#pragma once
#include "sdl.h"
#include "keybinding.h"
#include "file_path.h"
#include "color.h"
#include "steam_input.h"
class FilePath;
class GuiFactory;
class TString;
class KeybindingMap {
public:
KeybindingMap(const FilePath& defaults, const FilePath& user);
bool matches(Keybinding, SDL::SDL_Keysym);
static TString getText(SDL::SDL_Keysym, string delimiter = " + ");
static optional<ControllerKey> getControllerMapping(Keybinding);
static optional<SDL::SDL_Keycode> getBuiltinMapping(Keybinding);
SGuiElem getGlyph(SGuiElem label, GuiFactory*, Keybinding);
SGuiElem getGlyph(SGuiElem label, GuiFactory*, optional<ControllerKey>, optional<TString> alternative);
optional<TString> getText(Keybinding);
bool set(Keybinding, SDL::SDL_Keysym);
void reset();
private:
using KeyMap = HashMap<Keybinding, SDL::SDL_Keysym>;
KeyMap bindings;
KeyMap defaults;
FilePath defaultsPath;
FilePath userPath;
void save();
};
namespace SDL {
struct SDL_Keysym;
}
class PrettyInputArchive;
void serialize(PrettyInputArchive&, SDL::SDL_Keysym&);