-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Gamepad vibrationActuator API to web-sys #4098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
brettchalupa
wants to merge
4
commits into
rustwasm:main
from
brettchalupa:gamepads-vibrationActuator
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2ad73e7
Add Gamepad vibrationActuator API to web-sys
brettchalupa dfde727
Add CHANGELOG entrie sfor Gamepad actuators changes
brettchalupa 41062b0
use space instead of tab in GamepadHapticActuator.webidl
brettchalupa 0296a06
move GamepadHapticActuator into unstable
brettchalupa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
118 changes: 118 additions & 0 deletions
118
crates/web-sys/src/features/gen_GamepadEffectParameters.rs
This file contains hidden or 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,118 @@ | ||
#![allow(unused_imports)] | ||
#![allow(clippy::all)] | ||
use super::*; | ||
use wasm_bindgen::prelude::*; | ||
#[wasm_bindgen] | ||
extern "C" { | ||
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = GamepadEffectParameters)] | ||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
#[doc = "The `GamepadEffectParameters` dictionary."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"] | ||
pub type GamepadEffectParameters; | ||
#[doc = "Get the `duration` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"] | ||
#[wasm_bindgen(method, getter = "duration")] | ||
pub fn get_duration(this: &GamepadEffectParameters) -> Option<f64>; | ||
#[doc = "Change the `duration` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"] | ||
#[wasm_bindgen(method, setter = "duration")] | ||
pub fn set_duration(this: &GamepadEffectParameters, val: f64); | ||
#[doc = "Get the `leftTrigger` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"] | ||
#[wasm_bindgen(method, getter = "leftTrigger")] | ||
pub fn get_left_trigger(this: &GamepadEffectParameters) -> Option<f64>; | ||
#[doc = "Change the `leftTrigger` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"] | ||
#[wasm_bindgen(method, setter = "leftTrigger")] | ||
pub fn set_left_trigger(this: &GamepadEffectParameters, val: f64); | ||
#[doc = "Get the `rightTrigger` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"] | ||
#[wasm_bindgen(method, getter = "rightTrigger")] | ||
pub fn get_right_trigger(this: &GamepadEffectParameters) -> Option<f64>; | ||
#[doc = "Change the `rightTrigger` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"] | ||
#[wasm_bindgen(method, setter = "rightTrigger")] | ||
pub fn set_right_trigger(this: &GamepadEffectParameters, val: f64); | ||
#[doc = "Get the `startDelay` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"] | ||
#[wasm_bindgen(method, getter = "startDelay")] | ||
pub fn get_start_delay(this: &GamepadEffectParameters) -> Option<f64>; | ||
#[doc = "Change the `startDelay` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"] | ||
#[wasm_bindgen(method, setter = "startDelay")] | ||
pub fn set_start_delay(this: &GamepadEffectParameters, val: f64); | ||
#[doc = "Get the `strongMagnitude` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"] | ||
#[wasm_bindgen(method, getter = "strongMagnitude")] | ||
pub fn get_strong_magnitude(this: &GamepadEffectParameters) -> Option<f64>; | ||
#[doc = "Change the `strongMagnitude` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"] | ||
#[wasm_bindgen(method, setter = "strongMagnitude")] | ||
pub fn set_strong_magnitude(this: &GamepadEffectParameters, val: f64); | ||
#[doc = "Get the `weakMagnitude` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"] | ||
#[wasm_bindgen(method, getter = "weakMagnitude")] | ||
pub fn get_weak_magnitude(this: &GamepadEffectParameters) -> Option<f64>; | ||
#[doc = "Change the `weakMagnitude` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"] | ||
#[wasm_bindgen(method, setter = "weakMagnitude")] | ||
pub fn set_weak_magnitude(this: &GamepadEffectParameters, val: f64); | ||
} | ||
impl GamepadEffectParameters { | ||
#[doc = "Construct a new `GamepadEffectParameters`."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"] | ||
pub fn new() -> Self { | ||
#[allow(unused_mut)] | ||
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); | ||
ret | ||
} | ||
#[deprecated = "Use `set_duration()` instead."] | ||
pub fn duration(&mut self, val: f64) -> &mut Self { | ||
self.set_duration(val); | ||
self | ||
} | ||
#[deprecated = "Use `set_left_trigger()` instead."] | ||
pub fn left_trigger(&mut self, val: f64) -> &mut Self { | ||
self.set_left_trigger(val); | ||
self | ||
} | ||
#[deprecated = "Use `set_right_trigger()` instead."] | ||
pub fn right_trigger(&mut self, val: f64) -> &mut Self { | ||
self.set_right_trigger(val); | ||
self | ||
} | ||
#[deprecated = "Use `set_start_delay()` instead."] | ||
pub fn start_delay(&mut self, val: f64) -> &mut Self { | ||
self.set_start_delay(val); | ||
self | ||
} | ||
#[deprecated = "Use `set_strong_magnitude()` instead."] | ||
pub fn strong_magnitude(&mut self, val: f64) -> &mut Self { | ||
self.set_strong_magnitude(val); | ||
self | ||
} | ||
#[deprecated = "Use `set_weak_magnitude()` instead."] | ||
pub fn weak_magnitude(&mut self, val: f64) -> &mut Self { | ||
self.set_weak_magnitude(val); | ||
self | ||
} | ||
} | ||
impl Default for GamepadEffectParameters { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} |
This file contains hidden or 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
12 changes: 12 additions & 0 deletions
12
crates/web-sys/src/features/gen_GamepadHapticEffectType.rs
This file contains hidden or 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,12 @@ | ||
#![allow(unused_imports)] | ||
#![allow(clippy::all)] | ||
use wasm_bindgen::prelude::*; | ||
#[wasm_bindgen] | ||
#[doc = "The `GamepadHapticEffectType` enum."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadHapticEffectType`*"] | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub enum GamepadHapticEffectType { | ||
DualRumble = "dual-rumble", | ||
TriggerRumble = "trigger-rumble", | ||
} |
This file contains hidden or 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,12 @@ | ||
#![allow(unused_imports)] | ||
#![allow(clippy::all)] | ||
use wasm_bindgen::prelude::*; | ||
#[wasm_bindgen] | ||
#[doc = "The `GamepadHapticsResult` enum."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `GamepadHapticsResult`*"] | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub enum GamepadHapticsResult { | ||
Complete = "complete", | ||
Preempted = "preempted", | ||
} |
This file contains hidden or 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 hidden or 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
21 changes: 0 additions & 21 deletions
21
crates/web-sys/webidls/enabled/GamepadHapticActuator.webidl
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
crates/web-sys/webidls/unstable/GamepadHapticActuator.webidl
This file contains hidden or 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,50 @@ | ||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* The origin of this IDL file is | ||
* https://w3c.github.io/gamepad/ | ||
* (Deprecated) https://w3c.github.io/gamepad/extensions.html#gamepadhapticactuator-interface | ||
*/ | ||
|
||
[RustDeprecated] | ||
enum GamepadHapticActuatorType { | ||
"vibration" | ||
}; | ||
|
||
enum GamepadHapticEffectType { | ||
"dual-rumble", | ||
"trigger-rumble" | ||
}; | ||
|
||
enum GamepadHapticsResult { | ||
"complete", | ||
"preempted" | ||
}; | ||
|
||
dictionary GamepadEffectParameters { | ||
unsigned long long duration = 0; | ||
unsigned long long startDelay = 0; | ||
double strongMagnitude = 0.0; | ||
double weakMagnitude = 0.0; | ||
double leftTrigger = 0.0; | ||
double rightTrigger = 0.0; | ||
}; | ||
|
||
[Pref="dom.gamepad.extensions.enabled", | ||
HeaderFile="mozilla/dom/GamepadHapticActuator.h"] | ||
interface GamepadHapticActuator | ||
{ | ||
[RustDeprecated] | ||
readonly attribute GamepadHapticActuatorType type; | ||
[Throws, NewObject, RustDeprecated] | ||
Promise<boolean> pulse(double value, double duration); | ||
Comment on lines
+37
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already stabilized APIs can't simply be made unstable, this would be a breaking change. |
||
|
||
readonly attribute FrozenArray<GamepadHapticEffectType> effects; | ||
Promise<GamepadHapticsResult> playEffect( | ||
GamepadHapticEffectType type, | ||
optional GamepadEffectParameters params = {} | ||
); | ||
Promise<GamepadHapticsResult> reset(); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before, this can't be made unstable without a breaking change anymore.