diff options
author | kdx <kikoodx@paranoici.org> | 2023-07-17 07:45:44 +0200 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-07-17 07:45:44 +0200 |
commit | 3fdbdbdce406ee9f5ecddb15cf1b8897898c4b61 (patch) | |
tree | 274df8b692ebe32357f380d3eede1a9c67a686e3 | |
parent | c3761f14bb5f9dca54e36435cbab6ce7b43c8612 (diff) | |
download | fld-3fdbdbdce406ee9f5ecddb15cf1b8897898c4b61.tar.gz |
make input states private
-rw-r--r-- | src/FLD.hpp | 9 | ||||
-rw-r--r-- | src/cycleEvents.cpp | 14 |
2 files changed, 10 insertions, 13 deletions
diff --git a/src/FLD.hpp b/src/FLD.hpp index ecc88a8..9d4e879 100644 --- a/src/FLD.hpp +++ b/src/FLD.hpp @@ -21,9 +21,6 @@ public: Release, Press }; - using InputStateArray = std::array<InputState, SDL_NUM_SCANCODES>; - using MouseStateArray = std::array<InputState, 256>; - using JoyStateArray = std::array<InputState, SDL_CONTROLLER_BUTTON_MAX>; struct Config { int width = 640; int height = 480; @@ -96,9 +93,6 @@ public: READONLY(SDL_Texture *, target, nullptr); READONLY(unsigned long, tick, 0); READONLY(Color, drawColor, Color({0, 0, 0, 1})); - READONLY(InputStateArray, keystates, {}); - READONLY(MouseStateArray, mousestates, {}); - READONLY(JoyStateArray, joystates, {}); public: FLD(const Config& config); FLD(const Config&& config); @@ -148,6 +142,9 @@ private: int off_y = 0; } transform; std::map<const std::string, Image> images = {}; + std::array<InputState, SDL_NUM_SCANCODES> keystates = {}; + std::array<InputState, 256> mousestates = {}; + std::array<InputState, SDL_CONTROLLER_BUTTON_MAX> joystates = {}; Error sdlError(const std::string& msg="") const; Error soloudError(SoLoud::result result) const; diff --git a/src/cycleEvents.cpp b/src/cycleEvents.cpp index 5e15602..ea86359 100644 --- a/src/cycleEvents.cpp +++ b/src/cycleEvents.cpp @@ -20,11 +20,11 @@ next_state(FLD::InputState *state) void FLD::cycleEvents() { - for (auto& e : _keystates) + for (auto& e : keystates) next_state(&e); - for (auto& e : _mousestates) + for (auto& e : mousestates) next_state(&e); - for (auto& e : _joystates) + for (auto& e : joystates) next_state(&e); SDL_Event e; @@ -32,16 +32,16 @@ FLD::cycleEvents() case SDL_KEYDOWN: if (e.key.repeat) break; - _keystates[e.key.keysym.scancode] = InputState::Press; + keystates[e.key.keysym.scancode] = InputState::Press; break; case SDL_KEYUP: - _keystates[e.key.keysym.scancode] = InputState::Release; + keystates[e.key.keysym.scancode] = InputState::Release; break; case SDL_MOUSEBUTTONDOWN: - _mousestates[e.button.button] = InputState::Press; + mousestates[e.button.button] = InputState::Press; break; case SDL_MOUSEBUTTONUP: - _mousestates[e.button.button] = InputState::Release; + mousestates[e.button.button] = InputState::Release; break; case SDL_JOYDEVICEADDED: /* TODO */ |