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

Engine

Struct Engine 

Source
pub struct Engine<'p, H: Hw> { /* private fields */ }
Expand description

The state machine. One per console, driven by three events: a VBlank (on_vblank), a device’s /ACK (on_ack) and the deadline timer (on_deadline). The three run with CPU interrupts off. Everything else is for the foreground, which must not overlap them.

Implementations§

Source§

impl<'p, H: Hw> Engine<'p, H>

Source

pub const fn new(hw: H, published: &'p Published, config: Config) -> Self

An idle engine that publishes to published.

Source

pub fn hw(&self) -> &H

The hardware.

Source

pub fn hw_mut(&mut self) -> &mut H

The hardware, mutably.

Source

pub const fn config(&self) -> Config

The settings in force.

Source

pub fn configure(&mut self, config: Config)

Change the settings; they apply from the next transaction.

Source

pub const fn stats(&self) -> Stats

The counters.

Source

pub const fn owner(&self) -> Owner

Who may use the serial port now.

Source

pub fn is_idle(&self) -> bool

Whether no transaction is on the wire.

Source

pub fn publish_readings(&self)

Publish the current readings. A freshly built engine calls this so the snapshot a previous engine left behind does not outlive it: its counters start again from zero.

Source

pub fn snapshot(&self) -> Snapshot

The latest publication.

Source

pub fn on_vblank(&mut self)

A VBlank: start a round of transactions, one per enabled port, unless the port is leased. A round still running is abandoned.

Source

pub fn on_ack(&mut self)

The device’s /ACK pulse raised IRQ7.

Source

pub fn on_deadline(&mut self)

The deadline timer’s interrupt.

Source

pub fn reading(&self, port: Port) -> PortReading

The latest reading of port, ahead of the next publication.

Source

pub fn request_analog(&mut self, port: Port)

Put the pad on port in analog mode and lock it there, one command per VBlank, then check what it settled on. A request made while one is running changes nothing. [analog_outcome] (Self::analog_outcome) answers once that is done.

Source

pub fn enable_rumble(&mut self, port: Port)

Put the motors of the pad on port under the poll: map them, whenever a DualShock in analog mode is there and again each time one is plugged in, and send them set_rumble’s request on every poll from then on. rumble_mapped says whether the pad took it; a digital pad and a pad that refuses configuration mode never do, and are asked once per plug-in.

Source

pub fn disable_rumble(&mut self, port: Port)

Stop wanting the motors on port: they are asked to stop on the next poll, and the pad is not mapped again after a replug.

Source

pub fn set_rumble(&mut self, port: Port, rumble: Rumble)

What the motors on port are asked to do on every poll. Nothing reaches a pad until it is mapped.

Source

pub fn rumble(&self, port: Port) -> Rumble

What the motors on port are asked for.

Source

pub fn rumble_mapped(&self, port: Port) -> bool

Whether the pad on port took the motor mapping.

Source

pub fn rumble_refused(&self, port: Port) -> bool

Whether the pad on port was asked for its motors and did not take the mapping.

Source

pub fn stop_motors(&mut self)

Ask every motor on both ports to stop: for a pause, a menu or an exit. The pads hear it on their next poll.

Source

pub fn motors_requested(&self) -> bool

Whether any motor is being asked to run.

Source

pub fn analog_outcome(&self, port: Port) -> Option<AnalogRequirement>

What the pad on port settled on after [request_analog] (Self::request_analog); None while the request is still running or none was made.

Source

pub fn analog_pending(&self, port: Port) -> bool

Whether an analog request on port is still running.

Source

pub fn try_lease(&mut self) -> bool

Take the serial port for a foreground driver, if no transaction is on the wire. While held, VBlanks poll nothing and the snapshot stands.

Source

pub fn force_lease(&mut self)

Take the serial port now, abandoning a transaction in flight: for a caller that has waited as long as it can. The abandoned port reads Health::Faulted until its next transaction.

Source

pub fn release_lease(&mut self)

Give the serial port back to the engine.

Auto Trait Implementations§

§

impl<'p, H> Freeze for Engine<'p, H>
where H: Freeze,

§

impl<'p, H> !RefUnwindSafe for Engine<'p, H>

§

impl<'p, H> Send for Engine<'p, H>
where H: Send,

§

impl<'p, H> Sync for Engine<'p, H>
where H: Sync,

§

impl<'p, H> Unpin for Engine<'p, H>
where H: Unpin,

§

impl<'p, H> UnsafeUnpin for Engine<'p, H>
where H: UnsafeUnpin,

§

impl<'p, H> !UnwindSafe for Engine<'p, H>

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> 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.