dasdas
This commit is contained in:
parent
69a17c25ea
commit
95c713bc4d
@ -4,11 +4,8 @@
|
|||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
const short KEYS_BUFFER_SIZE = 1032;
|
bool Events::_keys[KEYS_BUFFER_SIZE] = {};
|
||||||
const short _MOUSE_KEYS_OFFSET = 1024;
|
uint Events::_frames[KEYS_BUFFER_SIZE] = {};
|
||||||
|
|
||||||
bool* Events::_keys;
|
|
||||||
uint* Events::_frames;
|
|
||||||
uint Events::_current = 0;
|
uint Events::_current = 0;
|
||||||
float Events::deltaX = 0.0f;
|
float Events::deltaX = 0.0f;
|
||||||
float Events::deltaY = 0.0f;
|
float Events::deltaY = 0.0f;
|
||||||
@ -21,21 +18,6 @@ std::vector<uint> Events::codepoints;
|
|||||||
std::vector<int> Events::pressedKeys;
|
std::vector<int> Events::pressedKeys;
|
||||||
std::unordered_map<std::string, Binding> Events::bindings;
|
std::unordered_map<std::string, Binding> Events::bindings;
|
||||||
|
|
||||||
int Events::initialize(){
|
|
||||||
_keys = new bool[KEYS_BUFFER_SIZE];
|
|
||||||
_frames = new uint[KEYS_BUFFER_SIZE];
|
|
||||||
|
|
||||||
memset(_keys, false, KEYS_BUFFER_SIZE*sizeof(bool));
|
|
||||||
memset(_frames, 0, KEYS_BUFFER_SIZE*sizeof(uint));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Events::finalize(){
|
|
||||||
delete[] _keys;
|
|
||||||
delete[] _frames;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns bool repr. of key state
|
// Returns bool repr. of key state
|
||||||
bool Events::pressed(int keycode){
|
bool Events::pressed(int keycode){
|
||||||
if (keycode < 0 || keycode >= KEYS_BUFFER_SIZE){
|
if (keycode < 0 || keycode >= KEYS_BUFFER_SIZE){
|
||||||
|
|||||||
@ -10,13 +10,13 @@
|
|||||||
|
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
|
|
||||||
extern const short KEYS_BUFFER_SIZE;
|
const short KEYS_BUFFER_SIZE = 1032;
|
||||||
extern const short _MOUSE_KEYS_OFFSET;
|
const short _MOUSE_KEYS_OFFSET = 1024;
|
||||||
|
|
||||||
class Events {
|
class Events {
|
||||||
public:
|
public:
|
||||||
static bool* _keys;
|
static bool _keys[KEYS_BUFFER_SIZE];
|
||||||
static uint* _frames;
|
static uint _frames[KEYS_BUFFER_SIZE];
|
||||||
static uint _current;
|
static uint _current;
|
||||||
static float deltaX;
|
static float deltaX;
|
||||||
static float deltaY;
|
static float deltaY;
|
||||||
@ -29,8 +29,6 @@ public:
|
|||||||
static std::vector<int> pressedKeys;
|
static std::vector<int> pressedKeys;
|
||||||
static std::unordered_map<std::string, Binding> bindings;
|
static std::unordered_map<std::string, Binding> bindings;
|
||||||
|
|
||||||
static int initialize();
|
|
||||||
static void finalize();
|
|
||||||
static void pollEvents();
|
static void pollEvents();
|
||||||
|
|
||||||
static bool pressed(int keycode);
|
static bool pressed(int keycode);
|
||||||
|
|||||||
@ -163,7 +163,6 @@ int Window::initialize(DisplaySettings& settings){
|
|||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
Events::initialize();
|
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
glfwSetMouseButtonCallback(window, mouse_button_callback);
|
glfwSetMouseButtonCallback(window, mouse_button_callback);
|
||||||
glfwSetCursorPosCallback(window, cursor_position_callback);
|
glfwSetCursorPosCallback(window, cursor_position_callback);
|
||||||
@ -255,7 +254,6 @@ void Window::popScissor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Window::terminate(){
|
void Window::terminate(){
|
||||||
Events::finalize();
|
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user