#[repr(C)]pub(crate) struct Gamepad {Show 17 fields
reflector_: Reflector,
gamepad_id: u32,
id: String,
index: Cell<i32>,
connected: Cell<bool>,
timestamp: Cell<f64>,
mapping_type: String,
frozen_buttons: CachedFrozenArray,
buttons: Vec<Dom<GamepadButton>>,
frozen_axes: CachedFrozenArray,
axes: RefCell<Vec<f64>>,
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§frozen_axes: CachedFrozenArray§axes: RefCell<Vec<f64>>§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: &[&GamepadButton], pose: Option<&GamepadPose>, hand: GamepadHand, axis_bounds: (f64, f64), button_bounds: (f64, f64), vibration_actuator: &GamepadHapticActuator, ) -> Gamepad
Sourcepub(crate) fn new(
cx: &mut JSContext,
window: &Window,
gamepad_id: u32,
id: String,
mapping_type: String,
axis_bounds: (f64, f64),
button_bounds: (f64, f64),
supported_haptic_effects: GamepadSupportedHapticEffects,
xr: bool,
) -> DomRoot<Gamepad>
pub(crate) fn new( cx: &mut JSContext, window: &Window, gamepad_id: u32, id: String, mapping_type: String, axis_bounds: (f64, f64), button_bounds: (f64, f64), supported_haptic_effects: GamepadSupportedHapticEffects, xr: bool, ) -> DomRoot<Gamepad>
From: https://www.w3.org/TR/gamepad/#fingerprinting-mitigation The user agent MAY alter the device information exposed through the API to reduce the fingerprinting surface. As an example, an implementation can require that a Gamepad object have exactly the number of buttons and axes defined in the Standard Gamepad layout even if more or fewer inputs are present on the connected device.
So, we initialize the number of buttons and axes corresponding to the “standard” gamepad mapping and happens to simplify implementation. https://www.w3.org/TR/gamepad/#dfn-a-new-gamepad
Source§impl Gamepad
impl Gamepad
pub(crate) fn gamepad_id(&self) -> u32
Initialize the standard buttons for a gamepad. https://www.w3.org/TR/gamepad/#dfn-initializing-buttons
pub(crate) fn update_connected(&self, connected: bool)
pub(crate) fn index(&self) -> i32
pub(crate) fn update_index(&self, index: i32)
pub(crate) fn update_timestamp(&self, timestamp: f64)
pub(crate) fn notify_event( &self, cx: &mut JSContext, event_type: GamepadEventType, )
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(crate) fn map_and_normalize_axes(&self, axis_index: usize, value: f64)
pub(crate) fn map_and_normalize_axes(&self, axis_index: usize, value: f64)
pub(crate) fn connected(&self) -> bool
Sourcepub(crate) fn set_exposed(&self, exposed: bool)
pub(crate) fn set_exposed(&self, exposed: bool)
pub(crate) fn vibration_actuator(&self) -> &GamepadHapticActuator
Trait Implementations§
Source§impl DomObject for Gamepad
impl DomObject for Gamepad
type ReflectorType = ()
Source§fn reflector(&self) -> &Reflector<Self::ReflectorType>
fn reflector(&self) -> &Reflector<Self::ReflectorType>
Source§impl DomObjectWrap<DomTypeHolder> for Gamepad
impl DomObjectWrap<DomTypeHolder> for Gamepad
Source§impl GamepadMethods<DomTypeHolder> for Gamepad
impl GamepadMethods<DomTypeHolder> for Gamepad
Source§fn Axes(&self, cx: &mut JSContext, retval: MutableHandleValue<'_>)
fn Axes(&self, cx: &mut JSContext, retval: MutableHandleValue<'_>)
Source§fn Buttons(&self, cx: &mut JSContext, retval: MutableHandleValue<'_>)
fn Buttons(&self, cx: &mut JSContext, retval: MutableHandleValue<'_>)
Source§fn VibrationActuator(&self) -> DomRoot<GamepadHapticActuator>
fn VibrationActuator(&self) -> DomRoot<GamepadHapticActuator>
Source§impl IDLInterface for Gamepad
impl IDLInterface for Gamepad
Source§const PROTO_FIRST: u16 = 388
const PROTO_FIRST: u16 = 388
Source§const PROTO_LAST: u16 = 388
const PROTO_LAST: u16 = 388
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
Source§impl MutDomObject for Gamepad
impl MutDomObject for Gamepad
Source§impl ToJSValConvertible for Gamepad
impl ToJSValConvertible for Gamepad
Source§unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue<'_>)
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue<'_>)
self to a JSVal. JSAPI failure causes a panic.Source§fn safe_to_jsval(&self, cx: &mut JSContext, rval: MutableHandle<'_, Value>)
fn safe_to_jsval(&self, cx: &mut JSContext, rval: MutableHandle<'_, Value>)
self to a JSVal. JSAPI failure causes a panic.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 UnsafeUnpin 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
Source§impl<D, T> DomGlobalGeneric<D> for T
impl<D, T> DomGlobalGeneric<D> for T
Source§fn global_from_reflector(&self) -> Root<Dom<<D as DomTypes>::GlobalScope>>where
Self: Sized,
fn global_from_reflector(&self) -> Root<Dom<<D as DomTypes>::GlobalScope>>where
Self: Sized,
GlobalScope] of the realm that the DomObject was created in. If this
object is a Node, this will be different from it’s owning Document if adopted by. For
Nodes it’s almost always better to use NodeTraits::owning_global.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
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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>
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>
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 more