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 "../../WindowsWrapper.h"
|
||||
#include "../Misc.h"
|
||||
#include "../../WindowsWrapper.h"
|
||||
|
||||
#define DEADZONE 10000
|
||||
|
||||
|
@ -142,6 +142,7 @@ BOOL ControllerBackend_ResetJoystickStatus(void)
|
|||
void ControllerBackend_JoystickConnect(Sint32 joystick_id)
|
||||
{
|
||||
const char *joystick_name = SDL_JoystickNameForIndex(joystick_id);
|
||||
|
||||
if (joystick_name != NULL)
|
||||
{
|
||||
Backend_PrintInfo("Joystick #%d connected - %s", joystick_id, joystick_name);
|
||||
|
@ -172,18 +173,23 @@ void ControllerBackend_JoystickConnect(Sint32 joystick_id)
|
|||
|
||||
// Set up neutral axes
|
||||
axis_neutrals = (Sint16*)malloc(sizeof(Sint16) * total_axes);
|
||||
|
||||
if (axis_neutrals != NULL)
|
||||
{
|
||||
for (int i = 0; i < total_axes; ++i)
|
||||
axis_neutrals[i] = SDL_JoystickGetAxis(joystick, i);
|
||||
else
|
||||
Backend_PrintError("Couldn't allocate memory for neutral axes");
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Backend_PrintError("Couldn't allocate memory for neutral axes");
|
||||
}
|
||||
}
|
||||
|
||||
SDL_JoystickClose(joystick);
|
||||
joystick = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Backend_PrintError("Couldn't open joystick for use: %s", SDL_GetError());
|
||||
|
|
|
@ -45,22 +45,29 @@ BOOL Backend_Init(void)
|
|||
const char *driver = SDL_GetCurrentVideoDriver();
|
||||
|
||||
if (driver != NULL)
|
||||
{
|
||||
Backend_PrintInfo("Selected SDL video driver: %s", driver);
|
||||
else
|
||||
Backend_PrintError("No SDL video driver initialized !");
|
||||
|
||||
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());
|
||||
|
||||
SDL_Quit();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string error_message = std::string("Could not initialise SDL: ") + SDL_GetError();
|
||||
Backend_ShowMessageBox("Fatal error", error_message.c_str());
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -301,6 +308,7 @@ void Backend_GetKeyboardState(BOOL *out_keyboard_state)
|
|||
void Backend_ShowMessageBox(const char *title, const char *message)
|
||||
{
|
||||
fprintf(stderr, "ShowMessageBox - '%s' - '%s'\n", title, message);
|
||||
|
||||
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());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue