mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-26 21:13:51 +00:00
Initial commit: wowee native WoW 3.3.5a client
This commit is contained in:
commit
ce6cb8f38e
147 changed files with 32347 additions and 0 deletions
57
include/core/input.hpp
Normal file
57
include/core/input.hpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <array>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace wowee {
|
||||
namespace core {
|
||||
|
||||
class Input {
|
||||
public:
|
||||
static Input& getInstance();
|
||||
|
||||
void update();
|
||||
void handleEvent(const SDL_Event& event);
|
||||
|
||||
// Keyboard
|
||||
bool isKeyPressed(SDL_Scancode key) const;
|
||||
bool isKeyJustPressed(SDL_Scancode key) const;
|
||||
bool isKeyJustReleased(SDL_Scancode key) const;
|
||||
|
||||
// Mouse
|
||||
bool isMouseButtonPressed(int button) const;
|
||||
bool isMouseButtonJustPressed(int button) const;
|
||||
bool isMouseButtonJustReleased(int button) const;
|
||||
|
||||
glm::vec2 getMousePosition() const { return mousePosition; }
|
||||
glm::vec2 getMouseDelta() const { return mouseDelta; }
|
||||
float getMouseWheelDelta() const { return mouseWheelDelta; }
|
||||
|
||||
bool isMouseLocked() const { return mouseLocked; }
|
||||
void setMouseLocked(bool locked);
|
||||
|
||||
private:
|
||||
Input() = default;
|
||||
~Input() = default;
|
||||
Input(const Input&) = delete;
|
||||
Input& operator=(const Input&) = delete;
|
||||
|
||||
static constexpr int NUM_KEYS = SDL_NUM_SCANCODES;
|
||||
static constexpr int NUM_MOUSE_BUTTONS = 8;
|
||||
|
||||
std::array<bool, NUM_KEYS> currentKeyState = {};
|
||||
std::array<bool, NUM_KEYS> previousKeyState = {};
|
||||
|
||||
std::array<bool, NUM_MOUSE_BUTTONS> currentMouseState = {};
|
||||
std::array<bool, NUM_MOUSE_BUTTONS> previousMouseState = {};
|
||||
|
||||
glm::vec2 mousePosition = glm::vec2(0.0f);
|
||||
glm::vec2 previousMousePosition = glm::vec2(0.0f);
|
||||
glm::vec2 mouseDelta = glm::vec2(0.0f);
|
||||
float mouseWheelDelta = 0.0f;
|
||||
bool mouseLocked = false;
|
||||
};
|
||||
|
||||
} // namespace core
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue