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>
impl<'p, H: Hw> Engine<'p, H>
Sourcepub const fn new(hw: H, published: &'p Published, config: Config) -> Self
pub const fn new(hw: H, published: &'p Published, config: Config) -> Self
An idle engine that publishes to published.
Sourcepub fn configure(&mut self, config: Config)
pub fn configure(&mut self, config: Config)
Change the settings; they apply from the next transaction.
Sourcepub fn publish_readings(&self)
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.
Sourcepub fn on_vblank(&mut self)
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.
Sourcepub fn on_deadline(&mut self)
pub fn on_deadline(&mut self)
The deadline timer’s interrupt.
Sourcepub fn reading(&self, port: Port) -> PortReading
pub fn reading(&self, port: Port) -> PortReading
The latest reading of port, ahead of the next publication.
Sourcepub fn request_analog(&mut self, port: Port)
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.
Sourcepub fn enable_rumble(&mut self, port: Port)
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.
Sourcepub fn disable_rumble(&mut self, port: Port)
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.
Sourcepub fn set_rumble(&mut self, port: Port, rumble: Rumble)
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.
Sourcepub fn rumble_mapped(&self, port: Port) -> bool
pub fn rumble_mapped(&self, port: Port) -> bool
Whether the pad on port took the motor mapping.
Sourcepub fn rumble_refused(&self, port: Port) -> bool
pub fn rumble_refused(&self, port: Port) -> bool
Whether the pad on port was asked for its motors and did not take
the mapping.
Sourcepub fn stop_motors(&mut self)
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.
Sourcepub fn motors_requested(&self) -> bool
pub fn motors_requested(&self) -> bool
Whether any motor is being asked to run.
Sourcepub fn analog_outcome(&self, port: Port) -> Option<AnalogRequirement>
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.
Sourcepub fn analog_pending(&self, port: Port) -> bool
pub fn analog_pending(&self, port: Port) -> bool
Whether an analog request on port is still running.
Sourcepub fn try_lease(&mut self) -> bool
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.
Sourcepub fn force_lease(&mut self)
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.
Sourcepub fn release_lease(&mut self)
pub fn release_lease(&mut self)
Give the serial port back to the engine.