aurora: Free result of SDL_GameControllerMapping

This commit is contained in:
Luke Street 2022-02-23 03:19:19 -05:00
parent 1685489303
commit 79c4368f15
2 changed files with 3 additions and 4 deletions

View File

@ -215,8 +215,6 @@ static bool poll_events() noexcept {
break;
}
case SDL_QUIT:
g_AppDelegate->onAppExiting();
Log.report(logvisor::Info, FMT_STRING("Received quit request"));
return false;
}
// Log.report(logvisor::Info, FMT_STRING("Received SDL event: {}"), event.type);
@ -350,6 +348,7 @@ void app_run(std::unique_ptr<AppDelegate> app, Icon icon, int argc, char** argv)
ImGui::EndFrame();
}
Log.report(logvisor::Info, FMT_STRING("Application exiting"));
g_AppDelegate->onAppExiting();
imgui::shutdown();

View File

@ -56,7 +56,6 @@ static std::optional<std::string> remap_controller_layout(std::string_view mappi
newMapping.push_back(':');
newMapping.append(v);
}
Log.report(logvisor::Info, FMT_STRING("New mapping: {}"), newMapping);
return newMapping;
}
@ -64,9 +63,10 @@ Sint32 add_controller(Sint32 which) noexcept {
auto* ctrl = SDL_GameControllerOpen(which);
if (ctrl != nullptr) {
{
const char* mapping = SDL_GameControllerMapping(ctrl);
char* mapping = SDL_GameControllerMapping(ctrl);
if (mapping != nullptr) {
auto newMapping = remap_controller_layout(mapping);
SDL_free(mapping);
if (newMapping) {
if (SDL_GameControllerAddMapping(newMapping->c_str()) == -1) {
Log.report(logvisor::Error, FMT_STRING("Failed to update controller mapping: {}"), SDL_GetError());