update code for some recent SDL3 renames

This commit is contained in:
Sasha Szpakowski
2024-03-25 20:55:28 -03:00
parent 2bdadf51d4
commit 8d360113f8
2 changed files with 15 additions and 4 deletions
+3 -4
View File
@@ -334,14 +334,13 @@ Joystick::JoystickInput Joystick::getGamepadMapping(const GamepadInput &input) c
int bindcount = 0; int bindcount = 0;
SDL_GamepadBinding **sdlbindings = SDL_GetGamepadBindings(controller, &bindcount); SDL_GamepadBinding **sdlbindings = SDL_GetGamepadBindings(controller, &bindcount);
const SDL_GamepadBinding *sdlbinding = nullptr;
for (int i = 0; i < bindcount; i++) for (int i = 0; i < bindcount; i++)
{ {
const SDL_GamepadBinding *b = sdlbindings[i]; const SDL_GamepadBinding *b = sdlbindings[i];
if ((input.type == INPUT_TYPE_BUTTON && b->outputType == SDL_GAMEPAD_BINDTYPE_BUTTON && b->output.button == sdlbutton) if ((input.type == INPUT_TYPE_BUTTON && b->output_type == SDL_GAMEPAD_BINDTYPE_BUTTON && b->output.button == sdlbutton)
|| (input.type == INPUT_TYPE_AXIS && b->outputType == SDL_GAMEPAD_BINDTYPE_AXIS && b->output.axis.axis == sdlaxis)) || (input.type == INPUT_TYPE_AXIS && b->output_type == SDL_GAMEPAD_BINDTYPE_AXIS && b->output.axis.axis == sdlaxis))
{ {
switch (b->inputType) switch (b->input_type)
{ {
case SDL_GAMEPAD_BINDTYPE_BUTTON: case SDL_GAMEPAD_BINDTYPE_BUTTON:
jinput.type = INPUT_TYPE_BUTTON; jinput.type = INPUT_TYPE_BUTTON;
+12
View File
@@ -1512,13 +1512,21 @@ void Window::setMouseGrab(bool grab)
{ {
mouseGrabbed = grab; mouseGrabbed = grab;
if (window) if (window)
#if SDL_VERSION_ATLEAST(3, 0, 0)
SDL_SetWindowMouseGrab(window, (SDL_bool) grab);
#else
SDL_SetWindowGrab(window, (SDL_bool) grab); SDL_SetWindowGrab(window, (SDL_bool) grab);
#endif
} }
bool Window::isMouseGrabbed() const bool Window::isMouseGrabbed() const
{ {
if (window) if (window)
#if SDL_VERSION_ATLEAST(3, 0, 0)
return SDL_GetWindowMouseGrab(window);
#else
return SDL_GetWindowGrab(window) != SDL_FALSE; return SDL_GetWindowGrab(window) != SDL_FALSE;
#endif
else else
return mouseGrabbed; return mouseGrabbed;
} }
@@ -1684,7 +1692,11 @@ int Window::showMessageBox(const MessageBoxData &data)
{ {
SDL_MessageBoxButtonData sdlbutton = {}; SDL_MessageBoxButtonData sdlbutton = {};
#if SDL_VERSION_ATLEAST(3, 0, 0)
sdlbutton.buttonID = i;
#else
sdlbutton.buttonid = i; sdlbutton.buttonid = i;
#endif
sdlbutton.text = data.buttons[i].c_str(); sdlbutton.text = data.buttons[i].c_str();
if (i == data.enterButtonIndex) if (i == data.enterButtonIndex)