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

Module console

Module console 

Source
Expand description

The console side of the pad engine: the serial port and a timer behind Hw, the one global Engine, and the exception wrapper that feeds it.

Everything here is for the target. (It compiles on the host so the documentation shows it; none of it may run there.)

§Interrupt path

The wrapper sits in the general exception vector in front of whatever handler was there when install ran (psx-rt’s, or a wrapper such as psx-cdstream’s that leads to it). For an interrupt with VBlank, the controller (IRQ7) or root counter 0 pending it saves the interrupted CPU context, switches to a private stack, runs the engine’s events, restores the context and jumps on to the next handler either way, so the VBlank counter, the display flip and the fault handling run exactly as before. The wrapper never touches the interrupted stack, which is what makes it safe with a scratchpad stack; install declares it so.

§Foreground path

Every foreground call runs with CPU interrupts off for its few instructions, so it never overlaps a handler. Reading a snapshot takes no lock at all (snapshot).

§Memory cards

The engine owns the port token. A card driver borrows it as a Lease, which keeps the engine off the port until it is dropped.

Structs§

Lease
The port, on loan from the engine: it derefs to the ControllerPort a memory card or a diagnostic needs, and the engine polls nothing until it is dropped. VBlanks that pass meanwhile are not polled, so the snapshot stands still; keep a lease to one transaction.
Mmio
The serial port and root counter 0, through the SDK’s register steps.

Constants§

HANDLER_STACK_BYTES
Bytes of private stack the handler runs on.

Functions§

analog_outcome
What the pad settled on after request_analog; None while pending.
configure
Change the settings; they apply from the next transaction.
disable_rumble
Stop wanting the motors on port. They are told to stop on the next poll.
enable_rumble
Put the motors of the pad on port under the poll. The engine maps them (command 0x4D, in the same visit to configuration mode as an analog request if one is pending) whenever an analog DualShock is there and again each time one is plugged in, then sends set_rumble’s request with every poll. rumble_mapped says whether the pad took it.
handler_stack_unused_bytes
Bytes of the handler’s private stack never touched since install painted it.
install
Take over the controller port: put the exception wrapper in front of the handler the vector leads to and start polling on every VBlank.
is_installed
Whether install has run, uninstall has not, and psx-rt’s handler has not been put back in the vector since (which drops the wrapper from the exception chain: false then, and the engine no longer runs). Otherwise the wrapper is in the chain, first in the vector or behind psx-cdstream’s, which chains to it.
lease
Borrow the port. Waits for a transaction in flight (under two milliseconds on the wire); if the engine has not gone idle after a few VBlanks it abandons the transaction instead of waiting longer. A caller with CPU interrupts off cannot let the transaction finish, so it waits a fixed number of attempts instead and then takes the port.
owner
Who may use the port now.
pad
The latest clean state of port.
reading
The latest reading of port: the pad’s state and whether the socket is present.
request_analog
Ask for analog mode on port and lock it there. See Engine::request_analog; analog_outcome answers a few frames later.
rumble_mapped
Whether the pad on port took the motor mapping.
set_rumble
What the motors on port are asked to do on every poll. Takes effect on a pad that has been mapped; a digital pad ignores it.
snapshot
The latest publication of both ports. A copy: no lock, no interrupt masking.
stats
A copy of the counters.
stop_motors
Stop every motor now and return once a poll with the motors off has gone out on each port, so a program can pause, open a menu, or hand the port over knowing nothing is still spinning. Waits as lease does, three VBlanks at most; a port a Lease holds is not polled meanwhile. An unplugged pad has nothing to stop.
try_lease
Borrow the port if no transaction is on the wire right now.
uninstall
Give the port back to synchronous code. Waits for the transaction in flight, as lease does (and abandons it after the same patience), then closes the controller and counter 0 sources. The wrapper stays in the exception vector, chained, a few instructions per exception; install finds it there and takes the port again.