From 8665a24eee71a45cb7d911a1b68027325812ceca Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 26 Jul 2020 23:56:58 +1000 Subject: [PATCH] CommonHostInterface: Fix crash when there's no controller interface --- src/frontend-common/common_host_interface.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index ab13293ad..14049a2e6 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -1058,12 +1058,15 @@ void CommonHostInterface::UpdateControllerInputMap(SettingsInterface& si) AddRumbleToInputMap(binding, controller_index, num_motors); } - const float axis_scale = si.GetFloatValue(category, "AxisScale", 1.00f); - m_controller_interface->SetControllerAxisScale(controller_index, - (ctype == ControllerType::AnalogController) ? axis_scale : 1.00f); + if (m_controller_interface) + { + const float axis_scale = si.GetFloatValue(category, "AxisScale", 1.00f); + m_controller_interface->SetControllerAxisScale(controller_index, + (ctype == ControllerType::AnalogController) ? axis_scale : 1.00f); - const float deadzone_size = si.GetFloatValue(category, "Deadzone", 0.25f); - m_controller_interface->SetControllerDeadzone(controller_index, deadzone_size); + const float deadzone_size = si.GetFloatValue(category, "Deadzone", 0.25f); + m_controller_interface->SetControllerDeadzone(controller_index, deadzone_size); + } } } @@ -2000,8 +2003,7 @@ bool CommonHostInterface::SaveScreenshot(const char* filename /* = nullptr */, b } m_system->GetGPU()->ResetGraphicsAPIState(); - const bool screenshot_saved = - m_display->WriteDisplayTextureToFile(filename, full_resolution, apply_aspect_ratio); + const bool screenshot_saved = m_display->WriteDisplayTextureToFile(filename, full_resolution, apply_aspect_ratio); m_system->GetGPU()->RestoreGraphicsAPIState(); if (!screenshot_saved) {