From 9275ad46893ce65ad5944c16da573486db28e3db Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 13 Apr 2020 13:35:01 +0100 Subject: [PATCH] This error should result in failure --- src/Backends/GLFW3/Controller.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Backends/GLFW3/Controller.cpp b/src/Backends/GLFW3/Controller.cpp index b82cd482..88885f35 100644 --- a/src/Backends/GLFW3/Controller.cpp +++ b/src/Backends/GLFW3/Controller.cpp @@ -38,18 +38,22 @@ static void JoystickCallback(int joystick_id, int event) if (glfwJoystickIsGamepad(joystick_id) == GLFW_TRUE) // Avoid selecting things like laptop touchpads #endif { - printf("Joystick #%d selected\n", joystick_id); - joystick_connected = TRUE; - connected_joystick_id = joystick_id; - // Set up neutral axes axis_neutrals = (float*)malloc(sizeof(float) * total_axes); if (axis_neutrals != NULL) + { for (int i = 0; i < total_axes; ++i) axis_neutrals[i] = axes[i]; + + printf("Joystick #%d selected\n", joystick_id); + joystick_connected = TRUE; + connected_joystick_id = joystick_id; + } else - Backend_PrintError("Couldn't allocate memory for axis"); + { + Backend_PrintError("Couldn't allocate memory for joystick axes"); + } } } }