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
impl InputData
Sourcepub fn new(input_data: &[u8]) -> Result<Self, InputDataError>
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.
Sourcepub fn inputs(&self) -> Vec<Input>
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.
Sourcepub fn contains_illegal_brake_or_drift_inputs(&self) -> bool
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).
Sourcepub fn is_compressed(&self) -> bool
pub fn is_compressed(&self) -> bool
Returns true if the raw input data begins with a Yaz1 magic header at offset 4.
Sourcepub fn contains_illegal_stick_inputs(&self, controller: Controller) -> bool
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.
Sourcepub fn face_inputs(&self) -> &[FaceInput]
pub fn face_inputs(&self) -> &[FaceInput]
Returns the decoded face button input stream.
Sourcepub fn stick_inputs(&self) -> &[StickInput]
pub fn stick_inputs(&self) -> &[StickInput]
Returns the decoded analog stick input stream.
Sourcepub fn dpad_inputs(&self) -> &[DPadInput]
pub fn dpad_inputs(&self) -> &[DPadInput]
Returns the decoded D-pad input stream.
Sourcepub fn face_input_count(&self) -> u16
pub fn face_input_count(&self) -> u16
Returns the number of face input entries as recorded in the stream header.
Sourcepub fn stick_input_count(&self) -> u16
pub fn stick_input_count(&self) -> u16
Returns the number of stick input entries as recorded in the stream header.
Sourcepub fn dpad_input_count(&self) -> u16
pub fn dpad_input_count(&self) -> u16
Returns the number of D-pad input entries as recorded in the stream header.