-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyboardInput.cpp
More file actions
41 lines (41 loc) · 859 Bytes
/
KeyboardInput.cpp
File metadata and controls
41 lines (41 loc) · 859 Bytes
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
#include <Windows.h>
#include <iostream>
#include <vector>
bool IsKeyDown(int key)
{
return GetAsyncKeyState(key) & 0x8000;
}
bool CheckToggleKeys(int key)
{
int evaluateKey = GetAsyncKeyState(key) & 0x0001;
if(evaluateKey) return true;
else return false;
}
bool MultiKeysPressed(std::initializer_list<int> keys)
{
for (int key : keys)
{
if (!IsKeyDown(key))
{
return false;
}
}
return true;
}
int WhichKeyUniversal(){
for (int key = 0x01; key <= 0xFE; ++key) {
if (IsKeyDown(key)) {
return key;
}
}
return 0;
}
std::vector<int> WhichKeyUniversalMultiple(){
std::vector<int> MultiKeys;
for (int key = 0x01; key <= 0xFE; ++key) {
if (IsKeyDown(key)) {
MultiKeys.push_back(key);
}
}
return MultiKeys;
}