get playdate
v1.13.4

Module playdate

Source

source/playdate/package.d

See Also

Inside Playdate with C - Official Playdate SDK Documentation

Authors

Chance Snow

License

MIT License

Members

  • AddedIn

    struct AddedIn;

    Attribute specifying which version a symbol was added to the Playdate C SDK.

    • this

      this(ubyte major, ubyte minor, ubyte patch = 0);
  • PDButtons

    enum PDButtons: int;
  • PDLanguage

    enum PDLanguage: int;
  • PDDateTime

    struct PDDateTime;
  • PDPeripherals

    enum PDPeripherals: int;
  • LCDRect

    struct LCDRect;
    • left

      int left;

      Left edge along x-axis.

    • right

      int right;

      Right edge along x-axis, not inclusive.

    • top

      int top;

      Top edge along y-axis.

    • bottom

      int bottom;

      Bottom edge along y-axis, not inclusive.

    • translate

      const nothrow @nogc LCDRect translate(int dx, int dy);
  • makeRect

    nothrow @nogc LCDRect makeRect(int x, int y, int width, int height);

    Remarks

    Assumes width and height are positive.

  • LCD_COLUMNS

    enum int LCD_COLUMNS;
  • LCD_ROWS

    enum int LCD_ROWS;
  • LCD_ROWSIZE

    enum int LCD_ROWSIZE;
  • LCD_SCREEN_RECT

    enum LCDRect LCD_SCREEN_RECT;
  • LCDBitmapDrawMode

    enum LCDBitmapDrawMode: int;
  • LCDBitmapFlip

    enum LCDBitmapFlip: int;
  • LCDSolidColor

    enum LCDSolidColor: int;
  • LCDLineCapStyle

    enum LCDLineCapStyle: int;
  • PDStringEncoding

    enum PDStringEncoding: int;
  • LCDPolygonFillRule

    enum LCDPolygonFillRule: int;
  • PDSystemEvent

    enum PDSystemEvent: int;
  • PDCallbackFunction

    alias PDCallbackFunction = int function(void* userData) nothrow @nogc;
  • PDMenuItemCallbackFunction

    alias PDMenuItemCallbackFunction = void function(void* userdata) nothrow @nogc;
  • AudioSourceFunction

    alias AudioSourceFunction = bool function(void* context, short* left, short* right, int len) nothrow @nogc;

    Fill the passed-in left buffer (and right if it’s a stereo source) with len samples each and return true, or false if the source is silent through the cycle.

  • RecordCallback

    alias RecordCallback = bool function(void* context, short* buffer, int length) nothrow @nogc;

    Called with the recorded audio data, a monophonic stream of samples.

    Return true to continue recording, false to stop recording.

    See Also

    Sound.setMicCallback

  • effectProc

    alias effectProc = bool function(void* e, int* left, int* right, int nsamples, bool bufactive) nothrow @nogc;

    bufactive is true if samples have been set in the left or right buffers. Return true if it changed the buffer samples, otherwise false. left and right (if the effect is on a stereo channel) are sample buffers in signed Q8.24 format.

  • System

    struct System;
    • realloc

      void* function(void* ptr, size_t size) realloc;

      ptr = NULL -> malloc, size = 0 -> free

    • formatString

      int function(char** ret, const char* fmt, ...) formatString;
    • logToConsole

      void function(const char* fmt, ...) logToConsole;
    • error

      void function(const char* fmt, ...) error;
    • getLanguage

      PDLanguage function() getLanguage;
    • getCurrentTimeMilliseconds

      uint function() getCurrentTimeMilliseconds;
    • getSecondsSinceEpoch

      uint function(uint* milliseconds) getSecondsSinceEpoch;
    • drawFPS

      void function(int x, int y) drawFPS;
    • setUpdateCallback

      void function(PDCallbackFunction update, void* userdata) setUpdateCallback;
    • getButtonState

      void function(PDButtons* current, PDButtons* pushed, PDButtons* released) getButtonState;
    • setPeripheralsEnabled

      void function(PDPeripherals mask) setPeripheralsEnabled;
    • getAccelerometer

      void function(float* outx, float* outy, float* outz) getAccelerometer;

      Returns the last-read accelerometer data.

    • getCrankChange

      float function() getCrankChange;

      Returns the angle change of the crank since the last time this function was called. Negative values are anti-clockwise.

    • getCrankAngle

      float function() getCrankAngle;

      Returns the current position of the crank, in the range 0-360. Zero is pointing up, and the value increases as the crank moves clockwise, as viewed from the right side of the device.

    • isCrankDocked

      bool function() isCrankDocked;

      Returns true or false indicating whether or not the crank is folded into the unit.

    • setCrankSoundsDisabled

      int function(int flag) setCrankSoundsDisabled;

      Returns the previous value for this setting.

      Remarks

      0.12 adds sound effects for various system events, such as the menu opening or closing, USB cable plugged or unplugged, and the crank docked or undocked. Since games can receive notification of the crank docking and undocking, and may incorporate this into the game, we’ve provided a function for muting the default sounds for these events.

    • getFlipped

      int function() getFlipped;
    • setAutoLockDisabled

      void function(bool disable) setAutoLockDisabled;

      Disables or enables the 60 second auto lock feature. When called, the timer is reset to 60 seconds.

      Remarks

      As of 0.10.3, the device will automatically lock if the user doesn’t press any buttons or use the crank for more than 60 seconds. In order for games that expect longer periods without interaction to continue to function, it is possible to manually disable the auto lock feature. Note that when disabling the timeout, developers should take care to re-enable the timeout when appropiate.

    • setMenuImage

      void function(LCDBitmap* bitmap, int xOffset) setMenuImage;
    • addMenuItem

      PDMenuItem* function(const char* title, PDMenuItemCallbackFunction callback, void* userdata) addMenuItem;
    • addCheckmarkMenuItem

      PDMenuItem* function(const char* title, int value, PDMenuItemCallbackFunction callback, void* userdata) addCheckmarkMenuItem;
    • addOptionsMenuItem

      PDMenuItem* function(const char* title, const char** optionTitles, int optionsCount, PDMenuItemCallbackFunction f, void* userdata) addOptionsMenuItem;
    • removeAllMenuItems

      void function() removeAllMenuItems;
    • removeMenuItem

      void function(PDMenuItem* menuItem) removeMenuItem;
    • getMenuItemValue

      int function(PDMenuItem* menuItem) getMenuItemValue;
    • setMenuItemValue

      void function(PDMenuItem* menuItem, int value) setMenuItemValue;
    • getMenuItemTitle

      const(char*) function(PDMenuItem* menuItem) getMenuItemTitle;
    • setMenuItemTitle

      void function(PDMenuItem* menuItem, const char* title) setMenuItemTitle;
    • getMenuItemUserdata

      void* function(PDMenuItem* menuItem) getMenuItemUserdata;
    • setMenuItemUserdata

      void function(PDMenuItem* menuItem, void* ud) setMenuItemUserdata;
    • getReduceFlashing

      bool function() getReduceFlashing;
    • getElapsedTime

      float function() getElapsedTime;
    • resetElapsedTime

      void function() resetElapsedTime;
    • getBatteryPercentage

      float function() getBatteryPercentage;
    • getBatteryVoltage

      float function() getBatteryVoltage;
    • getTimezoneOffset

      int function() getTimezoneOffset;
    • shouldDisplay24HourTime

      bool function() shouldDisplay24HourTime;
    • convertEpochToDateTime

      void function(int epoch, PDDateTime* datetime) convertEpochToDateTime;
    • convertDateTimeToEpoch

      int function(PDDateTime* datetime) convertDateTimeToEpoch;
  • alloc

    T* alloc(T)(System* system);
  • alloc

    T[] alloc(T)(System* system, ulong size);
  • free

    void free(T)(System* system, T* value);
  • logToConsole

    nothrow @nogc void logToConsole(System* system, string message);
  • FileOptions

    enum FileOptions: int;
  • FileStat

    struct FileStat;
    • isDir

      bool isDir;

      Whether the file is a directory.

    • size

      uint size;

      Size of the file, in bytes.

    • year

      int year;

      Year component of the file's last modified date.

    • month

      int month;

      Month component of the file's last modified date.

    • day

      int day;

      Day component of the file's last modified date.

    • hour

      int hour;

      Hour component of the file's last modified date.

    • minute

      int minute;

      Minute component of the file's last modified date.

    • second

      int second;

      Second component of the file's last modified date.

  • File

    struct File;
    • geterr

      const(char*) function() geterr;
    • listfiles

      int function(const char* path, void function(const char* path, void* userdata) callback, void* userdata, bool showHidden) listfiles;
    • stat

      int function(const char* path, FileStat* stat) stat;
    • mkdir

      int function(const char* path) mkdir;
    • unlink

      int function(const char* name, int recursive) unlink;
    • rename

      int function(const char* from, const char* to) rename;
    • open

      SDFile function(const char* name, FileOptions mode) open;
    • close

      int function(SDFile file) close;
    • read

      int function(SDFile file, void* buf, uint len) read;
    • write

      int function(SDFile file, const void* buf, uint len) write;
    • flush

      int function(SDFile file) flush;
    • tell

      int function(SDFile file) tell;
    • seek

      int function(SDFile file, int pos, int whence) seek;
  • Video

    struct Video;
    • loadVideo

      LCDVideoPlayer* function(const char* path) loadVideo;
    • freePlayer

      void function(LCDVideoPlayer* p) freePlayer;
    • setContext

      int function(LCDVideoPlayer* p, LCDBitmap* context) setContext;
    • useScreenContext

      void function(LCDVideoPlayer* p) useScreenContext;
    • renderFrame

      int function(LCDVideoPlayer* p, int n) renderFrame;
    • getError

      const(char*) function(LCDVideoPlayer* p) getError;
    • getInfo

      void function(LCDVideoPlayer* p, int* outWidth, int* outHeight, float* outFrameRate, int* outFrameCount, int* outCurrentFrame) getInfo;
    • getContext

      LCDBitmap* function(LCDVideoPlayer* p) getContext;
  • Graphics

    struct Graphics;
    • video

      Video* video;
    • clear

      void function(LCDColor color) clear;
    • setBackgroundColor

      void function(LCDSolidColor color) setBackgroundColor;
    • setStencil

      void function(LCDBitmap* stencil) setStencil;

      Deprecated

      In favor of setStencilImage, which adds a "tile" flag

    • setDrawMode

      void function(LCDBitmapDrawMode mode) setDrawMode;
    • setDrawOffset

      void function(int dx, int dy) setDrawOffset;
    • setClipRect

      void function(int x, int y, int width, int height) setClipRect;
    • clearClipRect

      void function() clearClipRect;
    • setLineCapStyle

      void function(LCDLineCapStyle endCapStyle) setLineCapStyle;
    • setFont

      void function(LCDFont* font) setFont;
    • setTextTracking

      void function(int tracking) setTextTracking;
    • pushContext

      void function(LCDBitmap* target) pushContext;
    • popContext

      void function() popContext;
    • drawBitmap

      void function(LCDBitmap* bitmap, int x, int y, LCDBitmapFlip flip) drawBitmap;
    • tileBitmap

      void function(LCDBitmap* bitmap, int x, int y, int width, int height, LCDBitmapFlip flip) tileBitmap;
    • drawLine

      void function(int x1, int y1, int x2, int y2, int width, LCDColor color) drawLine;
    • fillTriangle

      void function(int x1, int y1, int x2, int y2, int x3, int y3, LCDColor color) fillTriangle;
    • drawRect

      void function(int x, int y, int width, int height, LCDColor color) drawRect;
    • fillRect

      void function(int x, int y, int width, int height, LCDColor color) fillRect;
    • drawEllipse

      void function(int x, int y, int width, int height, int lineWidth, float startAngle, float endAngle, LCDColor color) drawEllipse;

      stroked inside the rect

    • fillEllipse

      void function(int x, int y, int width, int height, float startAngle, float endAngle, LCDColor color) fillEllipse;
    • drawScaledBitmap

      void function(LCDBitmap* bitmap, int x, int y, float xscale, float yscale) drawScaledBitmap;
    • drawText

      int function(const void* text, size_t len, PDStringEncoding encoding, int x, int y) drawText;
    • newBitmap

      LCDBitmap* function(int width, int height, LCDColor bgcolor) newBitmap;
    • freeBitmap

      void function(LCDBitmap*) freeBitmap;
    • loadBitmap

      LCDBitmap* function(const char* path, const char** outerr) loadBitmap;
    • copyBitmap

      LCDBitmap* function(LCDBitmap* bitmap) copyBitmap;
    • loadIntoBitmap

      void function(const char* path, LCDBitmap* bitmap, const char** outerr) loadIntoBitmap;
    • getBitmapData

      void function(LCDBitmap* bitmap, int* width, int* height, int* rowbytes, ubyte** mask, ubyte** data) getBitmapData;
    • clearBitmap

      void function(LCDBitmap* bitmap, LCDColor bgcolor) clearBitmap;
    • rotatedBitmap

      LCDBitmap* function(LCDBitmap* bitmap, float rotation, float xscale, float yscale, int* allocedSize) rotatedBitmap;
    • newBitmapTable

      LCDBitmapTable* function(int count, int width, int height) newBitmapTable;
    • freeBitmapTable

      void function(LCDBitmapTable* table) freeBitmapTable;
    • loadBitmapTable

      LCDBitmapTable* function(const char* path, const char** outerr) loadBitmapTable;
    • loadIntoBitmapTable

      void function(const char* path, LCDBitmapTable* table, const char** outerr) loadIntoBitmapTable;
    • getTableBitmap

      LCDBitmap* function(LCDBitmapTable* table, int idx) getTableBitmap;
    • loadFont

      LCDFont* function(const char* path, const char** outErr) loadFont;
    • getFontPage

      LCDFontPage* function(LCDFont* font, uint c) getFontPage;
    • getPageGlyph

      LCDFontGlyph* function(LCDFontPage* page, uint c, LCDBitmap** bitmap, int* advance) getPageGlyph;
    • getGlyphKerning

      int function(LCDFontGlyph* glyph, uint glyphcode, uint nextcode) getGlyphKerning;
    • getTextWidth

      int function(LCDFont* font, const void* text, size_t len, PDStringEncoding encoding, int tracking) getTextWidth;
    • getFrame

      ubyte* function() getFrame;
    • getDisplayFrame

      ubyte* function() getDisplayFrame;
    • getDebugBitmap

      LCDBitmap* function() getDebugBitmap;
    • copyFrameBufferBitmap

      LCDBitmap* function() copyFrameBufferBitmap;
    • markUpdatedRows

      void function(int start, int end) markUpdatedRows;
    • display

      void function() display;
    • setColorToPattern

      void function(LCDColor* color, LCDBitmap* bitmap, int x, int y) setColorToPattern;

      misc util.

    • checkMaskCollision

      int function(LCDBitmap* bitmap1, int x1, int y1, LCDBitmapFlip flip1, LCDBitmap* bitmap2, int x2, int y2, LCDBitmapFlip flip2, LCDRect rect) checkMaskCollision;
    • setScreenClipRect

      void function(int x, int y, int width, int height) setScreenClipRect;
    • fillPolygon

      void function(int nPoints, int* coords, LCDColor color, LCDPolygonFillRule fillrule) fillPolygon;
    • getFontHeight

      ubyte function(LCDFont* font) getFontHeight;
    • getDisplayBufferBitmap

      LCDBitmap* function() getDisplayBufferBitmap;
    • drawRotatedBitmap

      void function(LCDBitmap* bitmap, int x, int y, float rotation, float centerx, float centery, float xscale, float yscale) drawRotatedBitmap;
    • setTextLeading

      void function(int lineHeightAdustment) setTextLeading;
    • setBitmapMask

      int function(LCDBitmap* bitmap, LCDBitmap* mask) setBitmapMask;
    • getBitmapMask

      LCDBitmap* function(LCDBitmap* bitmap) getBitmapMask;
    • setStencilImage

      void function(LCDBitmap* stencil, int tile) setStencilImage;
    • makeFontFromData

      LCDFont* function(LCDFontData* data, int wide) makeFontFromData;
  • drawText

    nothrow @nogc int drawText(Graphics* gfx, string text, int x, int y, PDStringEncoding encoding = PDStringEncoding.utf8Encoding);
  • Sprite

    struct Sprite;
  • Display

    struct Display;
  • SoundChannel

    alias SoundChannel = void*;

    A SoundChannel contains SoundSources and SoundEffects.

  • SoundChannelApi

    struct SoundChannelApi;
    • newChannel

      SoundChannel function() newChannel;
    • freeChannel

      void function(SoundChannel channel) freeChannel;
    • addSource

      int function(SoundChannel channel, SoundSource* source) addSource;
    • removeSource

      int function(SoundChannel channel, SoundSource* source) removeSource;
    • addCallbackSource

      SoundSource* function(SoundChannel channel, AudioSourceFunction* callback, void* context, int stereo) addCallbackSource;

      Creates a new SoundSource using the given data provider callback and adds it to the default channel.

      Remarks

      The caller takes ownership of the allocated SoundSource, and should free it with playdate.system.realloc(source, NULL); when it is no longer in use.

    • addEffect

      void function(SoundChannel channel, SoundEffect* effect) addEffect;
    • removeEffect

      void function(SoundChannel channel, SoundEffect* effect) removeEffect;
    • setVolume

      void function(SoundChannel channel, float volume) setVolume;
    • getVolume

      float function(SoundChannel channel) getVolume;
    • setVolumeModulator

      void function(SoundChannel channel, PDSynthSignalValue mod) setVolumeModulator;
    • getVolumeModulator

      PDSynthSignalValue function(SoundChannel channel) getVolumeModulator;
    • setPan

      void function(SoundChannel channel, float pan) setPan;
    • setPanModulator

      void function(SoundChannel channel, PDSynthSignalValue mod) setPanModulator;
    • getPanModulator

      PDSynthSignalValue function(SoundChannel channel) getPanModulator;
    • getDryLevelSignal

      PDSynthSignalValue function(SoundChannel channel) getDryLevelSignal;
    • getWetLevelSignal

      PDSynthSignalValue function(SoundChannel channel) getWetLevelSignal;
  • SoundFileplayer

    struct SoundFileplayer;
  • SoundSample

    struct SoundSample;
  • SoundSampleplayer

    struct SoundSampleplayer;
  • SoundSynth

    struct SoundSynth;
  • SoundSequence

    struct SoundSequence;
  • SoundEffect

    alias SoundEffect = void*;
  • SoundEffectApi

    struct SoundEffectApi;
  • SoundLfo

    struct SoundLfo;
  • SoundEnvelope

    struct SoundEnvelope;
  • SoundSource

    struct SoundSource;
  • ControlSignal

    struct ControlSignal;
  • SoundTrack

    struct SoundTrack;
  • SoundInstrument

    struct SoundInstrument;
  • PDSynthSignalValue

    alias PDSynthSignalValue = void*;

    A PDSynthSignalValue represents a signal that can be used as an input to a modulator. Its PDSynthSignal subclass is used for "active" signals that change their values automatically. PDSynthLFO and PDSynthEnvelope are subclasses of PDSynthSignal.

  • SoundSignal

    struct SoundSignal;
  • Sound

    struct Sound;
    • channel

      SoundChannelApi* channel;
    • fileplayer

      SoundFileplayer* fileplayer;
    • sample

      SoundSample* sample;
    • sampleplayer

      SoundSampleplayer* sampleplayer;
    • synth

      SoundSynth* synth;
    • sequence

      SoundSequence* sequence;
    • effect

      SoundEffectApi* effect;
    • lfo

      SoundLfo* lfo;
    • envelope

      SoundEnvelope* envelope;
    • source

      SoundSource* source;
    • controlsignal

      ControlSignal* controlsignal;
    • track

      SoundTrack* track;
    • instrument

      SoundInstrument* instrument;
    • getCurrentTime

      uint function() getCurrentTime;
    • addSource

      SoundSource* function(AudioSourceFunction callback, void* context, bool stereo) addSource;

      The callback function you pass in will be called every audio render cycle.

    • getDefaultChannel

      SoundChannel function() getDefaultChannel;
    • addChannel

      void function(SoundChannel channel) addChannel;
    • removeChannel

      void function(SoundChannel channel) removeChannel;
    • setMicCallback

      void function(RecordCallback callback, void* context, bool forceInternal) setMicCallback;

      The callback you pass in will be called every audio cycle.

      If forceInternal is set, the device microphone is used regardless of whether the headset has a microphone.

    • getHeadphoneState

      void function(bool* headphone, bool* headsetmic, void function(bool headphone, bool mic) changeCallback) getHeadphoneState;

      If headphone contains a non-null pointer, the value is set to true if headphones are currently plugged in. Likewise, mic is set if the headphones include a microphone. If changeCallback is provided, it will be called when the headset or mic status changes, and audio output will not automatically switch from speaker to headphones when headphones are plugged in (and vice versa). In this case, the callback should use playdate.sound.setOutputsActive() to change the output if needed.

    • setOutputsActive

      void function(bool headphone, bool speaker) setOutputsActive;

      Force audio output to the given outputs, regardless of headphone status.

    • removeSource

      void function(SoundSource* source) removeSource;
    • signal

      SoundSignal* signal;
  • Lua

    struct Lua;
  • Json

    struct Json;
  • Scoreboards

    struct Scoreboards;
  • PlaydateAPI

    struct PlaydateAPI;
  • EventHandlerShim

    template EventHandlerShim()

    Generates a shim around your eventHandler used by the Playdate OS as the entry-point to your application.