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
impl CalibratedGamepad
Sourcepub fn new(slot: usize) -> Result<CalibratedGamepad, CalibrationError>
pub fn new(slot: usize) -> Result<CalibratedGamepad, CalibrationError>
Create a disconnected adapter with no profile. Does not touch the host.
Sourcepub fn slot(&self) -> usize
pub fn slot(&self) -> usize
The fixed journal slot. Host ownership is explicit, not a hardware ID.
Sourcepub fn profile(&self) -> Option<&CalibrationProfile>
pub fn profile(&self) -> Option<&CalibrationProfile>
Selected connection-local profile, or None for existing defaults.
Sourcepub fn last_raw(&self) -> &PadState
pub fn last_raw(&self) -> &PadState
Last accepted uncalibrated sample, neutral when disconnected.
Sourcepub fn submit(&mut self, raw: PadState) -> Result<(), CalibrationError>
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.
Sourcepub fn select_profile(
&mut self,
profile: CalibrationProfile,
) -> Result<(), CalibrationError>
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.
Sourcepub fn reset(&mut self)
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.
Sourcepub fn disconnect(&mut self)
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.