shithub: cstory

Download patch

ref: dac8f704cd3511b2ce2535e33384dcb9a51367d7
parent: 5bb839136bab80e2c4605e40442edb138ecb83b5
author: Clownacy <[email protected]>
date: Fri Apr 3 13:02:02 EDT 2020

Cleanup and debug prints

--- a/src/Backends/GLFW3/Controller.cpp
+++ b/src/Backends/GLFW3/Controller.cpp
@@ -1,5 +1,7 @@
 #include "../Controller.h"
 
+#include <stdio.h>
+
 #define GLFW_INCLUDE_NONE
 #include <GLFW/glfw3.h>
 
@@ -20,16 +22,21 @@
 BOOL ControllerBackend_Init(void)
 {
 	for (int i = GLFW_JOYSTICK_1; i < GLFW_JOYSTICK_LAST; ++i)
+		if (glfwJoystickPresent(i) == GLFW_TRUE)
+			printf("Joystick #%d name: %s\n", i, glfwGetJoystickName(i));
+
+	for (int i = GLFW_JOYSTICK_1; i < GLFW_JOYSTICK_LAST; ++i)
 	{
 		if (glfwJoystickPresent(i) == GLFW_TRUE && glfwJoystickIsGamepad(i) == GLFW_TRUE)
 		{
+			printf("Joystick #%d selected\n", i);
 			joystick_connected = TRUE;
 			connected_joystick_id = i;
-			break;
+			return TRUE;
 		}
 	}
 
-	return joystick_connected;
+	return FALSE;
 }
 
 BOOL ControllerBackend_GetJoystickStatus(JOYSTICK_STATUS *status)
--- a/src/Backends/SDL2/Controller.cpp
+++ b/src/Backends/SDL2/Controller.cpp
@@ -2,7 +2,6 @@
 
 #include <stddef.h>
 #include <stdio.h>
-#include <string.h>
 
 #include "SDL.h"
 
@@ -54,7 +53,10 @@
 
 		// Break as soon as a joystick is properly opened
 		if (joystick != NULL)
+		{
+			printf("Joystick #%d selected\n", i);
 			return TRUE;
+		}
 	}
 
 	return FALSE;