Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Land stubs for Gamepad.vibrationActuator API
https://bugs.webkit.org/show_bug.cgi?id=250079 Reviewed by Brady Eidson. Land stubs for Gamepad.vibrationActuator API: - https://w3c.github.io/gamepad/extensions.html#gamepadhapticactuator-interface * Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml: * Source/WebCore/CMakeLists.txt: * Source/WebCore/DerivedSources-input.xcfilelist: * Source/WebCore/DerivedSources-output.xcfilelist: * Source/WebCore/DerivedSources.make: * Source/WebCore/Modules/gamepad/Gamepad.cpp: (WebCore::Gamepad::Gamepad): (WebCore::Gamepad::vibrationActuator): * Source/WebCore/Modules/gamepad/Gamepad.h: * Source/WebCore/Modules/gamepad/Gamepad.idl: * Source/WebCore/Modules/gamepad/GamepadEffectParameters.h: Copied from Source/WebCore/Modules/gamepad/Gamepad.idl. * Source/WebCore/Modules/gamepad/GamepadEffectParameters.idl: Copied from Source/WebCore/Modules/gamepad/Gamepad.idl. * Source/WebCore/Modules/gamepad/GamepadHapticActuator.cpp: Copied from Source/WebCore/Modules/gamepad/Gamepad.idl. (WebCore::GamepadHapticActuator::create): (WebCore::GamepadHapticActuator::GamepadHapticActuator): (WebCore::GamepadHapticActuator::canPlayEffectType const): (WebCore::GamepadHapticActuator::playEffect): (WebCore::GamepadHapticActuator::reset): * Source/WebCore/Modules/gamepad/GamepadHapticActuator.h: Copied from Source/WebCore/Modules/gamepad/Gamepad.idl. (WebCore::GamepadHapticActuator::type const): * Source/WebCore/Modules/gamepad/GamepadHapticActuator.idl: Copied from Source/WebCore/Modules/gamepad/Gamepad.idl. * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/bindings/js/WebCoreBuiltinNames.h: Canonical link: https://commits.webkit.org/258482@main
- Loading branch information
Showing
17 changed files
with
316 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#if ENABLE(GAMEPAD) | ||
|
||
namespace WebCore { | ||
|
||
struct GamepadEffectParameters { | ||
double duration = 0.0; | ||
double startDelay = 0.0; | ||
double strongMagnitude = 0.0; | ||
double weakMagnitude = 0.0; | ||
}; | ||
|
||
} // namespace WebCore | ||
|
||
#endif // ENABLE(GAMEPAD) |
34 changes: 34 additions & 0 deletions
34
Source/WebCore/Modules/gamepad/GamepadEffectParameters.idl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
[ | ||
Conditional=GAMEPAD, | ||
EnabledBySetting=GamepadVibrationActuatorEnabled | ||
] dictionary GamepadEffectParameters { | ||
double duration = 0.0; | ||
double startDelay = 0.0; | ||
double strongMagnitude = 0.0; | ||
double weakMagnitude = 0.0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
|
||
#if ENABLE(GAMEPAD) | ||
#include "GamepadHapticActuator.h" | ||
|
||
#include "GamepadEffectParameters.h" | ||
#include "JSDOMPromiseDeferred.h" | ||
|
||
namespace WebCore { | ||
|
||
Ref<GamepadHapticActuator> GamepadHapticActuator::create() | ||
{ | ||
return adoptRef(*new GamepadHapticActuator); | ||
} | ||
|
||
GamepadHapticActuator::GamepadHapticActuator() | ||
: m_type { Type::Vibration } | ||
{ | ||
} | ||
|
||
bool GamepadHapticActuator::canPlayEffectType(EffectType) const | ||
{ | ||
return false; | ||
} | ||
|
||
void GamepadHapticActuator::playEffect(EffectType, GamepadEffectParameters&&, Ref<DeferredPromise>&& promise) | ||
{ | ||
promise->reject(Exception { NotSupportedError }); | ||
} | ||
|
||
void GamepadHapticActuator::reset(Ref<DeferredPromise>&& promise) | ||
{ | ||
promise->reject(Exception { NotSupportedError }); | ||
} | ||
|
||
} // namespace WebCore | ||
|
||
#endif // ENABLE(GAMEPAD) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#if ENABLE(GAMEPAD) | ||
|
||
#include <wtf/Forward.h> | ||
#include <wtf/RefCounted.h> | ||
|
||
namespace WebCore { | ||
|
||
class DeferredPromise; | ||
struct GamepadEffectParameters; | ||
|
||
class GamepadHapticActuator : public RefCounted<GamepadHapticActuator> { | ||
public: | ||
static Ref<GamepadHapticActuator> create(); | ||
|
||
enum class Type : uint8_t { Vibration, DualRumble }; | ||
enum class EffectType : uint8_t { DualRumble }; | ||
enum class Result : uint8_t { Complete, Preempted }; | ||
|
||
Type type() const { return m_type; } | ||
bool canPlayEffectType(EffectType) const; | ||
void playEffect(EffectType, GamepadEffectParameters&&, Ref<DeferredPromise>&&); | ||
void reset(Ref<DeferredPromise>&&); | ||
|
||
private: | ||
GamepadHapticActuator(); | ||
|
||
Type m_type; | ||
}; | ||
|
||
} // namespace WebCore | ||
|
||
#endif // ENABLE(GAMEPAD) |
Oops, something went wrong.