-
Notifications
You must be signed in to change notification settings - Fork 11
/
key.h
40 lines (30 loc) · 890 Bytes
/
key.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
//---------------------------------------------------------------------------
#pragma once
#include "key_code.h"
#if RUN_TESTS
#include <vector>
#endif
//---------------------------------------------------------------------------
class Key {
public:
static void Press(KeyCode key);
static void Release(KeyCode key);
static void Tap(KeyCode key) {
Press(key);
Release(key);
}
static void Flush();
static void EnableHistory() { historyEnabled = true; }
static void DisableHistory() { historyEnabled = false; }
static bool historyEnabled;
#if RUN_TESTS
struct HistoryEntry {
HistoryEntry() = default;
HistoryEntry(KeyCode code, bool isPress) : code(code), isPress(isPress) {}
KeyCode code;
bool isPress;
};
static std::vector<HistoryEntry> history;
#endif
};
//---------------------------------------------------------------------------