Shuffle code

This commit is contained in:
Clownacy 2020-04-04 19:04:56 +01:00
parent d957c40649
commit e00ad1cd78
3 changed files with 23 additions and 23 deletions

View file

@ -4,7 +4,7 @@
#include "../Input.h" #include "../Input.h"
void ControllerBackend_Deinit(void);
BOOL ControllerBackend_Init(void); BOOL ControllerBackend_Init(void);
void ControllerBackend_Deinit(void);
BOOL ControllerBackend_GetJoystickStatus(JOYSTICK_STATUS *status); BOOL ControllerBackend_GetJoystickStatus(JOYSTICK_STATUS *status);
BOOL ControllerBackend_ResetJoystickStatus(void); BOOL ControllerBackend_ResetJoystickStatus(void);

View file

@ -57,16 +57,6 @@ static void JoystickCallback(int joystick_id, int event)
} }
} }
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) BOOL ControllerBackend_Init(void)
{ {
// Connect joysticks that are already plugged-in // Connect joysticks that are already plugged-in
@ -80,6 +70,16 @@ BOOL ControllerBackend_Init(void)
return TRUE; return TRUE;
} }
void ControllerBackend_Deinit(void)
{
glfwSetJoystickCallback(NULL);
joystick_connected = FALSE;
connected_joystick_id = 0;
joystick_neutral_x = 0;
joystick_neutral_y = 0;
}
BOOL ControllerBackend_GetJoystickStatus(JOYSTICK_STATUS *status) BOOL ControllerBackend_GetJoystickStatus(JOYSTICK_STATUS *status)
{ {
if (!joystick_connected) if (!joystick_connected)

View file

@ -12,18 +12,6 @@ static SDL_Joystick *joystick = NULL;
static int joystick_neutral_x = 0; static int joystick_neutral_x = 0;
static int joystick_neutral_y = 0; static int joystick_neutral_y = 0;
void ControllerBackend_Deinit(void)
{
// Close opened joystick (if exists)
if (joystick != NULL)
{
SDL_JoystickClose(joystick);
joystick = NULL;
}
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
}
// It looks like Pixel declared his functions early, so he could forward-reference // It looks like Pixel declared his functions early, so he could forward-reference
BOOL FindAndOpenDirectInputDevice(void); BOOL FindAndOpenDirectInputDevice(void);
@ -37,6 +25,18 @@ BOOL ControllerBackend_Init(void)
return TRUE; return TRUE;
} }
void ControllerBackend_Deinit(void)
{
// Close opened joystick (if exists)
if (joystick != NULL)
{
SDL_JoystickClose(joystick);
joystick = NULL;
}
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
}
// The original name for this function and its variables are unknown. // The original name for this function and its variables are unknown.
// This function finds and hooks the first available DirectInput device (or SDL Joystick, in this case). // This function finds and hooks the first available DirectInput device (or SDL Joystick, in this case).
BOOL FindAndOpenDirectInputDevice(void) BOOL FindAndOpenDirectInputDevice(void)