Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Deadzone

Struct Deadzone 

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

A radial dead region around stick centre, with the scaled response the literature settles on.

Three games on the PSoXide demo disc had grown one of these and they did not agree. hl-psx tests x*x + y*y against a squared radius. VoXide gates each axis separately, which makes its dead region a square: a stick pushed gently along a diagonal clears the threshold on one axis and not the other, so the input snaps to a cardinal instead of going where it was pushed. Sutphin’s write-up calls that the axial dead zone and its snapping is the classic complaint about it.

A stick’s centre drift is radial, so the region that ignores it is a circle, and Deadzone::scaled is the scaled-radial form: remapped so the first real reading starts from zero rather than jumping to the boundary magnitude. That is the recommended default. Deadzone::gate is the plain radial one, kept because the games being replaced were tuned against it.

This is for two-axis input. A single-axis control is a different question and a scalar threshold is right for it: NitroXide steers on the left stick’s X alone, and folding Y into the test there would let noise on an axis it does not read enable steering. See Deadzone::is_outside_axis.

Implementations§

Source§

impl Deadzone

Source

pub const fn new(radius: i16) -> Self

A dead region of radius counts around centre. Typical radii are 12 to 30 of the 127 counts a healthy stick reaches. A negative radius is no dead region (zero): the squared test would otherwise treat it as its absolute value while scaled divided by a zero length.

Source

pub const fn with_outer(self, outer: i16) -> Self

Treat any deflection at or beyond outer as full scale.

A worn stick often cannot reach its corners, so without this the player simply never gets full input. Sutphin recommends exposing it as a setting for anything where magnitude matters.

Source

pub const fn radius(self) -> i16

The inner radius this was built with.

Source

pub const fn is_outside(self, x: i16, y: i16) -> bool

Is this reading real input rather than centre drift?

Strictly outside, matching the boundary behaviour of the games this replaces.

Source

pub const fn gate(self, x: i16, y: i16) -> Option<(i16, i16)>

The reading unchanged if it is real input, or None inside the dead region. The plain radial form: direction is preserved, but magnitude jumps from zero to the boundary the moment it is crossed.

Source

pub fn scaled(self, x: i16, y: i16) -> Option<(i16, i16)>

Scaled radial: None inside the dead region, otherwise the reading with its magnitude remapped from the dead edge onto full scale, keeping direction.

The result is clamped to STICK_FULL per axis. Without that a full diagonal, which is 179 counts long rather than 127, remaps to 138 on each axis and hands the game 9% more than it believes the stick can produce.

Source

pub const fn is_outside_axis(self, v: i16) -> bool

The one-axis form, for a control that reads a single axis.

Source

pub const fn scaled_axis(self, v: i16) -> Option<i16>

The one-axis form of Deadzone::scaled.

Trait Implementations§

Source§

impl Clone for Deadzone

Source§

fn clone(&self) -> Deadzone

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Deadzone

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Deadzone

Source§

fn eq(&self, other: &Deadzone) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Deadzone

Source§

impl Eq for Deadzone

Source§

impl StructuralPartialEq for Deadzone

Auto Trait Implementations§

§

impl Freeze for Deadzone

§

impl RefUnwindSafe for Deadzone

§

impl Send for Deadzone

§

impl Sync for Deadzone

§

impl Unpin for Deadzone

§

impl UnsafeUnpin for Deadzone

§

impl UnwindSafe for Deadzone

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.