Skip to main content

DeviceInput

Enum DeviceInput 

Source
#[non_exhaustive]
pub enum DeviceInput { None, Zapper { x: u16, y: u16, trigger: bool, }, Vaus { position: u8, fire: bool, }, PowerPad(u16), FamilyTrainer(u16), SnesMouse { dx: i16, dy: i16, left: bool, right: bool, sensitivity: u8, }, FamilyKeyboard([u8; 9]), SuborKeyboard([u8; 9]), KonamiHyperShot(u8), BandaiHyperShot(u8), }
Expand description

What one controller port’s expansion device is doing in a movie frame.

One variant per InputDevice kind, holding exactly the fields a host sets through that device’s Nes setter – never the device’s internal shift registers or strobe latch, which the emulation derives. A replay that sets these fields at the same point the host did reproduces the device’s reads.

#[non_exhaustive]: a device added later is an additive change.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

None

No expansion device: the port reads its standard controller (or the Four Score).

§

Zapper

NES Zapper: aim point and trigger (Nes::set_zapper). The light sense is computed from the picture, not recorded.

Fields

§x: u16

Aim X, 0..256 (out of range = aimed off-screen).

§y: u16

Aim Y, 0..240 (out of range = aimed off-screen).

§trigger: bool

Trigger pulled.

§

Vaus

Arkanoid “Vaus” paddle (Nes::set_paddle).

Fields

§position: u8

Raw potentiometer position.

§fire: bool

Fire button held.

§

PowerPad(u16)

NES Power Pad mat: the 12-button mask (Nes::set_power_pad).

§

FamilyTrainer(u16)

Bandai Family Trainer mat: the 12-button mask (Nes::set_family_trainer).

§

SnesMouse

SNES-style mouse (Nes::set_snes_mouse).

Fields

§dx: i16

Delta X as the host set it (clamped by the device on latch).

§dy: i16

Delta Y as the host set it.

§left: bool

Left button held.

§right: bool

Right button held.

§sensitivity: u8

Reported sensitivity, 0..=3 (the device keeps two bits).

§

FamilyKeyboard([u8; 9])

Family BASIC keyboard: one byte per matrix row (Nes::set_family_keyboard).

§

SuborKeyboard([u8; 9])

Subor keyboard: one byte per matrix row (Nes::set_subor_keyboard).

§

KonamiHyperShot(u8)

Konami Hyper Shot: the 4-button mask (Nes::set_konami_hyper_shot).

§

BandaiHyperShot(u8)

Bandai Hyper Shot: the 8-sensor mask (Nes::set_bandai_hyper_shot).

Implementations§

Source§

impl DeviceInput

Source

pub const fn capture(device: &Option<InputDevice>) -> Self

Read the host-set fields of the device attached to a port.

Source

pub fn apply(self, nes: &mut Nes, port: usize)

Drive port of nes to this device input.

A different device kind is attached fresh (exactly what the Nes convenience setters do when the kind is absent); the same kind keeps its internal state and only has its host-set fields written, as the host’s own per-frame call did. Self::None unplugs a device.

§Panics

Panics if port is not 0 or 1.

Trait Implementations§

Source§

impl Clone for DeviceInput

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for DeviceInput

Source§

impl Debug for DeviceInput

Source§

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

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

impl Default for DeviceInput

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for DeviceInput

Source§

impl Hash for DeviceInput

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for DeviceInput

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DeviceInput

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> CloneToUninit for T
where T: Clone,

Source§

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
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.