mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-05-01 02:19:29 +02:00
Add cleanup of input handlers when shutting down; Remove C++11ism.
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
class InputHandler
|
class InputHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~InputHandler() {};
|
||||||
virtual bool update(SDL_Event &e) = 0;
|
virtual bool update(SDL_Event &e) = 0;
|
||||||
virtual bool pressed() = 0;
|
virtual bool pressed() = 0;
|
||||||
virtual void reset() = 0;
|
virtual void reset() = 0;
|
||||||
|
|||||||
@@ -36,6 +36,14 @@ UserInput::UserInput(Configuration &c)
|
|||||||
|
|
||||||
UserInput::~UserInput()
|
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.
|
// 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++)
|
// 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);
|
bool MapKey(std::string keyDescription, KeyCode_E key, bool required);
|
||||||
Configuration &config_;
|
Configuration &config_;
|
||||||
std::vector<SDL_Joystick *> joysticks_;
|
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 lastKeyState_[KeyCodeMax];
|
||||||
bool currentKeyState_[KeyCodeMax];
|
bool currentKeyState_[KeyCodeMax];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user