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; break;
} }
case SDL_QUIT: case SDL_QUIT:
g_AppDelegate->onAppExiting();
Log.report(logvisor::Info, FMT_STRING("Received quit request"));
return false; return false;
} }
// Log.report(logvisor::Info, FMT_STRING("Received SDL event: {}"), event.type); // 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(); ImGui::EndFrame();
} }
Log.report(logvisor::Info, FMT_STRING("Application exiting"));
g_AppDelegate->onAppExiting(); g_AppDelegate->onAppExiting();
imgui::shutdown(); imgui::shutdown();

View File

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