From 3fdbdbdce406ee9f5ecddb15cf1b8897898c4b61 Mon Sep 17 00:00:00 2001 From: kdx Date: Mon, 17 Jul 2023 07:45:44 +0200 Subject: make input states private --- src/FLD.hpp | 9 +++------ 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; - using MouseStateArray = std::array; - using JoyStateArray = std::array; 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 images = {}; + std::array keystates = {}; + std::array mousestates = {}; + std::array 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 */ -- cgit v1.2.3