Update SDL to 3.2.0
This commit is contained in:
@@ -386,7 +386,7 @@ public:
|
||||
SDL_GetGlobalMouseState(&oldPosition.X, &oldPosition.Y);
|
||||
|
||||
Mouse::SetRelativeMode(relativeMode, window);
|
||||
if (SDL_SetWindowRelativeMouseMode(static_cast<SDLWindow*>(window)->_window, relativeMode ? SDL_TRUE : SDL_FALSE) != 0)
|
||||
if (!SDL_SetWindowRelativeMouseMode(static_cast<SDLWindow*>(window)->_window, relativeMode))
|
||||
LOG(Error, "Failed to set mouse relative mode: {0}", String(SDL_GetError()));
|
||||
|
||||
if (!relativeMode)
|
||||
@@ -438,7 +438,7 @@ public:
|
||||
|
||||
void OnAxisMotion(SDL_GamepadAxis axis, int16 value);
|
||||
|
||||
void OnButtonState(SDL_GamepadButton axis, uint8 state);
|
||||
void OnButtonState(SDL_GamepadButton axis, bool pressed);
|
||||
|
||||
// [Gamepad]
|
||||
void SetVibration(const GamepadVibrationState& state) override;
|
||||
@@ -512,7 +512,7 @@ bool SDLInput::HandleEvent(SDLWindow* window, SDL_Event& event)
|
||||
mousePos = SDLInputImpl::Mouse->GetMousePosition();
|
||||
}
|
||||
|
||||
if (event.button.state == SDL_RELEASED)
|
||||
if (!event.button.down)
|
||||
Input::Mouse->OnMouseUp(mousePos, button, window);
|
||||
// Prevent sending multiple mouse down event when double-clicking UI elements
|
||||
else if (event.button.clicks % 2 == 1)
|
||||
@@ -543,7 +543,7 @@ bool SDLInput::HandleEvent(SDLWindow* window, SDL_Event& event)
|
||||
// TODO: scancode support
|
||||
KeyboardKeys key = SDL_TO_FLAX_KEYS_MAP[event.key.scancode];
|
||||
//event.key.mod
|
||||
if (event.key.state == SDL_RELEASED)
|
||||
if (!event.key.down)
|
||||
Input::Keyboard->OnKeyUp(key, window);
|
||||
else
|
||||
Input::Keyboard->OnKeyDown(key, window);
|
||||
@@ -577,7 +577,7 @@ bool SDLInput::HandleEvent(SDLWindow* window, SDL_Event& event)
|
||||
{
|
||||
SDLGamepad* gamepad = SDLGamepad::GetGamepadById(event.gbutton.which);
|
||||
SDL_GamepadButton button = (SDL_GamepadButton)event.gbutton.button;
|
||||
gamepad->OnButtonState(button, event.gbutton.state);
|
||||
gamepad->OnButtonState(button, event.gbutton.down);
|
||||
|
||||
LOG(Info, "SDL_EVENT_GAMEPAD_BUTTON_");
|
||||
break;
|
||||
@@ -731,51 +731,51 @@ void SDLGamepad::OnAxisMotion(SDL_GamepadAxis sdlAxis, int16 value)
|
||||
_state.Axis[(int32)axis] = valueNormalized;
|
||||
}
|
||||
|
||||
void SDLGamepad::OnButtonState(SDL_GamepadButton sdlButton, uint8 state)
|
||||
void SDLGamepad::OnButtonState(SDL_GamepadButton sdlButton, bool pressed)
|
||||
{
|
||||
switch (sdlButton)
|
||||
{
|
||||
case SDL_GamepadButton::SDL_GAMEPAD_BUTTON_SOUTH:
|
||||
_state.Buttons[(int32)GamepadButton::A] = state == SDL_PRESSED;
|
||||
_state.Buttons[(int32)GamepadButton::A] = pressed;
|
||||
break;
|
||||
case SDL_GamepadButton::SDL_GAMEPAD_BUTTON_EAST:
|
||||
_state.Buttons[(int32)GamepadButton::B] = state == SDL_PRESSED;
|
||||
_state.Buttons[(int32)GamepadButton::B] = pressed;
|
||||
break;
|
||||
case SDL_GamepadButton::SDL_GAMEPAD_BUTTON_WEST:
|
||||
_state.Buttons[(int32)GamepadButton::X] = state == SDL_PRESSED;
|
||||
_state.Buttons[(int32)GamepadButton::X] = pressed;
|
||||
break;
|
||||
case SDL_GamepadButton::SDL_GAMEPAD_BUTTON_NORTH:
|
||||
_state.Buttons[(int32)GamepadButton::Y] = state == SDL_PRESSED;
|
||||
_state.Buttons[(int32)GamepadButton::Y] = pressed;
|
||||
break;
|
||||
case SDL_GamepadButton::SDL_GAMEPAD_BUTTON_LEFT_SHOULDER:
|
||||
_state.Buttons[(int32)GamepadButton::LeftShoulder] = state == SDL_PRESSED;
|
||||
_state.Buttons[(int32)GamepadButton::LeftShoulder] = pressed;
|
||||
break;
|
||||
case SDL_GamepadButton::SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER:
|
||||
_state.Buttons[(int32)GamepadButton::RightShoulder] = state == SDL_PRESSED;
|
||||
_state.Buttons[(int32)GamepadButton::RightShoulder] = pressed;
|
||||
break;
|
||||
case SDL_GamepadButton::SDL_GAMEPAD_BUTTON_BACK:
|
||||
_state.Buttons[(int32)GamepadButton::Back] = state == SDL_PRESSED;
|
||||
_state.Buttons[(int32)GamepadButton::Back] = pressed;
|
||||
break;
|
||||
case SDL_GamepadButton::SDL_GAMEPAD_BUTTON_START:
|
||||
_state.Buttons[(int32)GamepadButton::Start] = state == SDL_PRESSED;
|
||||
_state.Buttons[(int32)GamepadButton::Start] = pressed;
|
||||
break;
|
||||
case SDL_GamepadButton::SDL_GAMEPAD_BUTTON_LEFT_STICK:
|
||||
_state.Buttons[(int32)GamepadButton::LeftThumb] = state == SDL_PRESSED;
|
||||
_state.Buttons[(int32)GamepadButton::LeftThumb] = pressed;
|
||||
break;
|
||||
case SDL_GamepadButton::SDL_GAMEPAD_BUTTON_RIGHT_STICK:
|
||||
_state.Buttons[(int32)GamepadButton::RightThumb] = state == SDL_PRESSED;
|
||||
_state.Buttons[(int32)GamepadButton::RightThumb] = pressed;
|
||||
break;
|
||||
case SDL_GamepadButton::SDL_GAMEPAD_BUTTON_DPAD_UP:
|
||||
_state.Buttons[(int32)GamepadButton::DPadUp] = state == SDL_PRESSED;
|
||||
_state.Buttons[(int32)GamepadButton::DPadUp] = pressed;
|
||||
break;
|
||||
case SDL_GamepadButton::SDL_GAMEPAD_BUTTON_DPAD_DOWN:
|
||||
_state.Buttons[(int32)GamepadButton::DPadDown] = state == SDL_PRESSED;
|
||||
_state.Buttons[(int32)GamepadButton::DPadDown] = pressed;
|
||||
break;
|
||||
case SDL_GamepadButton::SDL_GAMEPAD_BUTTON_DPAD_LEFT:
|
||||
_state.Buttons[(int32)GamepadButton::DPadLeft] = state == SDL_PRESSED;
|
||||
_state.Buttons[(int32)GamepadButton::DPadLeft] = pressed;
|
||||
break;
|
||||
case SDL_GamepadButton::SDL_GAMEPAD_BUTTON_DPAD_RIGHT:
|
||||
_state.Buttons[(int32)GamepadButton::DPadRight] = state == SDL_PRESSED;
|
||||
_state.Buttons[(int32)GamepadButton::DPadRight] = pressed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -651,7 +651,7 @@ Array<String> SDLClipboard::GetFiles()
|
||||
return Array<String>();
|
||||
}
|
||||
|
||||
SDL_bool SDLCALL SDLPlatform::X11EventHook(void *userdata, _XEvent *xevent)
|
||||
bool SDLCALL SDLPlatform::X11EventHook(void *userdata, _XEvent *xevent)
|
||||
{
|
||||
const X11::XEvent& event = *(X11::XEvent*)xevent;
|
||||
Window* window;
|
||||
@@ -677,7 +677,7 @@ SDL_bool SDLCALL SDLPlatform::X11EventHook(void *userdata, _XEvent *xevent)
|
||||
{
|
||||
xDnDRequested = Impl::SelectTargetFromAtoms(xDisplay, targetTypeFiles, event.xclient.data.l[2], event.xclient.data.l[3], event.xclient.data.l[4]);
|
||||
}
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
else if ((uint32)event.xclient.message_type == (uint32)xAtomXdndPosition)
|
||||
{
|
||||
@@ -712,7 +712,7 @@ SDL_bool SDLCALL SDLPlatform::X11EventHook(void *userdata, _XEvent *xevent)
|
||||
window->OnDragEnter(&dropData, xDndPos, xDndResult);
|
||||
}
|
||||
}
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
else if ((uint32)event.xclient.message_type == (uint32)xAtomXdndLeave)
|
||||
{
|
||||
@@ -722,7 +722,7 @@ SDL_bool SDLCALL SDLPlatform::X11EventHook(void *userdata, _XEvent *xevent)
|
||||
window->_dragOver = false;
|
||||
window->OnDragLeave();
|
||||
}
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
else if ((uint32)event.xclient.message_type == (uint32)xAtomXdndDrop)
|
||||
{
|
||||
@@ -749,7 +749,7 @@ SDL_bool SDLCALL SDLPlatform::X11EventHook(void *userdata, _XEvent *xevent)
|
||||
m.data.l[2] = 0;
|
||||
X11::XSendEvent(xDisplay, event.xclient.data.l[0], 0, NoEventMask, (X11::XEvent*)&m);
|
||||
}
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (event.type == SelectionNotify)
|
||||
@@ -787,14 +787,14 @@ SDL_bool SDLCALL SDLPlatform::X11EventHook(void *userdata, _XEvent *xevent)
|
||||
m.data.l[1] = 1;
|
||||
m.data.l[2] = xAtomXdndActionCopy;
|
||||
XSendEvent(xDisplay, xDndSourceWindow, 0, NoEventMask, (X11::XEvent*)&m);
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
else if (event.type == SelectionRequest)
|
||||
{
|
||||
if (event.xselectionrequest.selection != xAtomClipboard)
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
|
||||
const X11::XSelectionRequestEvent* xsr = &event.xselectionrequest;
|
||||
X11::XSelectionEvent ev = { 0 };
|
||||
@@ -822,13 +822,13 @@ SDL_bool SDLCALL SDLPlatform::X11EventHook(void *userdata, _XEvent *xevent)
|
||||
ev.property = 0;
|
||||
if ((result & 2) == 0)
|
||||
X11::XSendEvent(xDisplay, ev.requestor, 0, 0, (X11::XEvent*)&ev);
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
else if (event.type == SelectionClear)
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
else if (event.type == XFixesSelectionNotifyEvent)
|
||||
return SDL_FALSE;
|
||||
return SDL_TRUE;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int X11ErrorHandler(X11::Display* display, X11::XErrorEvent* event)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <SDL3/SDL_system.h>
|
||||
|
||||
// The events for releasing the mouse during window dragging are missing, handle the mouse release event here
|
||||
SDL_bool SDLCALL SDLPlatform::EventMessageHook(void* userdata, MSG* msg)
|
||||
bool SDLCALL SDLPlatform::EventMessageHook(void* userdata, MSG* msg)
|
||||
{
|
||||
#define GET_WINDOW_WITH_HWND(window, hwnd) \
|
||||
do { \
|
||||
@@ -38,9 +38,9 @@ SDL_bool SDLCALL SDLPlatform::EventMessageHook(void* userdata, MSG* msg)
|
||||
|
||||
auto hit = static_cast<WindowHitCodes>(msg->wParam);
|
||||
if (SDLPlatform::CheckWindowDragging(window, hit))
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
#undef GET_WINDOW_WITH_HWND
|
||||
}
|
||||
|
||||
|
||||
@@ -70,16 +70,16 @@ bool SDLPlatform::Init()
|
||||
SDL_SetHint(SDL_HINT_WINDOWS_RAW_KEYBOARD, "1");
|
||||
|
||||
// Disable SDL clipboard support
|
||||
SDL_SetEventEnabled(SDL_EVENT_CLIPBOARD_UPDATE, SDL_FALSE);
|
||||
SDL_SetEventEnabled(SDL_EVENT_CLIPBOARD_UPDATE, false);
|
||||
|
||||
// Disable SDL drag and drop support
|
||||
SDL_SetEventEnabled(SDL_EVENT_DROP_FILE, SDL_FALSE);
|
||||
SDL_SetEventEnabled(SDL_EVENT_DROP_TEXT, SDL_FALSE);
|
||||
SDL_SetEventEnabled(SDL_EVENT_DROP_BEGIN, SDL_FALSE);
|
||||
SDL_SetEventEnabled(SDL_EVENT_DROP_COMPLETE, SDL_FALSE);
|
||||
SDL_SetEventEnabled(SDL_EVENT_DROP_POSITION, SDL_FALSE);
|
||||
SDL_SetEventEnabled(SDL_EVENT_DROP_FILE, false);
|
||||
SDL_SetEventEnabled(SDL_EVENT_DROP_TEXT, false);
|
||||
SDL_SetEventEnabled(SDL_EVENT_DROP_BEGIN, false);
|
||||
SDL_SetEventEnabled(SDL_EVENT_DROP_COMPLETE, false);
|
||||
SDL_SetEventEnabled(SDL_EVENT_DROP_POSITION, false);
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD) < 0)
|
||||
if (!SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD))
|
||||
Platform::Fatal(String::Format(TEXT("Failed to initialize SDL: {0}."), String(SDL_GetError())));
|
||||
|
||||
if (InitPlatform())
|
||||
@@ -123,7 +123,7 @@ void SDLPlatform::Tick()
|
||||
{
|
||||
Float2 mousePos;
|
||||
auto buttons = SDL_GetGlobalMouseState(&mousePos.X, &mousePos.Y);
|
||||
if (!(buttons & SDL_BUTTON(SDL_BUTTON_LEFT)))
|
||||
if (!(buttons & SDL_BUTTON_MASK(SDL_BUTTON_LEFT)))
|
||||
{
|
||||
Window* window = nullptr;
|
||||
WindowsManager::WindowsLocker.Lock();
|
||||
@@ -443,7 +443,7 @@ DialogResult MessageBox::Show(Window* parent, const StringView& text, const Stri
|
||||
data.buttons = dataButtons;
|
||||
|
||||
int result = -1;
|
||||
if (SDL_ShowMessageBox(&data, &result) != 0)
|
||||
if (!SDL_ShowMessageBox(&data, &result))
|
||||
{
|
||||
#if PLATFORM_LINUX
|
||||
// Fallback to native messagebox implementation in case some system fonts are missing
|
||||
|
||||
@@ -47,9 +47,9 @@ private:
|
||||
#endif
|
||||
static bool HandleEvent(SDL_Event& event);
|
||||
#if PLATFORM_WINDOWS
|
||||
static int __cdecl EventMessageHook(void* userdata, MSG* msg);
|
||||
static bool __cdecl EventMessageHook(void* userdata, MSG* msg);
|
||||
#elif PLATFORM_LINUX
|
||||
static int __cdecl X11EventHook(void *userdata, _XEvent *xevent);
|
||||
static bool __cdecl X11EventHook(void *userdata, _XEvent *xevent);
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
namespace
|
||||
{
|
||||
SDLWindow* LastEventWindow = nullptr;
|
||||
static SDL_Cursor* Cursors[SDL_NUM_SYSTEM_CURSORS] = { nullptr };
|
||||
static SDL_Cursor* Cursors[SDL_SYSTEM_CURSOR_COUNT] = { nullptr };
|
||||
}
|
||||
|
||||
void* GetNativeWindowPointer(SDL_Window* window);
|
||||
@@ -168,17 +168,17 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings)
|
||||
}
|
||||
|
||||
SDL_PropertiesID props = SDL_CreateProperties();
|
||||
SDL_SetNumberProperty(props, "flags", flags);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_FLAGS_NUMBER, flags);
|
||||
SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, settings.Title.ToStringAnsi().Get());
|
||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, x);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, y);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, windowWidth);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, windowHeight);
|
||||
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN, SDL_TRUE);
|
||||
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN, true);
|
||||
if ((flags & SDL_WINDOW_TOOLTIP) != 0)
|
||||
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_TOOLTIP_BOOLEAN, SDL_TRUE);
|
||||
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_TOOLTIP_BOOLEAN, true);
|
||||
else if ((flags & SDL_WINDOW_POPUP_MENU) != 0)
|
||||
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_MENU_BOOLEAN, SDL_TRUE);
|
||||
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_MENU_BOOLEAN, true);
|
||||
if (_settings.Parent != nullptr)
|
||||
SDL_SetPointerProperty(props, SDL_PROP_WINDOW_CREATE_PARENT_POINTER, _settings.Parent->_window);
|
||||
|
||||
@@ -509,7 +509,7 @@ void SDLWindow::HandleEvent(SDL_Event& event)
|
||||
if (pos.X < rect.x || pos.Y < rect.y || size.X > rect.w || size.Y > rect.h)
|
||||
{
|
||||
// Disable resizable flag so SDL updates the client rectangle to expected values during WM_NCCALCSIZE
|
||||
SDL_SetWindowResizable(_window, SDL_FALSE);
|
||||
SDL_SetWindowResizable(_window, false);
|
||||
SDL_MaximizeWindow(_window);
|
||||
|
||||
// Set the internal floating window rectangle to expected position
|
||||
@@ -520,7 +520,7 @@ void SDLWindow::HandleEvent(SDL_Event& event)
|
||||
SDL_PumpEvents();
|
||||
|
||||
// Restore previous values
|
||||
SDL_SetWindowResizable(_window, SDL_TRUE);
|
||||
SDL_SetWindowResizable(_window, true);
|
||||
SetClientBounds(_cachedClientRectangle);
|
||||
}
|
||||
}
|
||||
@@ -704,11 +704,11 @@ void SDLWindow::Show()
|
||||
|
||||
// Reused top-most windows (DockHintWindow) doesn't stay on top for some reason
|
||||
if (_settings.IsTopmost && _settings.Type != WindowType::Tooltip)
|
||||
SDL_SetWindowAlwaysOnTop(_window, SDL_TRUE);
|
||||
SDL_SetWindowAlwaysOnTop(_window, true);
|
||||
|
||||
if (_isTrackingMouse)
|
||||
{
|
||||
if (SDL_CaptureMouse(SDL_TRUE) != 0)
|
||||
if (!SDL_CaptureMouse(true))
|
||||
{
|
||||
if (!SDLPlatform::UsesWayland()) // Suppress "That operation is not supported" errors
|
||||
LOG(Warning, "SDL_CaptureMouse: {0}", String(SDL_GetError()));
|
||||
@@ -759,7 +759,7 @@ void SDLWindow::SetBorderless(bool isBorderless, bool maximized)
|
||||
|
||||
if (isBorderless)
|
||||
{
|
||||
SDL_SetWindowBordered(_window, !isBorderless ? SDL_TRUE : SDL_FALSE);
|
||||
SDL_SetWindowBordered(_window, !isBorderless ? true : false);
|
||||
if (maximized)
|
||||
SDL_MaximizeWindow(_window);
|
||||
else
|
||||
@@ -767,7 +767,7 @@ void SDLWindow::SetBorderless(bool isBorderless, bool maximized)
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_SetWindowBordered(_window, !isBorderless ? SDL_TRUE : SDL_FALSE);
|
||||
SDL_SetWindowBordered(_window, !isBorderless ? true : false);
|
||||
if (maximized)
|
||||
SDL_MaximizeWindow(_window);
|
||||
else
|
||||
@@ -839,11 +839,11 @@ void SDLWindow::SetClientPosition(const Float2& position)
|
||||
|
||||
void SDLWindow::SetIsFullscreen(bool isFullscreen)
|
||||
{
|
||||
SDL_SetWindowFullscreen(_window, isFullscreen ? SDL_TRUE : SDL_FALSE);
|
||||
SDL_SetWindowFullscreen(_window, isFullscreen ? true : false);
|
||||
if (!isFullscreen)
|
||||
{
|
||||
// The window is set to always-on-top for some reason when leaving fullscreen
|
||||
SDL_SetWindowAlwaysOnTop(_window, SDL_FALSE);
|
||||
SDL_SetWindowAlwaysOnTop(_window, false);
|
||||
}
|
||||
|
||||
WindowBase::SetIsFullscreen(isFullscreen);
|
||||
@@ -981,7 +981,7 @@ void SDLWindow::StartTrackingMouse(bool useMouseScreenOffset)
|
||||
|
||||
if (_visible)
|
||||
{
|
||||
if (SDL_CaptureMouse(SDL_TRUE) != 0)
|
||||
if (!SDL_CaptureMouse(true))
|
||||
{
|
||||
if (!SDLPlatform::UsesWayland()) // Suppress "That operation is not supported" errors
|
||||
LOG(Warning, "SDL_CaptureMouse: {0}", String(SDL_GetError()));
|
||||
@@ -1002,7 +1002,7 @@ void SDLWindow::EndTrackingMouse()
|
||||
_isHorizontalFlippingMouse = false;
|
||||
_isVerticalFlippingMouse = false;
|
||||
|
||||
if (SDL_CaptureMouse(SDL_FALSE) != 0)
|
||||
if (!SDL_CaptureMouse(false))
|
||||
{
|
||||
if (!SDLPlatform::UsesWayland()) // Suppress "That operation is not supported" errors
|
||||
LOG(Warning, "SDL_CaptureMouse: {0}", String(SDL_GetError()));
|
||||
|
||||
Reference in New Issue
Block a user