bindings, controls.json file

This commit is contained in:
MihailRis
2023-11-19 22:37:15 +03:00
parent e3743b8463
commit 9051db3526
11 changed files with 186 additions and 22 deletions
+29
View File
@@ -3,8 +3,32 @@
#include "Window.h"
#include <string>
#include <vector>
#include <unordered_map>
typedef unsigned int uint;
enum class inputtype {
keyboard,
button,
};
struct Binding {
inputtype type;
int code;
bool state = false;
bool justChange = false;
bool active() const {
return state;
}
bool jactive() const {
return state && justChange;
}
};
class Events {
public:
static bool* _keys;
@@ -18,6 +42,7 @@ public:
static bool _cursor_started;
static std::vector<uint> codepoints;
static std::vector<int> pressedKeys;
static std::unordered_map<std::string, Binding> bindings;
static int initialize();
static void finalize();
@@ -30,6 +55,10 @@ public:
static bool jclicked(int button);
static void toggleCursor();
static void bind(std::string name, inputtype type, int code);
static bool active(std::string name);
static bool jactive(std::string name);
};
#define _MOUSE_BUTTONS 1024