Module playdate
Source
See Also
Inside Playdate with C - Official Playdate SDK Documentation
License
MIT License
Members
-
AddedInstruct AddedIn;Attribute specifying which version a symbol was added to the Playdate C SDK.
-
thisthis(ubytemajor, ubyteminor, ubytepatch= 0);
-
PDButtonsenum PDButtons: int;-
buttonLeftbuttonLeft -
buttonRightbuttonRight -
buttonUpbuttonUp -
buttonDownbuttonDown -
buttonBbuttonB -
buttonAbuttonA
-
PDLanguageenum PDLanguage: int; -
PDDateTimestruct PDDateTime; -
PDPeripheralsenum PDPeripherals: int; -
LCDRectstruct LCDRect; -
makeRectnothrow @nogc LCDRect makeRect(intx, inty, intwidth, intheight);Remarks
Assumeswidthandheightare positive. -
LCD_COLUMNSenum int LCD_COLUMNS; -
LCD_ROWSenum int LCD_ROWS; -
LCD_ROWSIZEenum int LCD_ROWSIZE; -
LCD_SCREEN_RECTenum LCDRect LCD_SCREEN_RECT; -
LCDBitmapDrawModeenum LCDBitmapDrawMode: int; -
LCDBitmapFlipenum LCDBitmapFlip: int; -
LCDSolidColorenum LCDSolidColor: int; -
LCDLineCapStyleenum LCDLineCapStyle: int; -
PDStringEncodingenum PDStringEncoding: int; -
LCDPolygonFillRuleenum LCDPolygonFillRule: int; -
PDSystemEventenum PDSystemEvent: int; -
PDCallbackFunctionalias PDCallbackFunction = int function(void* userData) nothrow @nogc; -
PDMenuItemCallbackFunctionalias PDMenuItemCallbackFunction = void function(void* userdata) nothrow @nogc; -
AudioSourceFunctionalias AudioSourceFunction = bool function(void* context, short* left, short* right, int len) nothrow @nogc;Fill the passed-in
leftbuffer (andrightif it’s a stereo source) withlensamples each and returntrue, orfalseif the source is silent through the cycle. -
RecordCallbackalias RecordCallback = bool function(void* context, short* buffer, int length) nothrow @nogc;Called with the recorded audio data, a monophonic stream of samples.
Return
trueto continue recording,falseto stop recording.See Also
Sound.setMicCallback -
effectProcalias effectProc = bool function(void* e, int* left, int* right, int nsamples, bool bufactive) nothrow @nogc;bufactiveistrueif samples have been set in the left or right buffers. Returntrueif it changed the buffer samples, otherwisefalse.leftandright(if the effect is on a stereo channel) are sample buffers in signed Q8.24 format. -
Systemstruct System;-
reallocvoid* function(void* ptr, size_t size) realloc;ptr = NULL -> malloc, size = 0 -> free
-
formatStringint function(char** ret, const char* fmt, ...) formatString; -
logToConsolevoid function(const char* fmt, ...) logToConsole; -
errorvoid function(const char* fmt, ...) error; -
getLanguagePDLanguage function() getLanguage; -
getCurrentTimeMillisecondsuint function() getCurrentTimeMilliseconds; -
getSecondsSinceEpochuint function(uint* milliseconds) getSecondsSinceEpoch; -
drawFPSvoid function(int x, int y) drawFPS; -
setUpdateCallbackvoid function(PDCallbackFunction update, void* userdata) setUpdateCallback; -
getButtonStatevoid function(PDButtons* current, PDButtons* pushed, PDButtons* released) getButtonState; -
setPeripheralsEnabledvoid function(PDPeripherals mask) setPeripheralsEnabled; -
getAccelerometervoid function(float* outx, float* outy, float* outz) getAccelerometer;Returns the last-read accelerometer data.
-
getCrankChangefloat function() getCrankChange;Returns the angle change of the crank since the last time this function was called. Negative values are anti-clockwise.
-
getCrankAnglefloat 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.
-
isCrankDockedbool function() isCrankDocked;Returns
trueorfalseindicating whether or not the crank is folded into the unit. -
setCrankSoundsDisabledint 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. -
getFlippedint function() getFlipped; -
setAutoLockDisabledvoid 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. -
setMenuImagevoid function(LCDBitmap* bitmap, int xOffset) setMenuImage; -
addMenuItemPDMenuItem* function(const char* title, PDMenuItemCallbackFunction callback, void* userdata) addMenuItem; -
addCheckmarkMenuItemPDMenuItem* function(const char* title, int value, PDMenuItemCallbackFunction callback, void* userdata) addCheckmarkMenuItem; -
addOptionsMenuItemPDMenuItem* function(const char* title, const char** optionTitles, int optionsCount, PDMenuItemCallbackFunction f, void* userdata) addOptionsMenuItem; -
removeAllMenuItemsvoid function() removeAllMenuItems; -
removeMenuItemvoid function(PDMenuItem* menuItem) removeMenuItem; -
getMenuItemValueint function(PDMenuItem* menuItem) getMenuItemValue; -
setMenuItemValuevoid function(PDMenuItem* menuItem, int value) setMenuItemValue; -
getMenuItemTitleconst(char*) function(PDMenuItem* menuItem) getMenuItemTitle; -
setMenuItemTitlevoid function(PDMenuItem* menuItem, const char* title) setMenuItemTitle; -
getMenuItemUserdatavoid* function(PDMenuItem* menuItem) getMenuItemUserdata; -
setMenuItemUserdatavoid function(PDMenuItem* menuItem, void* ud) setMenuItemUserdata; -
getReduceFlashingbool function() getReduceFlashing; -
getElapsedTimefloat function() getElapsedTime; -
resetElapsedTimevoid function() resetElapsedTime; -
getBatteryPercentagefloat function() getBatteryPercentage; -
getBatteryVoltagefloat function() getBatteryVoltage; -
getTimezoneOffsetint function() getTimezoneOffset; -
shouldDisplay24HourTimebool function() shouldDisplay24HourTime; -
convertEpochToDateTimevoid function(int epoch, PDDateTime* datetime) convertEpochToDateTime; -
convertDateTimeToEpochint function(PDDateTime* datetime) convertDateTimeToEpoch;
-
allocT* alloc(T)(System*system); -
allocT[] alloc(T)(System*system, ulongsize); -
freevoid free(T)(System*system, T*value); -
logToConsolenothrow @nogc void logToConsole(System*system, stringmessage); -
FileOptionsenum FileOptions: int; -
FileStatstruct FileStat;-
isDirbool isDir;Whether the file is a directory.
-
sizeuint size;Size of the file, in bytes.
-
yearint year;Year component of the file's last modified date.
-
monthint month;Month component of the file's last modified date.
-
dayint day;Day component of the file's last modified date.
-
hourint hour;Hour component of the file's last modified date.
-
minuteint minute;Minute component of the file's last modified date.
-
secondint second;Second component of the file's last modified date.
-
Filestruct File;-
geterrconst(char*) function() geterr; -
listfilesint function(const char* path, void function(const char* path, void* userdata) callback, void* userdata, bool showHidden) listfiles; -
statint function(const char* path, FileStat* stat) stat; -
mkdirint function(const char* path) mkdir; -
unlinkint function(const char* name, int recursive) unlink; -
renameint function(const char* from, const char* to) rename; -
openSDFile function(const char* name, FileOptions mode) open; -
closeint function(SDFile file) close; -
readint function(SDFile file, void* buf, uint len) read; -
writeint function(SDFile file, const void* buf, uint len) write; -
flushint function(SDFile file) flush; -
tellint function(SDFile file) tell; -
seekint function(SDFile file, int pos, int whence) seek;
-
Videostruct Video;-
loadVideoLCDVideoPlayer* function(const char* path) loadVideo; -
freePlayervoid function(LCDVideoPlayer* p) freePlayer; -
setContextint function(LCDVideoPlayer* p, LCDBitmap* context) setContext; -
useScreenContextvoid function(LCDVideoPlayer* p) useScreenContext; -
renderFrameint function(LCDVideoPlayer* p, int n) renderFrame; -
getErrorconst(char*) function(LCDVideoPlayer* p) getError; -
getInfovoid function(LCDVideoPlayer* p, int* outWidth, int* outHeight, float* outFrameRate, int* outFrameCount, int* outCurrentFrame) getInfo; -
getContextLCDBitmap* function(LCDVideoPlayer* p) getContext;
-
Graphicsstruct Graphics;-
videoVideo* video; -
clearvoid function(LCDColor color) clear; -
setBackgroundColorvoid function(LCDSolidColor color) setBackgroundColor; -
setStencilvoid function(LCDBitmap* stencil) setStencil;Deprecated
In favor of
setStencilImage, which adds a "tile" flag -
setDrawModevoid function(LCDBitmapDrawMode mode) setDrawMode; -
setDrawOffsetvoid function(int dx, int dy) setDrawOffset; -
setClipRectvoid function(int x, int y, int width, int height) setClipRect; -
clearClipRectvoid function() clearClipRect; -
setLineCapStylevoid function(LCDLineCapStyle endCapStyle) setLineCapStyle; -
setFontvoid function(LCDFont* font) setFont; -
setTextTrackingvoid function(int tracking) setTextTracking; -
pushContextvoid function(LCDBitmap* target) pushContext; -
popContextvoid function() popContext; -
drawBitmapvoid function(LCDBitmap* bitmap, int x, int y, LCDBitmapFlip flip) drawBitmap; -
tileBitmapvoid function(LCDBitmap* bitmap, int x, int y, int width, int height, LCDBitmapFlip flip) tileBitmap; -
drawLinevoid function(int x1, int y1, int x2, int y2, int width, LCDColor color) drawLine; -
fillTrianglevoid function(int x1, int y1, int x2, int y2, int x3, int y3, LCDColor color) fillTriangle; -
drawRectvoid function(int x, int y, int width, int height, LCDColor color) drawRect; -
fillRectvoid function(int x, int y, int width, int height, LCDColor color) fillRect; -
drawEllipsevoid function(int x, int y, int width, int height, int lineWidth, float startAngle, float endAngle, LCDColor color) drawEllipse;stroked inside the rect
-
fillEllipsevoid function(int x, int y, int width, int height, float startAngle, float endAngle, LCDColor color) fillEllipse; -
drawScaledBitmapvoid function(LCDBitmap* bitmap, int x, int y, float xscale, float yscale) drawScaledBitmap; -
drawTextint function(const void* text, size_t len, PDStringEncoding encoding, int x, int y) drawText; -
newBitmapLCDBitmap* function(int width, int height, LCDColor bgcolor) newBitmap; -
freeBitmapvoid function(LCDBitmap*) freeBitmap; -
loadBitmapLCDBitmap* function(const char* path, const char** outerr) loadBitmap; -
copyBitmapLCDBitmap* function(LCDBitmap* bitmap) copyBitmap; -
loadIntoBitmapvoid function(const char* path, LCDBitmap* bitmap, const char** outerr) loadIntoBitmap; -
getBitmapDatavoid function(LCDBitmap* bitmap, int* width, int* height, int* rowbytes, ubyte** mask, ubyte** data) getBitmapData; -
clearBitmapvoid function(LCDBitmap* bitmap, LCDColor bgcolor) clearBitmap; -
rotatedBitmapLCDBitmap* function(LCDBitmap* bitmap, float rotation, float xscale, float yscale, int* allocedSize) rotatedBitmap; -
newBitmapTableLCDBitmapTable* function(int count, int width, int height) newBitmapTable; -
freeBitmapTablevoid function(LCDBitmapTable* table) freeBitmapTable; -
loadBitmapTableLCDBitmapTable* function(const char* path, const char** outerr) loadBitmapTable; -
loadIntoBitmapTablevoid function(const char* path, LCDBitmapTable* table, const char** outerr) loadIntoBitmapTable; -
getTableBitmapLCDBitmap* function(LCDBitmapTable* table, int idx) getTableBitmap; -
loadFontLCDFont* function(const char* path, const char** outErr) loadFont; -
getFontPageLCDFontPage* function(LCDFont* font, uint c) getFontPage; -
getPageGlyphLCDFontGlyph* function(LCDFontPage* page, uint c, LCDBitmap** bitmap, int* advance) getPageGlyph; -
getGlyphKerningint function(LCDFontGlyph* glyph, uint glyphcode, uint nextcode) getGlyphKerning; -
getTextWidthint function(LCDFont* font, const void* text, size_t len, PDStringEncoding encoding, int tracking) getTextWidth; -
getFrameubyte* function() getFrame; -
getDisplayFrameubyte* function() getDisplayFrame; -
getDebugBitmapLCDBitmap* function() getDebugBitmap; -
copyFrameBufferBitmapLCDBitmap* function() copyFrameBufferBitmap; -
markUpdatedRowsvoid function(int start, int end) markUpdatedRows; -
displayvoid function() display; -
setColorToPatternvoid function(LCDColor* color, LCDBitmap* bitmap, int x, int y) setColorToPattern;misc util.
-
checkMaskCollisionint function(LCDBitmap* bitmap1, int x1, int y1, LCDBitmapFlip flip1, LCDBitmap* bitmap2, int x2, int y2, LCDBitmapFlip flip2, LCDRect rect) checkMaskCollision; -
setScreenClipRectvoid function(int x, int y, int width, int height) setScreenClipRect; -
fillPolygonvoid function(int nPoints, int* coords, LCDColor color, LCDPolygonFillRule fillrule) fillPolygon; -
getFontHeightubyte function(LCDFont* font) getFontHeight; -
getDisplayBufferBitmapLCDBitmap* function() getDisplayBufferBitmap; -
drawRotatedBitmapvoid function(LCDBitmap* bitmap, int x, int y, float rotation, float centerx, float centery, float xscale, float yscale) drawRotatedBitmap; -
setTextLeadingvoid function(int lineHeightAdustment) setTextLeading; -
setBitmapMaskint function(LCDBitmap* bitmap, LCDBitmap* mask) setBitmapMask; -
getBitmapMaskLCDBitmap* function(LCDBitmap* bitmap) getBitmapMask; -
setStencilImagevoid function(LCDBitmap* stencil, int tile) setStencilImage; -
makeFontFromDataLCDFont* function(LCDFontData* data, int wide) makeFontFromData;
-
drawTextnothrow @nogc int drawText(Graphics*gfx, stringtext, intx, inty, PDStringEncodingencoding= PDStringEncoding.utf8Encoding); -
Spritestruct Sprite; -
Displaystruct Display;-
getWidthint function() getWidth; -
getHeightint function() getHeight; -
setRefreshRatevoid function(float rate) setRefreshRate; -
setInvertedvoid function(int flag) setInverted; -
setScalevoid function(uint s) setScale; -
setMosaicvoid function(uint x, uint y) setMosaic; -
setFlippedvoid function(int x, int y) setFlipped; -
setOffsetvoid function(int x, int y) setOffset;
-
SoundChannelalias SoundChannel = void*;A SoundChannel contains
SoundSources andSoundEffects. -
SoundChannelApistruct SoundChannelApi;-
newChannelSoundChannel function() newChannel; -
freeChannelvoid function(SoundChannel channel) freeChannel; -
addSourceint function(SoundChannel channel, SoundSource* source) addSource; -
removeSourceint function(SoundChannel channel, SoundSource* source) removeSource; -
addCallbackSourceSoundSource* function(SoundChannel channel, AudioSourceFunction* callback, void* context, int stereo) addCallbackSource;Creates a new
SoundSourceusing the given data providercallbackand adds it to the default channel.Remarks
The caller takes ownership of the allocatedSoundSource, and should free it withplaydate.system.realloc(source, NULL);when it is no longer in use. -
addEffectvoid function(SoundChannel channel, SoundEffect* effect) addEffect; -
removeEffectvoid function(SoundChannel channel, SoundEffect* effect) removeEffect; -
setVolumevoid function(SoundChannel channel, float volume) setVolume; -
getVolumefloat function(SoundChannel channel) getVolume; -
setVolumeModulatorvoid function(SoundChannel channel, PDSynthSignalValue mod) setVolumeModulator; -
getVolumeModulatorPDSynthSignalValue function(SoundChannel channel) getVolumeModulator; -
setPanvoid function(SoundChannel channel, float pan) setPan; -
setPanModulatorvoid function(SoundChannel channel, PDSynthSignalValue mod) setPanModulator; -
getPanModulatorPDSynthSignalValue function(SoundChannel channel) getPanModulator; -
getDryLevelSignalPDSynthSignalValue function(SoundChannel channel) getDryLevelSignal; -
getWetLevelSignalPDSynthSignalValue function(SoundChannel channel) getWetLevelSignal;
-
SoundFileplayerstruct SoundFileplayer; -
SoundSamplestruct SoundSample; -
SoundSampleplayerstruct SoundSampleplayer; -
SoundSynthstruct SoundSynth; -
SoundSequencestruct SoundSequence; -
SoundEffectalias SoundEffect = void*; -
SoundEffectApistruct SoundEffectApi; -
SoundLfostruct SoundLfo; -
SoundEnvelopestruct SoundEnvelope; -
SoundSourcestruct SoundSource; -
ControlSignalstruct ControlSignal; -
SoundTrackstruct SoundTrack; -
SoundInstrumentstruct SoundInstrument; -
PDSynthSignalValuealias PDSynthSignalValue = void*;A PDSynthSignalValue represents a signal that can be used as an input to a modulator. Its
PDSynthSignalsubclass is used for "active" signals that change their values automatically.PDSynthLFOandPDSynthEnvelopeare subclasses ofPDSynthSignal. -
SoundSignalstruct SoundSignal; -
Soundstruct Sound;-
channelSoundChannelApi* channel; -
fileplayerSoundFileplayer* fileplayer; -
sampleSoundSample* sample; -
sampleplayerSoundSampleplayer* sampleplayer; -
synthSoundSynth* synth; -
sequenceSoundSequence* sequence; -
effectSoundEffectApi* effect; -
lfoSoundLfo* lfo; -
envelopeSoundEnvelope* envelope; -
sourceSoundSource* source; -
controlsignalControlSignal* controlsignal; -
trackSoundTrack* track; -
instrumentSoundInstrument* instrument; -
getCurrentTimeuint function() getCurrentTime; -
addSourceSoundSource* function(AudioSourceFunction callback, void* context, bool stereo) addSource;The
callbackfunction you pass in will be called every audio render cycle. -
getDefaultChannelSoundChannel function() getDefaultChannel; -
addChannelvoid function(SoundChannel channel) addChannel; -
removeChannelvoid function(SoundChannel channel) removeChannel; -
setMicCallbackvoid function(RecordCallback callback, void* context, bool forceInternal) setMicCallback;The
callbackyou pass in will be called every audio cycle.If
forceInternalis set, the device microphone is used regardless of whether the headset has a microphone. -
getHeadphoneStatevoid function(bool* headphone, bool* headsetmic, void function(bool headphone, bool mic) changeCallback) getHeadphoneState;If
headphonecontains a non-nullpointer, the value is set totrueif headphones are currently plugged in. Likewise, mic is set if the headphones include a microphone. IfchangeCallbackis 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 useplaydate.sound.setOutputsActive()to change the output if needed. -
setOutputsActivevoid function(bool headphone, bool speaker) setOutputsActive;Force audio output to the given outputs, regardless of headphone status.
-
removeSourcevoid function(SoundSource* source) removeSource; -
signalSoundSignal* signal;
-
Luastruct Lua; -
Jsonstruct Json; -
Scoreboardsstruct Scoreboards; -
PlaydateAPIstruct PlaydateAPI; -
EventHandlerShimtemplate EventHandlerShim()Generates a shim around your
eventHandlerused by the Playdate OS as the entry-point to your application.