Struct CalibratedGamepad

Source
pub struct CalibratedGamepad { /* private fields */ }
Expand description

Explicit embedding-host adapter for one slot. No automatic device association, global selection, hidden native polling, allocations or button synthesis. It retains one last-good raw sample for immediate profile changes/reset. Errors preserve that sample, selection and existing journal state. Like super::gamepad_sample, success means accepted submission, not consumption; normal journal capacity/focus rules and PlayerInput held suppression still apply.

Implementations§

Source§

impl CalibratedGamepad

Source

pub fn new(slot: usize) -> Result<CalibratedGamepad, CalibrationError>

Create a disconnected adapter with no profile. Does not touch the host.

Source

pub fn slot(&self) -> usize

The fixed journal slot. Host ownership is explicit, not a hardware ID.

Source

pub fn profile(&self) -> Option<&CalibrationProfile>

Selected connection-local profile, or None for existing defaults.

Source

pub fn last_raw(&self) -> &PadState

Last accepted uncalibrated sample, neutral when disconnected.

Source

pub fn submit(&mut self, raw: PadState) -> Result<(), CalibrationError>

Calibrate exactly once and submit through super::gamepad_sample. A disconnect or changed supplied epoch clears selection; a changed epoch also submits a disconnect/reconnect so existing PlayerInput held suppression applies. A new connection starts with defaults until explicitly selected again. Invalid connected samples do not clear selection, even when their epoch changed: no part of an invalid sample is accepted. A disconnected sample always succeeds.

Source

pub fn select_profile( &mut self, profile: CalibrationProfile, ) -> Result<(), CalibrationError>

Select for the current connection and immediately reapply the last raw sample, including neutral axes. Replacing pairs cannot leave old axes stuck, and unchanged buttons generate no new journal edges. Fails while disconnected; profiles cannot silently wait for an unknown next device.

Source

pub fn reset(&mut self)

Clear selection and immediately resubmit the last raw sample using default clamping. Does not disconnect, erase held buttons, or consume tick edges.

Source

pub fn disconnect(&mut self)

Explicitly end this device’s slot ownership: neutralize the journal and forget both profile and last raw sample. Repeated calls are harmless. Call before replacing hardware when no physical disconnect was observed.

Trait Implementations§

Source§

impl Debug for CalibratedGamepad

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.