Skip to main content

Playdate

Struct Playdate 

Source
pub struct Playdate<S: Sdk> { /* private fields */ }
Expand description

The Playdate’s Platform.

Implementations§

Source§

impl<S: Sdk> Playdate<S>

Source

pub fn new(sdk: S) -> Self

The backend on sdk: it sets the display’s rate from the profile.

Source

pub fn sdk(&self) -> &S

The SDK.

Source

pub fn start<G: GameData>(&mut self, game: &Game<G>)

The game has loaded: loads its sounds, reads the crank’s notch from its keymap, adds the system menu’s items its optional actions are bound to, and lets it hear of the crank from the next frame.

Source

pub fn menu_chosen(&mut self, slot: u8)

The player chose the system menu’s item in slot: a press of its button at the next poll, so it goes where input goes.

Source

pub fn event(&mut self, event: SdkEvent) -> bool

The SDK’s event, as the SystemEvents the next frame reads. True when it should be heard now: no update comes until the system gives the game back, so what it saves must be saved before.

Source

pub fn take_changed(&mut self) -> bool

Whether anything reached the screen since the last call: the update callback returns it.

Source

pub fn pacing(&self, fps: u16) -> Pacing

What it applied, for App::set_pacing: the device runs at the profile’s rate whatever a game asks, so a request is confirmed.

Trait Implementations§

Source§

impl<S: Debug + Sdk> Debug for Playdate<S>

Source§

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

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

impl<S: Sdk> Platform for Playdate<S>

Source§

fn display(&self) -> DisplayInfo

The display, as it is now (a window may be resized between frames).
Source§

fn present(&mut self, frame: &Frame<'_>)

Shows frame. Called once per frame the game isn’t suspended, after its input, audio and update; the backend shows it as soon as it can and keeps it on the screen until the next.
Source§

fn poll_input(&mut self, out: &mut Vec<RawInputEvent>)

Adds the keyboard and controller events since the last call to out, in the order they happened: releases before presses within one poll of a device, as RawInputEvent::from_pads gives them.
Source§

fn system_events(&mut self, out: &mut Vec<SystemEvent>)

Adds the system’s events since the last call to out, in order.
Source§

fn storage(&mut self) -> Box<dyn Storage>

Hands over the game’s storage: its saves, settings and key bindings, by key. App calls it once, as the game loads, and the game’s context keeps it (screens save through it).
Source§

fn audio(&mut self) -> &mut dyn Audio

The sound device: it plays each frame’s sounds, music and voices and says what music is sounding.
Source§

fn text_input(&mut self) -> Option<&mut dyn TextInput>

The system’s own keyboard for text (a console’s, Steam’s on-screen one), if the device has one; None where the player types on keys, which come through poll_input.
Source§

fn facts(&self) -> PlatformFacts

Where the game runs (PlatformFacts): the target’s id, whether the game may quit, whether its window goes full screen and back, and the keyboard, pointer and touch screen the device has. Read from the target’s profile, or from what the backend reads of the system; constant for a run. App asks once, as the game loads, and the game’s context keeps them (Ctx::platform). Read more
Source§

fn clock(&self) -> Option<PerfClock>

A clock in whole microseconds, to measure frames with in debug builds (ADR-0046): App takes it once, on its first frame, and only with DEBUG_TOOLS on. None (the default) for a backend without one: nothing is measured.
Source§

fn memory(&mut self) -> Option<MemoryReading>

The device’s memory now, in debug builds (ADR-0046): the heap’s live bytes, their peak and the allocations since the last call. App asks once a frame, at the end of a frame it keeps a record of (debug tools on, with a clock), and puts the heap’s counts in the record. None (the default) for a backend that doesn’t count: records have no heap counts.
Source§

fn memory_scopes(&self) -> Option<MemoryScopes>

The memory tags of the backend’s heap counter, in debug builds (ADR-0046 §6): plain functions over its tags, so what the game allocates counts by the frame’s phase and the game’s spans. App takes them with the clock (clock), once, with DEBUG_TOOLS on, and moves them into the game’s context when it runs. None (the default) for a backend whose counter has no tags. A backend with them also tags each asset decode when it starts, before the game’s load (shuyi_assets::format::watch_decodes).
Source§

fn heap_snapshot(&mut self) -> Option<HeapSnapshot>

What holds the heap now, by memory tag, in debug builds (ADR-0046 §6): its live bytes and each tag’s counts, its frame left 0 for App::heap_snapshot to stamp. Taking one allocates the rows, so it is asked for now and then (a tool, a trace every 600 frames), never every frame. None (the default) for a backend whose counter has no tags.
Source§

fn changed_files(&mut self, _out: &mut Vec<String>)

Adds the paths in the bundle of the files that changed since the last call to out, in a build with debug tools (ADR-0071): the backend has already put their new bytes in their layers (Layer::replace). App asks once a frame while the game runs, only with Ctx::debug_tools on. By default it adds nothing: a device with no files to watch.

Auto Trait Implementations§

§

impl<S> !Freeze for Playdate<S>

§

impl<S> !RefUnwindSafe for Playdate<S>

§

impl<S> !Send for Playdate<S>

§

impl<S> !Sync for Playdate<S>

§

impl<S> !UnwindSafe for Playdate<S>

§

impl<S> Unpin for Playdate<S>
where S: Unpin, <S as Sdk>::Sample: Unpin, <S as Sdk>::SamplePlayer: Unpin, <S as Sdk>::FilePlayer: Unpin,

§

impl<S> UnsafeUnpin for Playdate<S>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.