mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-04 08:56:25 +00:00
Change return type from void to int, for functions that set an error
(SDL_SetError(), SDL_OutOfMemory(), SDL_Unsupported(), SDL_InvalidParam()) Update prototype to forward errors to generic layer, for the functions: MoveCursor, WarpMouse, GL_DeleteContext, GetDisplayModes. Check invalid parameter in SDL_SetTextInputRect() generic layer.
This commit is contained in:
@@ -936,7 +936,7 @@ const char *SDL_GetGamepadStringForButton(SDL_GamepadButton button)
|
||||
/*
|
||||
* given a gamepad button name and a joystick name update our mapping structure with it
|
||||
*/
|
||||
static void SDL_PrivateParseGamepadElement(SDL_Gamepad *gamepad, const char *szGameButton, const char *szJoystickButton)
|
||||
static int SDL_PrivateParseGamepadElement(SDL_Gamepad *gamepad, const char *szGameButton, const char *szJoystickButton)
|
||||
{
|
||||
SDL_ExtendedGamepadBind bind;
|
||||
SDL_GamepadButton button;
|
||||
@@ -975,8 +975,7 @@ static void SDL_PrivateParseGamepadElement(SDL_Gamepad *gamepad, const char *szG
|
||||
bind.outputType = SDL_GAMEPAD_BINDTYPE_BUTTON;
|
||||
bind.output.button = button;
|
||||
} else {
|
||||
SDL_SetError("Unexpected gamepad element %s", szGameButton);
|
||||
return;
|
||||
return SDL_SetError("Unexpected gamepad element %s", szGameButton);
|
||||
}
|
||||
|
||||
if (*szJoystickButton == '+' || *szJoystickButton == '-') {
|
||||
@@ -1015,24 +1014,23 @@ static void SDL_PrivateParseGamepadElement(SDL_Gamepad *gamepad, const char *szG
|
||||
bind.input.hat.hat = hat;
|
||||
bind.input.hat.hat_mask = mask;
|
||||
} else {
|
||||
SDL_SetError("Unexpected joystick element: %s", szJoystickButton);
|
||||
return;
|
||||
return SDL_SetError("Unexpected joystick element: %s", szJoystickButton);
|
||||
}
|
||||
|
||||
++gamepad->num_bindings;
|
||||
gamepad->bindings = (SDL_ExtendedGamepadBind *)SDL_realloc(gamepad->bindings, gamepad->num_bindings * sizeof(*gamepad->bindings));
|
||||
if (!gamepad->bindings) {
|
||||
gamepad->num_bindings = 0;
|
||||
SDL_OutOfMemory();
|
||||
return;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
gamepad->bindings[gamepad->num_bindings - 1] = bind;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* given a gamepad mapping string update our mapping object
|
||||
*/
|
||||
static void SDL_PrivateParseGamepadConfigString(SDL_Gamepad *gamepad, const char *pchString)
|
||||
static int SDL_PrivateParseGamepadConfigString(SDL_Gamepad *gamepad, const char *pchString)
|
||||
{
|
||||
char szGameButton[20];
|
||||
char szJoystickButton[20];
|
||||
@@ -1058,15 +1056,13 @@ static void SDL_PrivateParseGamepadConfigString(SDL_Gamepad *gamepad, const char
|
||||
|
||||
} else if (bGameButton) {
|
||||
if (i >= sizeof(szGameButton)) {
|
||||
SDL_SetError("Button name too large: %s", szGameButton);
|
||||
return;
|
||||
return SDL_SetError("Button name too large: %s", szGameButton);
|
||||
}
|
||||
szGameButton[i] = *pchPos;
|
||||
i++;
|
||||
} else {
|
||||
if (i >= sizeof(szJoystickButton)) {
|
||||
SDL_SetError("Joystick button name too large: %s", szJoystickButton);
|
||||
return;
|
||||
return SDL_SetError("Joystick button name too large: %s", szJoystickButton);
|
||||
}
|
||||
szJoystickButton[i] = *pchPos;
|
||||
i++;
|
||||
@@ -1078,6 +1074,7 @@ static void SDL_PrivateParseGamepadConfigString(SDL_Gamepad *gamepad, const char
|
||||
if (szGameButton[0] != '\0' || szJoystickButton[0] != '\0') {
|
||||
SDL_PrivateParseGamepadElement(gamepad, szGameButton, szJoystickButton);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -1043,15 +1043,16 @@ int SDL_GetJoystickPlayerIndex(SDL_Joystick *joystick)
|
||||
/**
|
||||
* Set the player index of an opened joystick
|
||||
*/
|
||||
void SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index)
|
||||
int SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index)
|
||||
{
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, );
|
||||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
SDL_SetJoystickIDForPlayerIndex(player_index, joystick->instance_id);
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
|
||||
@@ -1216,7 +1217,7 @@ int SDL_SendJoystickEffect(SDL_Joystick *joystick, const void *data, int size)
|
||||
/*
|
||||
* Close a joystick previously opened with SDL_OpenJoystick()
|
||||
*/
|
||||
void SDL_CloseJoystick(SDL_Joystick *joystick)
|
||||
int SDL_CloseJoystick(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_Joystick *joysticklist;
|
||||
SDL_Joystick *joysticklistprev;
|
||||
@@ -1224,12 +1225,12 @@ void SDL_CloseJoystick(SDL_Joystick *joystick)
|
||||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, );
|
||||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
/* First decrement ref count */
|
||||
if (--joystick->ref_count > 0) {
|
||||
SDL_UnlockJoysticks();
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (joystick->rumble_expiration) {
|
||||
@@ -1276,6 +1277,7 @@ void SDL_CloseJoystick(SDL_Joystick *joystick)
|
||||
SDL_free(joystick);
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_QuitJoysticks(void)
|
||||
|
@@ -458,15 +458,15 @@ static SDL_bool RAWINPUT_MissingWindowsGamingInputSlot()
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static void RAWINPUT_UpdateWindowsGamingInput()
|
||||
static int RAWINPUT_UpdateWindowsGamingInput()
|
||||
{
|
||||
int ii;
|
||||
if (!wgi_state.gamepad_statics) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!wgi_state.dirty) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
wgi_state.dirty = SDL_FALSE;
|
||||
@@ -507,13 +507,11 @@ static void RAWINPUT_UpdateWindowsGamingInput()
|
||||
wgi_state.per_gamepad_count++;
|
||||
wgi_state.per_gamepad = SDL_realloc(wgi_state.per_gamepad, sizeof(wgi_state.per_gamepad[0]) * wgi_state.per_gamepad_count);
|
||||
if (!wgi_state.per_gamepad) {
|
||||
SDL_OutOfMemory();
|
||||
return;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
gamepad_state = SDL_calloc(1, sizeof(*gamepad_state));
|
||||
if (gamepad_state == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
wgi_state.per_gamepad[wgi_state.per_gamepad_count - 1] = gamepad_state;
|
||||
gamepad_state->gamepad = gamepad;
|
||||
@@ -549,6 +547,7 @@ static void RAWINPUT_UpdateWindowsGamingInput()
|
||||
wgi_state.per_gamepad[ii]->connected = SDL_FALSE; /* Not used by anything, currently */
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static void RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx)
|
||||
{
|
||||
@@ -1907,7 +1906,7 @@ RAWINPUT_RegisterNotifications(HWND hWnd)
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
void RAWINPUT_UnregisterNotifications()
|
||||
int RAWINPUT_UnregisterNotifications()
|
||||
{
|
||||
int i;
|
||||
RAWINPUTDEVICE rid[SDL_arraysize(subscribed_devices)];
|
||||
@@ -1920,9 +1919,9 @@ void RAWINPUT_UnregisterNotifications()
|
||||
}
|
||||
|
||||
if (!RegisterRawInputDevices(rid, SDL_arraysize(rid), sizeof(RAWINPUTDEVICE))) {
|
||||
SDL_SetError("Couldn't unregister for raw input events");
|
||||
return;
|
||||
return SDL_SetError("Couldn't unregister for raw input events");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
|
@@ -29,7 +29,7 @@ extern SDL_bool RAWINPUT_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Ui
|
||||
|
||||
/* Registers for input events */
|
||||
extern SDL_bool RAWINPUT_RegisterNotifications(HWND hWnd);
|
||||
extern void RAWINPUT_UnregisterNotifications();
|
||||
extern int RAWINPUT_UnregisterNotifications();
|
||||
|
||||
/* Returns 0 if message was handled */
|
||||
extern LRESULT CALLBACK RAWINPUT_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
Reference in New Issue
Block a user