From dac8f704cd3511b2ce2535e33384dcb9a51367d7 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 3 Apr 2020 17:02:02 +0100 Subject: [PATCH] Cleanup and debug prints --- src/Backends/GLFW3/Controller.cpp | 11 +++++++++-- src/Backends/SDL2/Controller.cpp | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Backends/GLFW3/Controller.cpp b/src/Backends/GLFW3/Controller.cpp index eecd271e..345ecf95 100644 --- a/src/Backends/GLFW3/Controller.cpp +++ b/src/Backends/GLFW3/Controller.cpp @@ -1,5 +1,7 @@ #include "../Controller.h" +#include + #define GLFW_INCLUDE_NONE #include @@ -19,17 +21,22 @@ void ControllerBackend_Deinit(void) 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) diff --git a/src/Backends/SDL2/Controller.cpp b/src/Backends/SDL2/Controller.cpp index 05b30c2d..a3434bb5 100644 --- a/src/Backends/SDL2/Controller.cpp +++ b/src/Backends/SDL2/Controller.cpp @@ -2,7 +2,6 @@ #include #include -#include #include "SDL.h" @@ -54,7 +53,10 @@ BOOL FindAndOpenDirectInputDevice(void) // Break as soon as a joystick is properly opened if (joystick != NULL) + { + printf("Joystick #%d selected\n", i); return TRUE; + } } return FALSE;