mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 16:58:58 +00:00
LibWeb/Gamepad: Forward declare SDL components to fix Windows build
We have to prevent from including any SDL headers in LibWeb headers. Otherwise there will be transitive Windows.h includes that will re-declare some of our existing forward decls/defines in LibCore/SocketAddressWindows.h
This commit is contained in:
parent
5ce518f493
commit
454e6a6f7f
Notes:
github-actions[bot]
2025-09-02 10:12:35 +00:00
Author: https://github.com/ayeteadoe
Commit: 454e6a6f7f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6046
Reviewed-by: https://github.com/Lubrsi ✅
11 changed files with 39 additions and 17 deletions
|
@ -16,6 +16,8 @@
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/HTML/Window.h>
|
||||||
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
|
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
|
||||||
|
|
||||||
|
#include <SDL3/SDL_gamepad.h>
|
||||||
|
|
||||||
namespace Web::Gamepad {
|
namespace Web::Gamepad {
|
||||||
|
|
||||||
GC_DEFINE_ALLOCATOR(Gamepad);
|
GC_DEFINE_ALLOCATOR(Gamepad);
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
#include <LibWeb/Bindings/GamepadPrototype.h>
|
#include <LibWeb/Bindings/GamepadPrototype.h>
|
||||||
#include <LibWeb/Bindings/PlatformObject.h>
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
#include <LibWeb/Gamepad/SDLGamepadForward.h>
|
||||||
#include <LibWeb/HighResolutionTime/DOMHighResTimeStamp.h>
|
#include <LibWeb/HighResolutionTime/DOMHighResTimeStamp.h>
|
||||||
#include <SDL3/SDL_gamepad.h>
|
|
||||||
|
|
||||||
namespace Web::Gamepad {
|
namespace Web::Gamepad {
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include <LibWeb/Bindings/Intrinsics.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/Gamepad/GamepadButton.h>
|
#include <LibWeb/Gamepad/GamepadButton.h>
|
||||||
|
|
||||||
|
#include <SDL3/SDL_gamepad.h>
|
||||||
|
|
||||||
namespace Web::Gamepad {
|
namespace Web::Gamepad {
|
||||||
|
|
||||||
GC_DEFINE_ALLOCATOR(GamepadButton);
|
GC_DEFINE_ALLOCATOR(GamepadButton);
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/Bindings/PlatformObject.h>
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
#include <SDL3/SDL_gamepad.h>
|
|
||||||
|
|
||||||
namespace Web::Gamepad {
|
namespace Web::Gamepad {
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/HTML/Window.h>
|
||||||
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
|
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
|
||||||
|
|
||||||
|
#include <SDL3/SDL_gamepad.h>
|
||||||
|
|
||||||
namespace Web::Gamepad {
|
namespace Web::Gamepad {
|
||||||
|
|
||||||
// https://w3c.github.io/gamepad/#dom-navigator-getgamepads
|
// https://w3c.github.io/gamepad/#dom-navigator-getgamepads
|
||||||
|
|
|
@ -9,10 +9,9 @@
|
||||||
#include <LibGC/Ptr.h>
|
#include <LibGC/Ptr.h>
|
||||||
#include <LibGC/RootVector.h>
|
#include <LibGC/RootVector.h>
|
||||||
#include <LibWeb/Forward.h>
|
#include <LibWeb/Forward.h>
|
||||||
|
#include <LibWeb/Gamepad/SDLGamepadForward.h>
|
||||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||||
|
|
||||||
#include <SDL3/SDL_gamepad.h>
|
|
||||||
|
|
||||||
namespace Web::Gamepad {
|
namespace Web::Gamepad {
|
||||||
|
|
||||||
class NavigatorGamepadPartial {
|
class NavigatorGamepadPartial {
|
||||||
|
|
16
Libraries/LibWeb/Gamepad/SDLGamepadForward.h
Normal file
16
Libraries/LibWeb/Gamepad/SDLGamepadForward.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, ayeteadoe <ayeteadoe@gmail.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/Types.h>
|
||||||
|
|
||||||
|
typedef uint32_t Uint32;
|
||||||
|
typedef Uint32 SDL_JoystickID;
|
||||||
|
|
||||||
|
typedef struct SDL_Joystick SDL_Joystick;
|
||||||
|
|
||||||
|
typedef struct SDL_Gamepad SDL_Gamepad;
|
|
@ -8,11 +8,14 @@
|
||||||
#include <LibWeb/Bindings/Intrinsics.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/Internals/InternalGamepad.h>
|
#include <LibWeb/Internals/InternalGamepad.h>
|
||||||
|
|
||||||
|
#include <SDL3/SDL_gamepad.h>
|
||||||
|
#include <SDL3/SDL_joystick.h>
|
||||||
|
|
||||||
namespace Web::Internals {
|
namespace Web::Internals {
|
||||||
|
|
||||||
GC_DEFINE_ALLOCATOR(InternalGamepad);
|
GC_DEFINE_ALLOCATOR(InternalGamepad);
|
||||||
|
|
||||||
static constexpr Array<SDL_GamepadButton, 15> BUTTONS = {
|
static constexpr Array<i32, 15> BUTTONS = {
|
||||||
SDL_GAMEPAD_BUTTON_SOUTH,
|
SDL_GAMEPAD_BUTTON_SOUTH,
|
||||||
SDL_GAMEPAD_BUTTON_EAST,
|
SDL_GAMEPAD_BUTTON_EAST,
|
||||||
SDL_GAMEPAD_BUTTON_WEST,
|
SDL_GAMEPAD_BUTTON_WEST,
|
||||||
|
@ -30,14 +33,14 @@ static constexpr Array<SDL_GamepadButton, 15> BUTTONS = {
|
||||||
SDL_GAMEPAD_BUTTON_GUIDE,
|
SDL_GAMEPAD_BUTTON_GUIDE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr Array<SDL_GamepadAxis, 4> AXES {
|
static constexpr Array<i32, 4> AXES {
|
||||||
SDL_GAMEPAD_AXIS_LEFTX,
|
SDL_GAMEPAD_AXIS_LEFTX,
|
||||||
SDL_GAMEPAD_AXIS_LEFTY,
|
SDL_GAMEPAD_AXIS_LEFTY,
|
||||||
SDL_GAMEPAD_AXIS_RIGHTX,
|
SDL_GAMEPAD_AXIS_RIGHTX,
|
||||||
SDL_GAMEPAD_AXIS_RIGHTY,
|
SDL_GAMEPAD_AXIS_RIGHTY,
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr Array<SDL_GamepadAxis, 2> TRIGGERS {
|
static constexpr Array<i32, 2> TRIGGERS {
|
||||||
SDL_GAMEPAD_AXIS_LEFT_TRIGGER,
|
SDL_GAMEPAD_AXIS_LEFT_TRIGGER,
|
||||||
SDL_GAMEPAD_AXIS_RIGHT_TRIGGER,
|
SDL_GAMEPAD_AXIS_RIGHT_TRIGGER,
|
||||||
};
|
};
|
||||||
|
@ -112,17 +115,17 @@ void InternalGamepad::finalize()
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
Array<SDL_GamepadButton, 15> const& InternalGamepad::buttons()
|
Array<i32, 15> const& InternalGamepad::buttons()
|
||||||
{
|
{
|
||||||
return BUTTONS;
|
return BUTTONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array<SDL_GamepadAxis, 4> const& InternalGamepad::axes()
|
Array<i32, 4> const& InternalGamepad::axes()
|
||||||
{
|
{
|
||||||
return AXES;
|
return AXES;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array<SDL_GamepadAxis, 2> const& InternalGamepad::triggers()
|
Array<i32, 2> const& InternalGamepad::triggers()
|
||||||
{
|
{
|
||||||
return TRIGGERS;
|
return TRIGGERS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/Bindings/PlatformObject.h>
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
#include <SDL3/SDL_gamepad.h>
|
#include <LibWeb/Gamepad/SDLGamepadForward.h>
|
||||||
#include <SDL3/SDL_joystick.h>
|
|
||||||
|
|
||||||
namespace Web::Internals {
|
namespace Web::Internals {
|
||||||
|
|
||||||
|
@ -21,9 +20,9 @@ public:
|
||||||
|
|
||||||
virtual ~InternalGamepad() override;
|
virtual ~InternalGamepad() override;
|
||||||
|
|
||||||
Array<SDL_GamepadButton, 15> const& buttons();
|
Array<i32, 15> const& buttons();
|
||||||
Array<SDL_GamepadAxis, 4> const& axes();
|
Array<i32, 4> const& axes();
|
||||||
Array<SDL_GamepadAxis, 2> const& triggers();
|
Array<i32, 2> const& triggers();
|
||||||
|
|
||||||
void set_button(int button, bool down);
|
void set_button(int button, bool down);
|
||||||
void set_axis(int axis, short value);
|
void set_axis(int axis, short value);
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <LibWeb/UIEvents/WheelEvent.h>
|
#include <LibWeb/UIEvents/WheelEvent.h>
|
||||||
|
|
||||||
#include <SDL3/SDL_events.h>
|
#include <SDL3/SDL_events.h>
|
||||||
|
#include <SDL3/SDL_joystick.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,12 @@
|
||||||
#include <LibUnicode/Forward.h>
|
#include <LibUnicode/Forward.h>
|
||||||
#include <LibWeb/Export.h>
|
#include <LibWeb/Export.h>
|
||||||
#include <LibWeb/Forward.h>
|
#include <LibWeb/Forward.h>
|
||||||
|
#include <LibWeb/Gamepad/SDLGamepadForward.h>
|
||||||
#include <LibWeb/Page/EventResult.h>
|
#include <LibWeb/Page/EventResult.h>
|
||||||
#include <LibWeb/Page/InputEvent.h>
|
#include <LibWeb/Page/InputEvent.h>
|
||||||
#include <LibWeb/PixelUnits.h>
|
#include <LibWeb/PixelUnits.h>
|
||||||
#include <LibWeb/UIEvents/KeyCode.h>
|
#include <LibWeb/UIEvents/KeyCode.h>
|
||||||
|
|
||||||
#include <SDL3/SDL_joystick.h>
|
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
class WEB_API EventHandler {
|
class WEB_API EventHandler {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue