Skip to main content

InputData

Struct InputData 

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

The controller input stream from a Mario Kart Wii RKG ghost file.

Stores the raw bytes (compressed or decompressed) alongside three decoded run-length encoded input streams: face buttons, analog stick, and D-pad. Adjacent identical entries across byte boundaries are merged during parsing so that each entry in the decoded vectors represents a single contiguous hold period.

The binary layout is documented at https://wiki.tockdom.com/wiki/RKG_(File_Format)#Controller_Input_Data.

Implementations§

Source§

impl InputData

Source

pub fn new(input_data: &[u8]) -> Result<Self, InputDataError>

Parses controller input data from raw RKG bytes starting at offset 0x88.

If the bytes beginning at offset 4 carry a Yaz1 magic header, the data is decompressed before parsing. Otherwise the slice is zero-padded to 0x2774 bytes. After parsing, adjacent identical face and stick entries are merged to represent each continuous hold as a single entry.

§Errors

Returns an InputDataError variant if any individual input entry fails to parse.

Source

pub fn inputs(&self) -> Vec<Input>

Returns the three input streams merged into a single frame-accurate sequence of Input values.

The face, stick, and D-pad streams are interleaved by advancing through all three simultaneously and emitting a new Input whenever any stream transitions to its next entry. Each emitted Input covers exactly the frames until the next transition across any stream.

Source

pub fn contains_illegal_brake_or_drift_inputs(&self) -> bool

Returns true if the face input stream contains an illegal drift or brake input.

An input is illegal if drift is active without brake, or if brake and accelerator are pressed simultaneously without drift when the previous frame had accelerator but not brake (indicating a missing drift flag).

Source

pub fn is_compressed(&self) -> bool

Returns true if the raw input data begins with a Yaz1 magic header at offset 4.

Source

pub fn raw_data(&self) -> &[u8]

Returns the raw input data bytes as they appear in the file.

Source

pub fn contains_illegal_stick_inputs(&self, controller: Controller) -> bool

Returns true if the stick input stream contains any illegal stick position for the given controller type. More info on illegal input ranges here: https://github.com/malleoz/mkw-replay?tab=readme-ov-file#regarding-input-ranges https://youtu.be/KUjS7qWWu9c?t=489

The Wii Wheel has a fully unrestricted input range and is never considered to have illegal inputs.

Source

pub fn face_inputs(&self) -> &[FaceInput]

Returns the decoded face button input stream.

Source

pub fn stick_inputs(&self) -> &[StickInput]

Returns the decoded analog stick input stream.

Source

pub fn dpad_inputs(&self) -> &[DPadInput]

Returns the decoded D-pad input stream.

Source

pub fn face_input_count(&self) -> u16

Returns the number of face input entries as recorded in the stream header.

Source

pub fn stick_input_count(&self) -> u16

Returns the number of stick input entries as recorded in the stream header.

Source

pub fn dpad_input_count(&self) -> u16

Returns the number of D-pad input entries as recorded in the stream header.

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> Same for T

Source§

type Output = T

Should always be Self
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.