mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 14:31:50 +00:00
bindings, controls.json file
This commit is contained in:
parent
e3743b8463
commit
9051db3526
11 changed files with 186 additions and 22 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue