buf fixed
This commit is contained in:
+11
-9
@@ -16,8 +16,8 @@ public:
|
||||
Invalid
|
||||
};
|
||||
|
||||
Event() : type(Type::Invalid), code(0u) {}
|
||||
Event(Type typ, unsigned char cod) : type(typ), code(cod) {}
|
||||
Event() : type(Type::Invalid), code(0) {}
|
||||
Event(Type typ, int cod) : type(typ), code(cod) {}
|
||||
bool IsPress() const noexcept {
|
||||
return type == Type::Press;
|
||||
};
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
return type != Type::Invalid;
|
||||
};
|
||||
|
||||
unsigned char GetCode() const noexcept {
|
||||
int GetCode() const noexcept {
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
}
|
||||
private:
|
||||
Type type;
|
||||
unsigned char code;
|
||||
int code;
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -45,8 +45,8 @@ public:
|
||||
~Keyboard() = default;
|
||||
Keyboard(const Keyboard&) = delete;
|
||||
|
||||
bool IsKeyDown(const unsigned char key) const noexcept {
|
||||
return keys[key];
|
||||
bool IsKeyDown(const int key) const noexcept {
|
||||
return key >= 0 && key < (int)numerodekeys && keys[key];
|
||||
}
|
||||
|
||||
bool IsKeyEmpty() const noexcept {
|
||||
@@ -92,12 +92,14 @@ public:
|
||||
TrimBuffer(charbuffer);
|
||||
}
|
||||
|
||||
void KeyDown(const unsigned char key) noexcept {
|
||||
void KeyDown(const int key) noexcept {
|
||||
if (key < 0 || key >= (int)numerodekeys) return; // GLFW_KEY_UNKNOWN etc.
|
||||
keybuffer.push(Event(Event::Type::Press, key));
|
||||
keys[key] = true;
|
||||
TrimBuffer(keybuffer);
|
||||
}
|
||||
void KeyUp(const unsigned char key) noexcept {
|
||||
void KeyUp(const int key) noexcept {
|
||||
if (key < 0 || key >= (int)numerodekeys) return;
|
||||
keybuffer.push(Event(Event::Type::Release, key));
|
||||
keys[key] = false;
|
||||
TrimBuffer(keybuffer);
|
||||
@@ -129,7 +131,7 @@ private:
|
||||
}
|
||||
|
||||
bool AutorepeatEnabled = false;
|
||||
static constexpr unsigned int numerodekeys = 256u;
|
||||
static constexpr unsigned int numerodekeys = 512u; // GLFW key codes go up to ~348
|
||||
static constexpr unsigned int bufferSize = 16u;
|
||||
std::bitset<numerodekeys> keys;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user