Improve shutdowns
This commit is contained in:
parent
ecb059daa9
commit
326e2f110d
3 changed files with 17 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue