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

Profile

Struct Profile 

Source
pub struct Profile<const ACTIONS: usize, const SCORES: usize> {
    pub brightness: u8,
    pub sfx_volume: u8,
    pub music_volume: u8,
    pub move_deadzone: u8,
    pub look_deadzone: u8,
    pub look_speed_percent: u8,
    pub difficulty: u8,
    pub flags: u8,
    pub actions: ActionMap<ACTIONS>,
    pub high_scores: [u32; SCORES],
}
Expand description

A game profile shared by menus, input and memory-card persistence.

ACTIONS is the number of game-defined logical actions. SCORES is the number of high-score slots (usually one per difficulty).

Fields§

§brightness: u8

Display brightness, 0..=100.

§sfx_volume: u8

Sound-effect volume, 0..=100.

§music_volume: u8

Music volume, 0..=100.

§move_deadzone: u8

Left-stick deadzone in raw stick counts.

§look_deadzone: u8

Right-stick deadzone in raw stick counts.

§look_speed_percent: u8

Look-speed percentage.

§difficulty: u8

Game-selected difficulty index.

§flags: u8

Bit flags such as FLAG_INVERT_Y.

§actions: ActionMap<ACTIONS>

Logical action bindings.

§high_scores: [u32; SCORES]

Persistent high-score slots.

Implementations§

Source§

impl<const ACTIONS: usize, const SCORES: usize> Profile<ACTIONS, SCORES>

Source

pub const fn new(actions: ActionMap<ACTIONS>) -> Self

Construct a profile with common presentation/input defaults and the caller’s game-specific action map.

Source

pub const fn encoded_len() -> usize

Exact encoded byte length for this profile shape.

Source

pub fn sanitize(&mut self)

Clamp user-controlled values to safe shared ranges.

Source

pub const fn invert_y(&self) -> bool

Whether vertical look is inverted.

Source

pub fn set_invert_y(&mut self, enabled: bool)

Enable or disable inverted vertical look.

Source

pub fn submit_score(&mut self, slot: usize, score: u32) -> bool

Raise one high-score slot when score beats it. Returns true if the profile changed and should be persisted.

Source

pub fn encode(&self, out: &mut [u8]) -> Result<usize, CodecError>

Encode into out, returning the bytes used.

Source

pub fn decode(bytes: &[u8]) -> Result<Self, CodecError>

Decode a profile of this exact action/score shape.

Trait Implementations§

Source§

impl<const ACTIONS: usize, const SCORES: usize> Clone for Profile<ACTIONS, SCORES>

Source§

fn clone(&self) -> Profile<ACTIONS, SCORES>

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<const ACTIONS: usize, const SCORES: usize> Debug for Profile<ACTIONS, SCORES>

Source§

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

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

impl<const ACTIONS: usize, const SCORES: usize> PartialEq for Profile<ACTIONS, SCORES>

Source§

fn eq(&self, other: &Profile<ACTIONS, SCORES>) -> 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<const ACTIONS: usize, const SCORES: usize> Copy for Profile<ACTIONS, SCORES>

Source§

impl<const ACTIONS: usize, const SCORES: usize> Eq for Profile<ACTIONS, SCORES>

Source§

impl<const ACTIONS: usize, const SCORES: usize> StructuralPartialEq for Profile<ACTIONS, SCORES>

Auto Trait Implementations§

§

impl<const ACTIONS: usize, const SCORES: usize> Freeze for Profile<ACTIONS, SCORES>

§

impl<const ACTIONS: usize, const SCORES: usize> RefUnwindSafe for Profile<ACTIONS, SCORES>

§

impl<const ACTIONS: usize, const SCORES: usize> Send for Profile<ACTIONS, SCORES>

§

impl<const ACTIONS: usize, const SCORES: usize> Sync for Profile<ACTIONS, SCORES>

§

impl<const ACTIONS: usize, const SCORES: usize> Unpin for Profile<ACTIONS, SCORES>

§

impl<const ACTIONS: usize, const SCORES: usize> UnsafeUnpin for Profile<ACTIONS, SCORES>

§

impl<const ACTIONS: usize, const SCORES: usize> UnwindSafe for Profile<ACTIONS, SCORES>

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.