Improve shutdowns

This commit is contained in:
Daniel Stuart Baxter 2015-05-30 01:58:55 -05:00
parent ecb059daa9
commit 326e2f110d
3 changed files with 17 additions and 4 deletions

View file

@ -64,6 +64,15 @@ void Init(ControllerBackends backend) {
CoreTiming::ScheduleEvent(frame_ticks, input_event);
}
void ShutDown() {
//Delete the current user input plugin
if(g_user_input != nullptr)
{
delete g_user_input;
g_user_input = nullptr;
}
}
} // namespace

View file

@ -49,6 +49,9 @@ protected:
///Initialize the user input system
void Init(ControllerBackends backend);
///Deactive the user input system
void ShutDown();
///InputCommon 'plugin'
extern ControllerBase* g_user_input;

View file

@ -18,7 +18,10 @@ SDLController::SDLController() {
controller.touch_screen_x = 0;
controller.touch_screen_y = 0;
Init();
//Immediately shutdown if initialization fails
if(!Init()) {
ShutDown();
}
}
SDLController::~SDLController() {
@ -37,7 +40,6 @@ bool SDLController::Init() {
jpad = SDL_JoystickOpen(index);
if(jpad == nullptr) {
std::cout<<"What\n";
return false;
}
@ -58,8 +60,7 @@ void SDLController::ShutDown() {
SDL_JoystickClose(jpad);
}
//Delete the current user input plugin
delete g_user_input;
InputCommon::ShutDown();
}
void SDLController::Poll() {