Skip to main content

Module crank

Module crank 

Source
Expand description

A crank (the Playdate’s, ticket 1035) as two controller buttons: each notch wound backwards is a press and release of Button::CrankBack, each notch forwards one of Button::CrankForward, so the crank reaches a game through the player’s bindings like any button (game ADR-0034). How far a notch is comes from the keymap file’s crank (CrankDef).

Crank is pure: the platform hands it how far the crank turned since the last frame and gets whole notches back. A notch is that far wound one way: what is left of one is kept for the next frame, so the same turn gives the same notches however the frames split it, but turning the other way starts a fresh notch (so after a notch back, the next notch forwards is a whole notch away, and a hand resting on the crank never gives a notch). A docked crank gives none and forgets what was wound. A backend whose device says how far a crank turned as a float turns it into whole steps at its boundary, STEPS_PER_TURN to the turn, and hands those to Crank::turn_steps: no float goes further.

Structs§

Crank
A crank’s notches (see the module docs).

Constants§

STEPS_PER_TURN
How many steps make a whole turn (Crank::turn_steps).

Functions§

only_on_the_crank
Whether chords are all the buttons of an action and each needs the crank wound, so that with it docked the action can’t be pressed.

Type Aliases§

Notches
Notches wound in one frame: negative backwards, positive forwards.