ref: 659f89ea85658e789eafb66d1447617d691d925f
parent: e874b7535722a72456a20d2182b28f65f79a4f60
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sat Apr 4 15:03:19 EDT 2020
Cleanup and proper deinitialisation
--- a/src/Backends/GLFW3/Controller.cpp
+++ b/src/Backends/GLFW3/Controller.cpp
@@ -1,5 +1,6 @@
#include "../Controller.h"
+#include <stddef.h>
#include <stdio.h>
#define GLFW_INCLUDE_NONE
@@ -58,7 +59,12 @@
void ControllerBackend_Deinit(void)
{
-
+ glfwSetJoystickCallback(NULL);
+
+ joystick_connected = FALSE;
+ connected_joystick_id = 0;
+ joystick_neutral_x = 0;
+ joystick_neutral_y = 0;
}
BOOL ControllerBackend_Init(void)
@@ -92,6 +98,7 @@
int total_buttons;
const unsigned char *buttons = glfwGetJoystickButtons(connected_joystick_id, &total_buttons);
+ // The original `Input.cpp` assumed there were 32 buttons (because of DirectInput's `DIJOYSTATE` struct)
if (total_buttons > 32)
total_buttons = 32;
--- a/src/Backends/SDL2/Controller.cpp
+++ b/src/Backends/SDL2/Controller.cpp
@@ -67,7 +67,7 @@
if (joystick == NULL)
return FALSE;
- // The original Input.cpp assumed there were 32 buttons (because of DirectInput's 'DIJOYSTATE' struct)
+ // The original `Input.cpp` assumed there were 32 buttons (because of DirectInput's `DIJOYSTATE` struct)
int numButtons = SDL_JoystickNumButtons(joystick);
if (numButtons > 32)
numButtons = 32;