mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-13 17:50:17 +01:00
Add cleanup of input handlers when shutting down; Remove C++11ism.
This commit is contained in:
parent
91e2918f50
commit
6e06a9ac52
@ -5,6 +5,7 @@
|
||||
class InputHandler
|
||||
{
|
||||
public:
|
||||
virtual ~InputHandler() {};
|
||||
virtual bool update(SDL_Event &e) = 0;
|
||||
virtual bool pressed() = 0;
|
||||
virtual void reset() = 0;
|
||||
|
||||
@ -36,6 +36,14 @@ UserInput::UserInput(Configuration &c)
|
||||
|
||||
UserInput::~UserInput()
|
||||
{
|
||||
for (unsigned int i = 0; i < keyHandlers_.size(); ++i)
|
||||
{
|
||||
if (keyHandlers_[i].first)
|
||||
{
|
||||
delete keyHandlers_[i].first;
|
||||
}
|
||||
}
|
||||
|
||||
// This code causes an exception when a controller is attached; it's disabled to prevent crashes on exit.
|
||||
// for(std::vector<SDL_Joystick *>::iterator it = joysticks_.begin(); it != joysticks_.end(); it++)
|
||||
// {
|
||||
|
||||
@ -64,7 +64,7 @@ private:
|
||||
bool MapKey(std::string keyDescription, KeyCode_E key, bool required);
|
||||
Configuration &config_;
|
||||
std::vector<SDL_Joystick *> joysticks_;
|
||||
std::vector<std::pair<InputHandler *, KeyCode_E>> keyHandlers_;
|
||||
std::vector<std::pair<InputHandler *, KeyCode_E> > keyHandlers_;
|
||||
bool lastKeyState_[KeyCodeMax];
|
||||
bool currentKeyState_[KeyCodeMax];
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user