Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit fe21ae2

Browse files
close controllers on shutdown #61
1 parent 488b7b2 commit fe21ae2

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

OFS-lib/OFS_ControllerInput.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ void ControllerInput::CloseController() noexcept
4040
isConnected = false;
4141
if (haptic) {
4242
SDL_HapticClose(haptic);
43-
haptic = 0;
43+
haptic = nullptr;
4444
}
4545
SDL_GameControllerClose(gamepad);
46-
gamepad = 0;
46+
gamepad = nullptr;
4747
}
4848
}
4949

@@ -119,4 +119,11 @@ void ControllerInput::UpdateControllers() noexcept
119119
controller.Update();
120120
}
121121
}
122+
}
123+
124+
void ControllerInput::Shutdown() noexcept
125+
{
126+
for (auto& controller : Controllers) {
127+
controller.CloseController();
128+
}
122129
}

OFS-lib/OFS_ControllerInput.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class ControllerInput {
2828

2929
void Init() noexcept;
3030
void Update() noexcept;
31+
void Shutdown() noexcept;
3132

3233
static void UpdateControllers() noexcept;
3334

src/OpenFunscripter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,6 +1713,7 @@ void OpenFunscripter::Shutdown() noexcept
17131713
OFS_FileLogger::Shutdown();
17141714
webApi->Shutdown();
17151715

1716+
controllerInput->Shutdown();
17161717
SDL_GL_DeleteContext(glContext);
17171718
SDL_DestroyWindow(window);
17181719
SDL_Quit();

0 commit comments

Comments
 (0)