#ifndef INPUT_H_0FB34C42 #define INPUT_H_0FB34C42 #include #include /** * Helper class that detects when a key is newly pressed. */ class Input { public: Input() { const Uint8* s = SDL_GetKeyboardState(&length_); curstate_.assign(s, s + length_); prevstate_ = curstate_; } void tick(const Uint8* keystate) { prevstate_ = std::move(curstate_); curstate_.assign(keystate, keystate + length_); } bool wasPressed(int scancode) const { return curstate_.at(scancode) && !prevstate_.at(scancode); } private: int length_; std::vector curstate_; std::vector prevstate_; }; #endif /* end of include guard: INPUT_H_0FB34C42 */