More cleanup
This commit is contained in:
parent
aa9e486086
commit
58fc9a392a
2 changed files with 30 additions and 16 deletions
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
#include "../../WindowsWrapper.h"
|
|
||||||
#include "../Misc.h"
|
#include "../Misc.h"
|
||||||
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
#define DEADZONE 10000
|
#define DEADZONE 10000
|
||||||
|
|
||||||
|
@ -142,6 +142,7 @@ BOOL ControllerBackend_ResetJoystickStatus(void)
|
||||||
void ControllerBackend_JoystickConnect(Sint32 joystick_id)
|
void ControllerBackend_JoystickConnect(Sint32 joystick_id)
|
||||||
{
|
{
|
||||||
const char *joystick_name = SDL_JoystickNameForIndex(joystick_id);
|
const char *joystick_name = SDL_JoystickNameForIndex(joystick_id);
|
||||||
|
|
||||||
if (joystick_name != NULL)
|
if (joystick_name != NULL)
|
||||||
{
|
{
|
||||||
Backend_PrintInfo("Joystick #%d connected - %s", joystick_id, joystick_name);
|
Backend_PrintInfo("Joystick #%d connected - %s", joystick_id, joystick_name);
|
||||||
|
@ -172,17 +173,22 @@ void ControllerBackend_JoystickConnect(Sint32 joystick_id)
|
||||||
|
|
||||||
// Set up neutral axes
|
// Set up neutral axes
|
||||||
axis_neutrals = (Sint16*)malloc(sizeof(Sint16) * total_axes);
|
axis_neutrals = (Sint16*)malloc(sizeof(Sint16) * total_axes);
|
||||||
|
|
||||||
if (axis_neutrals != NULL)
|
if (axis_neutrals != NULL)
|
||||||
|
{
|
||||||
for (int i = 0; i < total_axes; ++i)
|
for (int i = 0; i < total_axes; ++i)
|
||||||
axis_neutrals[i] = SDL_JoystickGetAxis(joystick, i);
|
axis_neutrals[i] = SDL_JoystickGetAxis(joystick, i);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
Backend_PrintError("Couldn't allocate memory for neutral axes");
|
Backend_PrintError("Couldn't allocate memory for neutral axes");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
SDL_JoystickClose(joystick);
|
||||||
SDL_JoystickClose(joystick);
|
joystick = NULL;
|
||||||
joystick = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,22 +45,29 @@ BOOL Backend_Init(void)
|
||||||
const char *driver = SDL_GetCurrentVideoDriver();
|
const char *driver = SDL_GetCurrentVideoDriver();
|
||||||
|
|
||||||
if (driver != NULL)
|
if (driver != NULL)
|
||||||
|
{
|
||||||
Backend_PrintInfo("Selected SDL video driver: %s", driver);
|
Backend_PrintInfo("Selected SDL video driver: %s", driver);
|
||||||
else
|
|
||||||
Backend_PrintError("No SDL video driver initialized !");
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Backend_PrintError("No SDL video driver initialized!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string error_message = std::string("Could not initialise SDL video subsystem: ") + SDL_GetError();
|
||||||
|
Backend_ShowMessageBox("Fatal error", error_message.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string error_message = std::string("Could not initialise SDL video subsystem: ") + SDL_GetError();
|
|
||||||
Backend_ShowMessageBox("Fatal error", error_message.c_str());
|
|
||||||
|
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
std::string error_message = std::string("Could not initialise SDL: ") + SDL_GetError();
|
{
|
||||||
Backend_ShowMessageBox("Fatal error", error_message.c_str());
|
std::string error_message = std::string("Could not initialise SDL: ") + SDL_GetError();
|
||||||
|
Backend_ShowMessageBox("Fatal error", error_message.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -301,6 +308,7 @@ void Backend_GetKeyboardState(BOOL *out_keyboard_state)
|
||||||
void Backend_ShowMessageBox(const char *title, const char *message)
|
void Backend_ShowMessageBox(const char *title, const char *message)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ShowMessageBox - '%s' - '%s'\n", title, message);
|
fprintf(stderr, "ShowMessageBox - '%s' - '%s'\n", title, message);
|
||||||
|
|
||||||
if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, message, window) != 0)
|
if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, message, window) != 0)
|
||||||
Backend_PrintError("Was also unable to display a message box containing the error: %s", SDL_GetError());
|
Backend_PrintError("Was also unable to display a message box containing the error: %s", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue