Cleanup and debug prints

This commit is contained in:
Clownacy 2020-04-03 17:02:02 +01:00
parent 5bb839136b
commit dac8f704cd
2 changed files with 12 additions and 3 deletions

View file

@ -1,5 +1,7 @@
#include "../Controller.h" #include "../Controller.h"
#include <stdio.h>
#define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@ -19,17 +21,22 @@ void ControllerBackend_Deinit(void)
BOOL ControllerBackend_Init(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) for (int i = GLFW_JOYSTICK_1; i < GLFW_JOYSTICK_LAST; ++i)
{ {
if (glfwJoystickPresent(i) == GLFW_TRUE && glfwJoystickIsGamepad(i) == GLFW_TRUE) if (glfwJoystickPresent(i) == GLFW_TRUE && glfwJoystickIsGamepad(i) == GLFW_TRUE)
{ {
printf("Joystick #%d selected\n", i);
joystick_connected = TRUE; joystick_connected = TRUE;
connected_joystick_id = i; connected_joystick_id = i;
break; return TRUE;
} }
} }
return joystick_connected; return FALSE;
} }
BOOL ControllerBackend_GetJoystickStatus(JOYSTICK_STATUS *status) BOOL ControllerBackend_GetJoystickStatus(JOYSTICK_STATUS *status)

View file

@ -2,7 +2,6 @@
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "SDL.h" #include "SDL.h"
@ -54,7 +53,10 @@ BOOL FindAndOpenDirectInputDevice(void)
// Break as soon as a joystick is properly opened // Break as soon as a joystick is properly opened
if (joystick != NULL) if (joystick != NULL)
{
printf("Joystick #%d selected\n", i);
return TRUE; return TRUE;
}
} }
return FALSE; return FALSE;