mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-03 06:39:07 +00:00
LibWeb: Stub Navigator.getGamepads()
This commit is contained in:
parent
cdb736bea5
commit
526615bc10
Notes:
github-actions[bot]
2025-07-22 15:56:34 +00:00
Author: https://github.com/gmta
Commit: 526615bc10
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5562
13 changed files with 157 additions and 0 deletions
|
@ -346,6 +346,8 @@ set(SOURCES
|
||||||
FileAPI/FileList.cpp
|
FileAPI/FileList.cpp
|
||||||
FileAPI/FileReader.cpp
|
FileAPI/FileReader.cpp
|
||||||
FileAPI/FileReaderSync.cpp
|
FileAPI/FileReaderSync.cpp
|
||||||
|
Gamepad/Gamepad.cpp
|
||||||
|
Gamepad/NavigatorGamepad.cpp
|
||||||
Geolocation/Geolocation.cpp
|
Geolocation/Geolocation.cpp
|
||||||
Geolocation/GeolocationCoordinates.cpp
|
Geolocation/GeolocationCoordinates.cpp
|
||||||
Geolocation/GeolocationPosition.cpp
|
Geolocation/GeolocationPosition.cpp
|
||||||
|
|
|
@ -489,6 +489,12 @@ class FileList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::Gamepad {
|
||||||
|
|
||||||
|
class Gamepad;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
namespace Web::Geolocation {
|
namespace Web::Geolocation {
|
||||||
|
|
||||||
class Geolocation;
|
class Geolocation;
|
||||||
|
|
24
Libraries/LibWeb/Gamepad/Gamepad.cpp
Normal file
24
Libraries/LibWeb/Gamepad/Gamepad.cpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/GamepadPrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
|
#include <LibWeb/Gamepad/Gamepad.h>
|
||||||
|
|
||||||
|
namespace Web::Gamepad {
|
||||||
|
|
||||||
|
Gamepad::Gamepad(JS::Realm& realm)
|
||||||
|
: PlatformObject(realm)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gamepad::initialize(JS::Realm& realm)
|
||||||
|
{
|
||||||
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(Gamepad);
|
||||||
|
Base::initialize(realm);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
24
Libraries/LibWeb/Gamepad/Gamepad.h
Normal file
24
Libraries/LibWeb/Gamepad/Gamepad.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
|
||||||
|
namespace Web::Gamepad {
|
||||||
|
|
||||||
|
// https://w3c.github.io/gamepad/#dom-gamepad
|
||||||
|
class Gamepad : public Bindings::PlatformObject {
|
||||||
|
WEB_PLATFORM_OBJECT(Gamepad, Bindings::PlatformObject);
|
||||||
|
GC_DECLARE_ALLOCATOR(Gamepad);
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit Gamepad(JS::Realm&);
|
||||||
|
|
||||||
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
19
Libraries/LibWeb/Gamepad/Gamepad.idl
Normal file
19
Libraries/LibWeb/Gamepad/Gamepad.idl
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// https://w3c.github.io/gamepad/#dom-gamepad
|
||||||
|
[Exposed=Window]
|
||||||
|
interface Gamepad {
|
||||||
|
[FIXME] readonly attribute DOMString id;
|
||||||
|
[FIXME] readonly attribute long index;
|
||||||
|
[FIXME] readonly attribute boolean connected;
|
||||||
|
[FIXME] readonly attribute DOMHighResTimeStamp timestamp;
|
||||||
|
[FIXME] readonly attribute GamepadMappingType mapping;
|
||||||
|
[FIXME] readonly attribute FrozenArray<double> axes;
|
||||||
|
[FIXME] readonly attribute FrozenArray<GamepadButton> buttons;
|
||||||
|
[FIXME] readonly attribute FrozenArray<GamepadTouch> touches;
|
||||||
|
[FIXME, SameObject] readonly attribute GamepadHapticActuator vibrationActuator;
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://w3c.github.io/gamepad/#idl-def-navigator-partial-1
|
||||||
|
[Exposed=Window]
|
||||||
|
partial interface Navigator {
|
||||||
|
sequence<Gamepad?> getGamepads();
|
||||||
|
};
|
49
Libraries/LibWeb/Gamepad/NavigatorGamepad.cpp
Normal file
49
Libraries/LibWeb/Gamepad/NavigatorGamepad.cpp
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <AK/TypeCasts.h>
|
||||||
|
#include <LibWeb/Gamepad/Gamepad.h>
|
||||||
|
#include <LibWeb/Gamepad/NavigatorGamepad.h>
|
||||||
|
#include <LibWeb/HTML/Navigator.h>
|
||||||
|
|
||||||
|
namespace Web::Gamepad {
|
||||||
|
|
||||||
|
// https://w3c.github.io/gamepad/#dom-navigator-getgamepads
|
||||||
|
WebIDL::ExceptionOr<GC::RootVector<GC::Ptr<Gamepad>>> NavigatorGamepadPartial::get_gamepads()
|
||||||
|
{
|
||||||
|
auto& navigator = as<HTML::Navigator>(*this);
|
||||||
|
|
||||||
|
// FIXME: 1. Let doc be the current global object's associated Document.
|
||||||
|
|
||||||
|
// FIXME: 2. If doc is null or doc is not fully active, then return an empty list.
|
||||||
|
|
||||||
|
// FIXME: 3. If doc is not allowed to use the "gamepad" permission, then throw a "SecurityError" DOMException and abort
|
||||||
|
// these steps.
|
||||||
|
|
||||||
|
// FIXME: 4. If this.[[hasGamepadGesture]] is false, then return an empty list.
|
||||||
|
|
||||||
|
// FIXME: 5. Let now be the current high resolution time given the current global object.
|
||||||
|
|
||||||
|
// FIXME: 6. Let gamepads be an empty list.
|
||||||
|
|
||||||
|
// FIXME: 7. For each gamepad of this.[[gamepads]]:
|
||||||
|
{
|
||||||
|
// FIXME: 1. If gamepad is not null and gamepad.[[exposed]] is false:
|
||||||
|
if (false) {
|
||||||
|
// FIXME: 1. Set gamepad.[[exposed]] to true.
|
||||||
|
|
||||||
|
// FIXME: 2. Set gamepad.[[timestamp]] to now.
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: 2. Append gamepad to gamepads.
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: 8. Return gamepads.
|
||||||
|
dbgln("FIXME: Unimplemented NavigatorGamepadPartial::get_gamepads()");
|
||||||
|
return GC::RootVector<GC::Ptr<Gamepad>> { navigator.heap() };
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
26
Libraries/LibWeb/Gamepad/NavigatorGamepad.h
Normal file
26
Libraries/LibWeb/Gamepad/NavigatorGamepad.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibGC/Ptr.h>
|
||||||
|
#include <LibGC/RootVector.h>
|
||||||
|
#include <LibWeb/Forward.h>
|
||||||
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||||
|
|
||||||
|
namespace Web::Gamepad {
|
||||||
|
|
||||||
|
class NavigatorGamepadPartial {
|
||||||
|
public:
|
||||||
|
WebIDL::ExceptionOr<GC::RootVector<GC::Ptr<Gamepad>>> get_gamepads();
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual ~NavigatorGamepadPartial() = default;
|
||||||
|
|
||||||
|
friend class HTML::Navigator;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/Bindings/PlatformObject.h>
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
#include <LibWeb/Gamepad/NavigatorGamepad.h>
|
||||||
#include <LibWeb/HTML/MimeTypeArray.h>
|
#include <LibWeb/HTML/MimeTypeArray.h>
|
||||||
#include <LibWeb/HTML/NavigatorBeacon.h>
|
#include <LibWeb/HTML/NavigatorBeacon.h>
|
||||||
#include <LibWeb/HTML/NavigatorConcurrentHardware.h>
|
#include <LibWeb/HTML/NavigatorConcurrentHardware.h>
|
||||||
|
@ -25,6 +26,7 @@ class Navigator : public Bindings::PlatformObject
|
||||||
, public NavigatorBeaconPartial
|
, public NavigatorBeaconPartial
|
||||||
, public NavigatorConcurrentHardwareMixin
|
, public NavigatorConcurrentHardwareMixin
|
||||||
, public NavigatorDeviceMemoryMixin
|
, public NavigatorDeviceMemoryMixin
|
||||||
|
, public Gamepad::NavigatorGamepadPartial
|
||||||
, public NavigatorIDMixin
|
, public NavigatorIDMixin
|
||||||
, public NavigatorLanguageMixin
|
, public NavigatorLanguageMixin
|
||||||
, public NavigatorOnLineMixin
|
, public NavigatorOnLineMixin
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#import <Clipboard/Clipboard.idl>
|
#import <Clipboard/Clipboard.idl>
|
||||||
#import <CredentialManagement/CredentialsContainer.idl>
|
#import <CredentialManagement/CredentialsContainer.idl>
|
||||||
|
#import <Gamepad/Gamepad.idl>
|
||||||
#import <Geolocation/Geolocation.idl>
|
#import <Geolocation/Geolocation.idl>
|
||||||
#import <HTML/MimeTypeArray.idl>
|
#import <HTML/MimeTypeArray.idl>
|
||||||
#import <HTML/NavigatorBeacon.idl>
|
#import <HTML/NavigatorBeacon.idl>
|
||||||
|
|
|
@ -105,6 +105,7 @@ libweb_js_bindings(FileAPI/File)
|
||||||
libweb_js_bindings(FileAPI/FileList)
|
libweb_js_bindings(FileAPI/FileList)
|
||||||
libweb_js_bindings(FileAPI/FileReader)
|
libweb_js_bindings(FileAPI/FileReader)
|
||||||
libweb_js_bindings(FileAPI/FileReaderSync)
|
libweb_js_bindings(FileAPI/FileReaderSync)
|
||||||
|
libweb_js_bindings(Gamepad/Gamepad)
|
||||||
libweb_js_bindings(Geolocation/Geolocation)
|
libweb_js_bindings(Geolocation/Geolocation)
|
||||||
libweb_js_bindings(Geolocation/GeolocationCoordinates)
|
libweb_js_bindings(Geolocation/GeolocationCoordinates)
|
||||||
libweb_js_bindings(Geolocation/GeolocationPosition)
|
libweb_js_bindings(Geolocation/GeolocationPosition)
|
||||||
|
|
|
@ -4784,6 +4784,7 @@ using namespace Web::EntriesAPI;
|
||||||
using namespace Web::EventTiming;
|
using namespace Web::EventTiming;
|
||||||
using namespace Web::Fetch;
|
using namespace Web::Fetch;
|
||||||
using namespace Web::FileAPI;
|
using namespace Web::FileAPI;
|
||||||
|
using namespace Web::Gamepad;
|
||||||
using namespace Web::Geolocation;
|
using namespace Web::Geolocation;
|
||||||
using namespace Web::Geometry;
|
using namespace Web::Geometry;
|
||||||
using namespace Web::HighResolutionTime;
|
using namespace Web::HighResolutionTime;
|
||||||
|
|
|
@ -23,6 +23,7 @@ static constexpr Array libweb_interface_namespaces = {
|
||||||
"Encoding"sv,
|
"Encoding"sv,
|
||||||
"Fetch"sv,
|
"Fetch"sv,
|
||||||
"FileAPI"sv,
|
"FileAPI"sv,
|
||||||
|
"Gamepad"sv,
|
||||||
"Geolocation"sv,
|
"Geolocation"sv,
|
||||||
"Geometry"sv,
|
"Geometry"sv,
|
||||||
"HTML"sv,
|
"HTML"sv,
|
||||||
|
|
|
@ -139,6 +139,7 @@ FormData
|
||||||
FormDataEvent
|
FormDataEvent
|
||||||
Function
|
Function
|
||||||
GainNode
|
GainNode
|
||||||
|
Gamepad
|
||||||
Geolocation
|
Geolocation
|
||||||
GeolocationCoordinates
|
GeolocationCoordinates
|
||||||
GeolocationPosition
|
GeolocationPosition
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue