#[repr(C)]pub struct Gamepad {Show 15 fields
reflector_: Reflector,
gamepad_id: u32,
id: String,
index: Cell<i32>,
connected: Cell<bool>,
timestamp: Cell<f64>,
mapping_type: String,
axes: HeapBufferSource<Float64>,
buttons: Dom<GamepadButtonList>,
pose: Option<Dom<GamepadPose>>,
hand: GamepadHand,
axis_bounds: (f64, f64),
button_bounds: (f64, f64),
exposed: Cell<bool>,
vibration_actuator: Dom<GamepadHapticActuator>,
}
Fields§
§reflector_: Reflector
§gamepad_id: u32
§id: String
§index: Cell<i32>
§connected: Cell<bool>
§timestamp: Cell<f64>
§mapping_type: String
§axes: HeapBufferSource<Float64>
§pose: Option<Dom<GamepadPose>>
§hand: GamepadHand
§axis_bounds: (f64, f64)
§exposed: Cell<bool>
§vibration_actuator: Dom<GamepadHapticActuator>
Implementations§
source§impl Gamepad
impl Gamepad
fn __assert_parent_type(&self)
source§impl Gamepad
impl Gamepad
fn new_inherited( gamepad_id: u32, id: String, index: i32, connected: bool, timestamp: f64, mapping_type: String, buttons: &GamepadButtonList, pose: Option<&GamepadPose>, hand: GamepadHand, axis_bounds: (f64, f64), button_bounds: (f64, f64), vibration_actuator: &GamepadHapticActuator, ) -> Gamepad
pub fn new( global: &GlobalScope, gamepad_id: u32, id: String, mapping_type: String, axis_bounds: (f64, f64), button_bounds: (f64, f64), supported_haptic_effects: GamepadSupportedHapticEffects, xr: bool, can_gc: CanGc, ) -> Root<Dom<Gamepad>>
sourcefn new_with_proto(
global: &GlobalScope,
gamepad_id: u32,
id: String,
mapping_type: String,
axis_bounds: (f64, f64),
button_bounds: (f64, f64),
supported_haptic_effects: GamepadSupportedHapticEffects,
xr: bool,
can_gc: CanGc,
) -> Root<Dom<Gamepad>>
fn new_with_proto( global: &GlobalScope, gamepad_id: u32, id: String, mapping_type: String, axis_bounds: (f64, f64), button_bounds: (f64, f64), supported_haptic_effects: GamepadSupportedHapticEffects, xr: bool, can_gc: CanGc, ) -> Root<Dom<Gamepad>>
When we construct a new gamepad, we initialize the number of buttons and axes corresponding to the “standard” gamepad mapping. The spec says UAs may do this for fingerprint mitigation, and it also happens to simplify implementation https://www.w3.org/TR/gamepad/#fingerprinting-mitigation
source§impl Gamepad
impl Gamepad
pub fn gamepad_id(&self) -> u32
pub fn update_connected( &self, connected: bool, has_gesture: bool, can_gc: CanGc, )
pub fn index(&self) -> i32
pub fn update_index(&self, index: i32)
pub fn update_timestamp(&self, timestamp: f64)
pub fn notify_event(&self, event_type: GamepadEventType, can_gc: CanGc)
sourcefn init_axes(&self)
fn init_axes(&self)
Initialize the number of axes in the “standard” gamepad mapping. https://www.w3.org/TR/gamepad/#dfn-initializing-axes
sourcepub fn map_and_normalize_axes(&self, axis_index: usize, value: f64)
pub fn map_and_normalize_axes(&self, axis_index: usize, value: f64)
sourcepub fn set_exposed(&self, exposed: bool)
pub fn set_exposed(&self, exposed: bool)
pub fn vibration_actuator(&self) -> &GamepadHapticActuator
Trait Implementations§
source§impl DomObjectWrap for Gamepad
impl DomObjectWrap for Gamepad
source§const WRAP: unsafe fn(_: SafeJSContext, _: &GlobalScope, _: Option<HandleObject<'_>>, _: Box<Self>, _: CanGc) -> Root<Dom<Self>> = {dom::bindings::codegen::Bindings::GamepadBinding::Gamepad_Binding::Wrap as for<'a, 'b> unsafe fn(script_runtime::JSContext, &'a dom::globalscope::GlobalScope, std::option::Option<js::rust::Handle<'b, *mut js::jsapi::JSObject>>, std::boxed::Box<dom::gamepad::Gamepad>, script_runtime::CanGc) -> dom::bindings::root::Root<dom::bindings::root::Dom<dom::gamepad::Gamepad>>}
const WRAP: unsafe fn(_: SafeJSContext, _: &GlobalScope, _: Option<HandleObject<'_>>, _: Box<Self>, _: CanGc) -> Root<Dom<Self>> = {dom::bindings::codegen::Bindings::GamepadBinding::Gamepad_Binding::Wrap as for<'a, 'b> unsafe fn(script_runtime::JSContext, &'a dom::globalscope::GlobalScope, std::option::Option<js::rust::Handle<'b, *mut js::jsapi::JSObject>>, std::boxed::Box<dom::gamepad::Gamepad>, script_runtime::CanGc) -> dom::bindings::root::Root<dom::bindings::root::Dom<dom::gamepad::Gamepad>>}
Function pointer to the general wrap function type
source§impl GamepadMethods<DomTypeHolder> for Gamepad
impl GamepadMethods<DomTypeHolder> for Gamepad
fn Id(&self) -> DOMString
fn Index(&self) -> i32
fn Connected(&self) -> bool
fn Timestamp(&self) -> Finite<f64>
fn Mapping(&self) -> DOMString
fn Axes(&self, _cx: JSContext) -> Float64Array
fn Buttons(&self) -> Root<Dom<GamepadButtonList>>
fn VibrationActuator(&self) -> Root<Dom<GamepadHapticActuator>>
fn Hand(&self) -> GamepadHand
fn GetPose(&self) -> Option<Root<Dom<GamepadPose>>>
source§impl IDLInterface for Gamepad
impl IDLInterface for Gamepad
source§impl MallocSizeOf for Gamepad
impl MallocSizeOf for Gamepad
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
source§impl MutDomObject for Gamepad
impl MutDomObject for Gamepad
source§impl ToJSValConvertible for Gamepad
impl ToJSValConvertible for Gamepad
impl Eq for Gamepad
Auto Trait Implementations§
impl !Freeze for Gamepad
impl !RefUnwindSafe for Gamepad
impl !Send for Gamepad
impl !Sync for Gamepad
impl Unpin for Gamepad
impl !UnwindSafe for Gamepad
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
Creates a filterable data provider with the given name for debugging. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert